babylon.max.js 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123
  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. /**
  4444. * Clone the current animation group and returns a copy
  4445. * @param newName defines the name of the new group
  4446. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4447. * @returns the new aniamtion group
  4448. */
  4449. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4450. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4451. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4452. var targetAnimation = _a[_i];
  4453. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4454. }
  4455. return newGroup;
  4456. };
  4457. // Statics
  4458. /**
  4459. * Returns a new AnimationGroup object parsed from the source provided.
  4460. * @param parsedAnimationGroup defines the source
  4461. * @param scene defines the scene that will receive the animationGroup
  4462. * @returns a new AnimationGroup
  4463. */
  4464. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4465. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4466. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4467. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4468. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4469. var id = targetedAnimation.targetId;
  4470. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4471. var morphTarget = scene.getMorphTargetById(id);
  4472. if (morphTarget) {
  4473. animationGroup.addTargetedAnimation(animation, morphTarget);
  4474. }
  4475. }
  4476. else {
  4477. var targetNode = scene.getNodeByID(id);
  4478. if (targetNode != null) {
  4479. animationGroup.addTargetedAnimation(animation, targetNode);
  4480. }
  4481. }
  4482. }
  4483. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4484. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4485. }
  4486. return animationGroup;
  4487. };
  4488. /**
  4489. * Returns the string "AnimationGroup"
  4490. * @returns "AnimationGroup"
  4491. */
  4492. AnimationGroup.prototype.getClassName = function () {
  4493. return "AnimationGroup";
  4494. };
  4495. /**
  4496. * Creates a detailled string about the object
  4497. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4498. * @returns a string representing the object
  4499. */
  4500. AnimationGroup.prototype.toString = function (fullDetails) {
  4501. var ret = "Name: " + this.name;
  4502. ret += ", type: " + this.getClassName();
  4503. if (fullDetails) {
  4504. ret += ", from: " + this._from;
  4505. ret += ", to: " + this._to;
  4506. ret += ", isStarted: " + this._isStarted;
  4507. ret += ", speedRatio: " + this._speedRatio;
  4508. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4509. ret += ", animatables length: " + this._animatables;
  4510. }
  4511. return ret;
  4512. };
  4513. return AnimationGroup;
  4514. }());
  4515. /***/ }),
  4516. /***/ "./Animations/animationKey.ts":
  4517. /*!************************************!*\
  4518. !*** ./Animations/animationKey.ts ***!
  4519. \************************************/
  4520. /*! exports provided: AnimationKeyInterpolation */
  4521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4522. "use strict";
  4523. __webpack_require__.r(__webpack_exports__);
  4524. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4525. /**
  4526. * Enum for the animation key frame interpolation type
  4527. */
  4528. var AnimationKeyInterpolation;
  4529. (function (AnimationKeyInterpolation) {
  4530. /**
  4531. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4532. */
  4533. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4534. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4535. /***/ }),
  4536. /***/ "./Animations/animationPropertiesOverride.ts":
  4537. /*!***************************************************!*\
  4538. !*** ./Animations/animationPropertiesOverride.ts ***!
  4539. \***************************************************/
  4540. /*! exports provided: AnimationPropertiesOverride */
  4541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4542. "use strict";
  4543. __webpack_require__.r(__webpack_exports__);
  4544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4545. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4546. /**
  4547. * Class used to override all child animations of a given target
  4548. */
  4549. var AnimationPropertiesOverride = /** @class */ (function () {
  4550. function AnimationPropertiesOverride() {
  4551. /**
  4552. * Gets or sets a value indicating if animation blending must be used
  4553. */
  4554. this.enableBlending = false;
  4555. /**
  4556. * Gets or sets the blending speed to use when enableBlending is true
  4557. */
  4558. this.blendingSpeed = 0.01;
  4559. /**
  4560. * Gets or sets the default loop mode to use
  4561. */
  4562. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4563. }
  4564. return AnimationPropertiesOverride;
  4565. }());
  4566. /***/ }),
  4567. /***/ "./Animations/animationRange.ts":
  4568. /*!**************************************!*\
  4569. !*** ./Animations/animationRange.ts ***!
  4570. \**************************************/
  4571. /*! exports provided: AnimationRange */
  4572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4573. "use strict";
  4574. __webpack_require__.r(__webpack_exports__);
  4575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4576. /**
  4577. * Represents the range of an animation
  4578. */
  4579. var AnimationRange = /** @class */ (function () {
  4580. /**
  4581. * Initializes the range of an animation
  4582. * @param name The name of the animation range
  4583. * @param from The starting frame of the animation
  4584. * @param to The ending frame of the animation
  4585. */
  4586. function AnimationRange(
  4587. /**The name of the animation range**/
  4588. name,
  4589. /**The starting frame of the animation */
  4590. from,
  4591. /**The ending frame of the animation*/
  4592. to) {
  4593. this.name = name;
  4594. this.from = from;
  4595. this.to = to;
  4596. }
  4597. /**
  4598. * Makes a copy of the animation range
  4599. * @returns A copy of the animation range
  4600. */
  4601. AnimationRange.prototype.clone = function () {
  4602. return new AnimationRange(this.name, this.from, this.to);
  4603. };
  4604. return AnimationRange;
  4605. }());
  4606. /***/ }),
  4607. /***/ "./Animations/easing.ts":
  4608. /*!******************************!*\
  4609. !*** ./Animations/easing.ts ***!
  4610. \******************************/
  4611. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4613. "use strict";
  4614. __webpack_require__.r(__webpack_exports__);
  4615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4628. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4630. /**
  4631. * Base class used for every default easing function.
  4632. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4633. */
  4634. var EasingFunction = /** @class */ (function () {
  4635. function EasingFunction() {
  4636. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4637. }
  4638. /**
  4639. * Sets the easing mode of the current function.
  4640. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4641. */
  4642. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4643. var n = Math.min(Math.max(easingMode, 0), 2);
  4644. this._easingMode = n;
  4645. };
  4646. /**
  4647. * Gets the current easing mode.
  4648. * @returns the easing mode
  4649. */
  4650. EasingFunction.prototype.getEasingMode = function () {
  4651. return this._easingMode;
  4652. };
  4653. /**
  4654. * @hidden
  4655. */
  4656. EasingFunction.prototype.easeInCore = function (gradient) {
  4657. throw new Error('You must implement this method');
  4658. };
  4659. /**
  4660. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4661. * of the easing function.
  4662. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4663. * @returns the corresponding value on the curve defined by the easing function
  4664. */
  4665. EasingFunction.prototype.ease = function (gradient) {
  4666. switch (this._easingMode) {
  4667. case EasingFunction.EASINGMODE_EASEIN:
  4668. return this.easeInCore(gradient);
  4669. case EasingFunction.EASINGMODE_EASEOUT:
  4670. return (1 - this.easeInCore(1 - gradient));
  4671. }
  4672. if (gradient >= 0.5) {
  4673. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4674. }
  4675. return (this.easeInCore(gradient * 2) * 0.5);
  4676. };
  4677. /**
  4678. * Interpolation follows the mathematical formula associated with the easing function.
  4679. */
  4680. EasingFunction.EASINGMODE_EASEIN = 0;
  4681. /**
  4682. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4683. */
  4684. EasingFunction.EASINGMODE_EASEOUT = 1;
  4685. /**
  4686. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4687. */
  4688. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4689. return EasingFunction;
  4690. }());
  4691. /**
  4692. * Easing function with a circle shape (see link below).
  4693. * @see https://easings.net/#easeInCirc
  4694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4695. */
  4696. var CircleEase = /** @class */ (function (_super) {
  4697. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4698. function CircleEase() {
  4699. return _super !== null && _super.apply(this, arguments) || this;
  4700. }
  4701. /** @hidden */
  4702. CircleEase.prototype.easeInCore = function (gradient) {
  4703. gradient = Math.max(0, Math.min(1, gradient));
  4704. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4705. };
  4706. return CircleEase;
  4707. }(EasingFunction));
  4708. /**
  4709. * Easing function with a ease back shape (see link below).
  4710. * @see https://easings.net/#easeInBack
  4711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4712. */
  4713. var BackEase = /** @class */ (function (_super) {
  4714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4715. /**
  4716. * Instantiates a back ease easing
  4717. * @see https://easings.net/#easeInBack
  4718. * @param amplitude Defines the amplitude of the function
  4719. */
  4720. function BackEase(
  4721. /** Defines the amplitude of the function */
  4722. amplitude) {
  4723. if (amplitude === void 0) { amplitude = 1; }
  4724. var _this = _super.call(this) || this;
  4725. _this.amplitude = amplitude;
  4726. return _this;
  4727. }
  4728. /** @hidden */
  4729. BackEase.prototype.easeInCore = function (gradient) {
  4730. var num = Math.max(0, this.amplitude);
  4731. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4732. };
  4733. return BackEase;
  4734. }(EasingFunction));
  4735. /**
  4736. * Easing function with a bouncing shape (see link below).
  4737. * @see https://easings.net/#easeInBounce
  4738. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4739. */
  4740. var BounceEase = /** @class */ (function (_super) {
  4741. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4742. /**
  4743. * Instantiates a bounce easing
  4744. * @see https://easings.net/#easeInBounce
  4745. * @param bounces Defines the number of bounces
  4746. * @param bounciness Defines the amplitude of the bounce
  4747. */
  4748. function BounceEase(
  4749. /** Defines the number of bounces */
  4750. bounces,
  4751. /** Defines the amplitude of the bounce */
  4752. bounciness) {
  4753. if (bounces === void 0) { bounces = 3; }
  4754. if (bounciness === void 0) { bounciness = 2; }
  4755. var _this = _super.call(this) || this;
  4756. _this.bounces = bounces;
  4757. _this.bounciness = bounciness;
  4758. return _this;
  4759. }
  4760. /** @hidden */
  4761. BounceEase.prototype.easeInCore = function (gradient) {
  4762. var y = Math.max(0.0, this.bounces);
  4763. var bounciness = this.bounciness;
  4764. if (bounciness <= 1.0) {
  4765. bounciness = 1.001;
  4766. }
  4767. var num9 = Math.pow(bounciness, y);
  4768. var num5 = 1.0 - bounciness;
  4769. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4770. var num15 = gradient * num4;
  4771. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4772. var num3 = Math.floor(num65);
  4773. var num13 = num3 + 1.0;
  4774. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4775. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4776. var num7 = (num8 + num12) * 0.5;
  4777. var num6 = gradient - num7;
  4778. var num2 = num7 - num8;
  4779. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4780. };
  4781. return BounceEase;
  4782. }(EasingFunction));
  4783. /**
  4784. * Easing function with a power of 3 shape (see link below).
  4785. * @see https://easings.net/#easeInCubic
  4786. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4787. */
  4788. var CubicEase = /** @class */ (function (_super) {
  4789. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4790. function CubicEase() {
  4791. return _super !== null && _super.apply(this, arguments) || this;
  4792. }
  4793. /** @hidden */
  4794. CubicEase.prototype.easeInCore = function (gradient) {
  4795. return (gradient * gradient * gradient);
  4796. };
  4797. return CubicEase;
  4798. }(EasingFunction));
  4799. /**
  4800. * Easing function with an elastic shape (see link below).
  4801. * @see https://easings.net/#easeInElastic
  4802. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4803. */
  4804. var ElasticEase = /** @class */ (function (_super) {
  4805. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4806. /**
  4807. * Instantiates an elastic easing function
  4808. * @see https://easings.net/#easeInElastic
  4809. * @param oscillations Defines the number of oscillations
  4810. * @param springiness Defines the amplitude of the oscillations
  4811. */
  4812. function ElasticEase(
  4813. /** Defines the number of oscillations*/
  4814. oscillations,
  4815. /** Defines the amplitude of the oscillations*/
  4816. springiness) {
  4817. if (oscillations === void 0) { oscillations = 3; }
  4818. if (springiness === void 0) { springiness = 3; }
  4819. var _this = _super.call(this) || this;
  4820. _this.oscillations = oscillations;
  4821. _this.springiness = springiness;
  4822. return _this;
  4823. }
  4824. /** @hidden */
  4825. ElasticEase.prototype.easeInCore = function (gradient) {
  4826. var num2;
  4827. var num3 = Math.max(0.0, this.oscillations);
  4828. var num = Math.max(0.0, this.springiness);
  4829. if (num == 0) {
  4830. num2 = gradient;
  4831. }
  4832. else {
  4833. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4834. }
  4835. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4836. };
  4837. return ElasticEase;
  4838. }(EasingFunction));
  4839. /**
  4840. * Easing function with an exponential shape (see link below).
  4841. * @see https://easings.net/#easeInExpo
  4842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4843. */
  4844. var ExponentialEase = /** @class */ (function (_super) {
  4845. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4846. /**
  4847. * Instantiates an exponential easing function
  4848. * @see https://easings.net/#easeInExpo
  4849. * @param exponent Defines the exponent of the function
  4850. */
  4851. function ExponentialEase(
  4852. /** Defines the exponent of the function */
  4853. exponent) {
  4854. if (exponent === void 0) { exponent = 2; }
  4855. var _this = _super.call(this) || this;
  4856. _this.exponent = exponent;
  4857. return _this;
  4858. }
  4859. /** @hidden */
  4860. ExponentialEase.prototype.easeInCore = function (gradient) {
  4861. if (this.exponent <= 0) {
  4862. return gradient;
  4863. }
  4864. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4865. };
  4866. return ExponentialEase;
  4867. }(EasingFunction));
  4868. /**
  4869. * Easing function with a power shape (see link below).
  4870. * @see https://easings.net/#easeInQuad
  4871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4872. */
  4873. var PowerEase = /** @class */ (function (_super) {
  4874. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4875. /**
  4876. * Instantiates an power base easing function
  4877. * @see https://easings.net/#easeInQuad
  4878. * @param power Defines the power of the function
  4879. */
  4880. function PowerEase(
  4881. /** Defines the power of the function */
  4882. power) {
  4883. if (power === void 0) { power = 2; }
  4884. var _this = _super.call(this) || this;
  4885. _this.power = power;
  4886. return _this;
  4887. }
  4888. /** @hidden */
  4889. PowerEase.prototype.easeInCore = function (gradient) {
  4890. var y = Math.max(0.0, this.power);
  4891. return Math.pow(gradient, y);
  4892. };
  4893. return PowerEase;
  4894. }(EasingFunction));
  4895. /**
  4896. * Easing function with a power of 2 shape (see link below).
  4897. * @see https://easings.net/#easeInQuad
  4898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4899. */
  4900. var QuadraticEase = /** @class */ (function (_super) {
  4901. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4902. function QuadraticEase() {
  4903. return _super !== null && _super.apply(this, arguments) || this;
  4904. }
  4905. /** @hidden */
  4906. QuadraticEase.prototype.easeInCore = function (gradient) {
  4907. return (gradient * gradient);
  4908. };
  4909. return QuadraticEase;
  4910. }(EasingFunction));
  4911. /**
  4912. * Easing function with a power of 4 shape (see link below).
  4913. * @see https://easings.net/#easeInQuart
  4914. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4915. */
  4916. var QuarticEase = /** @class */ (function (_super) {
  4917. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4918. function QuarticEase() {
  4919. return _super !== null && _super.apply(this, arguments) || this;
  4920. }
  4921. /** @hidden */
  4922. QuarticEase.prototype.easeInCore = function (gradient) {
  4923. return (gradient * gradient * gradient * gradient);
  4924. };
  4925. return QuarticEase;
  4926. }(EasingFunction));
  4927. /**
  4928. * Easing function with a power of 5 shape (see link below).
  4929. * @see https://easings.net/#easeInQuint
  4930. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4931. */
  4932. var QuinticEase = /** @class */ (function (_super) {
  4933. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4934. function QuinticEase() {
  4935. return _super !== null && _super.apply(this, arguments) || this;
  4936. }
  4937. /** @hidden */
  4938. QuinticEase.prototype.easeInCore = function (gradient) {
  4939. return (gradient * gradient * gradient * gradient * gradient);
  4940. };
  4941. return QuinticEase;
  4942. }(EasingFunction));
  4943. /**
  4944. * Easing function with a sin shape (see link below).
  4945. * @see https://easings.net/#easeInSine
  4946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4947. */
  4948. var SineEase = /** @class */ (function (_super) {
  4949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4950. function SineEase() {
  4951. return _super !== null && _super.apply(this, arguments) || this;
  4952. }
  4953. /** @hidden */
  4954. SineEase.prototype.easeInCore = function (gradient) {
  4955. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4956. };
  4957. return SineEase;
  4958. }(EasingFunction));
  4959. /**
  4960. * Easing function with a bezier shape (see link below).
  4961. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4963. */
  4964. var BezierCurveEase = /** @class */ (function (_super) {
  4965. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4966. /**
  4967. * Instantiates a bezier function
  4968. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4969. * @param x1 Defines the x component of the start tangent in the bezier curve
  4970. * @param y1 Defines the y component of the start tangent in the bezier curve
  4971. * @param x2 Defines the x component of the end tangent in the bezier curve
  4972. * @param y2 Defines the y component of the end tangent in the bezier curve
  4973. */
  4974. function BezierCurveEase(
  4975. /** Defines the x component of the start tangent in the bezier curve */
  4976. x1,
  4977. /** Defines the y component of the start tangent in the bezier curve */
  4978. y1,
  4979. /** Defines the x component of the end tangent in the bezier curve */
  4980. x2,
  4981. /** Defines the y component of the end tangent in the bezier curve */
  4982. y2) {
  4983. if (x1 === void 0) { x1 = 0; }
  4984. if (y1 === void 0) { y1 = 0; }
  4985. if (x2 === void 0) { x2 = 1; }
  4986. if (y2 === void 0) { y2 = 1; }
  4987. var _this = _super.call(this) || this;
  4988. _this.x1 = x1;
  4989. _this.y1 = y1;
  4990. _this.x2 = x2;
  4991. _this.y2 = y2;
  4992. return _this;
  4993. }
  4994. /** @hidden */
  4995. BezierCurveEase.prototype.easeInCore = function (gradient) {
  4996. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  4997. };
  4998. return BezierCurveEase;
  4999. }(EasingFunction));
  5000. /***/ }),
  5001. /***/ "./Animations/index.ts":
  5002. /*!*****************************!*\
  5003. !*** ./Animations/index.ts ***!
  5004. \*****************************/
  5005. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5007. "use strict";
  5008. __webpack_require__.r(__webpack_exports__);
  5009. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5011. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5013. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5016. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5018. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5032. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5034. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5036. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5038. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5040. /***/ }),
  5041. /***/ "./Animations/runtimeAnimation.ts":
  5042. /*!****************************************!*\
  5043. !*** ./Animations/runtimeAnimation.ts ***!
  5044. \****************************************/
  5045. /*! exports provided: RuntimeAnimation */
  5046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5047. "use strict";
  5048. __webpack_require__.r(__webpack_exports__);
  5049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5050. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5051. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5052. // Static values to help the garbage collector
  5053. // Quaternion
  5054. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5055. // Vector3
  5056. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5057. // Vector2
  5058. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5059. // Size
  5060. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5061. // Color3
  5062. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5063. /**
  5064. * Defines a runtime animation
  5065. */
  5066. var RuntimeAnimation = /** @class */ (function () {
  5067. /**
  5068. * Create a new RuntimeAnimation object
  5069. * @param target defines the target of the animation
  5070. * @param animation defines the source animation object
  5071. * @param scene defines the hosting scene
  5072. * @param host defines the initiating Animatable
  5073. */
  5074. function RuntimeAnimation(target, animation, scene, host) {
  5075. var _this = this;
  5076. this._events = new Array();
  5077. /**
  5078. * The current frame of the runtime animation
  5079. */
  5080. this._currentFrame = 0;
  5081. /**
  5082. * The original value of the runtime animation
  5083. */
  5084. this._originalValue = new Array();
  5085. /**
  5086. * The offsets cache of the runtime animation
  5087. */
  5088. this._offsetsCache = {};
  5089. /**
  5090. * The high limits cache of the runtime animation
  5091. */
  5092. this._highLimitsCache = {};
  5093. /**
  5094. * Specifies if the runtime animation has been stopped
  5095. */
  5096. this._stopped = false;
  5097. /**
  5098. * The blending factor of the runtime animation
  5099. */
  5100. this._blendingFactor = 0;
  5101. /**
  5102. * The target path of the runtime animation
  5103. */
  5104. this._targetPath = "";
  5105. /**
  5106. * The weight of the runtime animation
  5107. */
  5108. this._weight = 1.0;
  5109. /**
  5110. * The ratio offset of the runtime animation
  5111. */
  5112. this._ratioOffset = 0;
  5113. /**
  5114. * The previous delay of the runtime animation
  5115. */
  5116. this._previousDelay = 0;
  5117. /**
  5118. * The previous ratio of the runtime animation
  5119. */
  5120. this._previousRatio = 0;
  5121. this._animation = animation;
  5122. this._target = target;
  5123. this._scene = scene;
  5124. this._host = host;
  5125. animation._runtimeAnimations.push(this);
  5126. // Cloning events locally
  5127. var events = animation.getEvents();
  5128. if (events && events.length > 0) {
  5129. events.forEach(function (e) {
  5130. _this._events.push(e._clone());
  5131. });
  5132. }
  5133. }
  5134. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5135. /**
  5136. * Gets the current frame of the runtime animation
  5137. */
  5138. get: function () {
  5139. return this._currentFrame;
  5140. },
  5141. enumerable: true,
  5142. configurable: true
  5143. });
  5144. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5145. /**
  5146. * Gets the weight of the runtime animation
  5147. */
  5148. get: function () {
  5149. return this._weight;
  5150. },
  5151. enumerable: true,
  5152. configurable: true
  5153. });
  5154. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5155. /**
  5156. * Gets the current value of the runtime animation
  5157. */
  5158. get: function () {
  5159. return this._currentValue;
  5160. },
  5161. enumerable: true,
  5162. configurable: true
  5163. });
  5164. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5165. /**
  5166. * Gets the target path of the runtime animation
  5167. */
  5168. get: function () {
  5169. return this._targetPath;
  5170. },
  5171. enumerable: true,
  5172. configurable: true
  5173. });
  5174. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5175. /**
  5176. * Gets the actual target of the runtime animation
  5177. */
  5178. get: function () {
  5179. return this._activeTarget;
  5180. },
  5181. enumerable: true,
  5182. configurable: true
  5183. });
  5184. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5185. /**
  5186. * Gets the animation from the runtime animation
  5187. */
  5188. get: function () {
  5189. return this._animation;
  5190. },
  5191. enumerable: true,
  5192. configurable: true
  5193. });
  5194. /**
  5195. * Resets the runtime animation to the beginning
  5196. * @param restoreOriginal defines whether to restore the target property to the original value
  5197. */
  5198. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5199. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5200. if (restoreOriginal) {
  5201. if (this._target instanceof Array) {
  5202. var index = 0;
  5203. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5204. var target = _a[_i];
  5205. if (this._originalValue[index] !== undefined) {
  5206. this._setValue(target, this._originalValue[index], -1);
  5207. }
  5208. index++;
  5209. }
  5210. }
  5211. else {
  5212. if (this._originalValue[0] !== undefined) {
  5213. this._setValue(this._target, this._originalValue[0], -1);
  5214. }
  5215. }
  5216. }
  5217. this._offsetsCache = {};
  5218. this._highLimitsCache = {};
  5219. this._currentFrame = 0;
  5220. this._blendingFactor = 0;
  5221. this._originalValue = new Array();
  5222. // Events
  5223. for (var index = 0; index < this._events.length; index++) {
  5224. this._events[index].isDone = false;
  5225. }
  5226. };
  5227. /**
  5228. * Specifies if the runtime animation is stopped
  5229. * @returns Boolean specifying if the runtime animation is stopped
  5230. */
  5231. RuntimeAnimation.prototype.isStopped = function () {
  5232. return this._stopped;
  5233. };
  5234. /**
  5235. * Disposes of the runtime animation
  5236. */
  5237. RuntimeAnimation.prototype.dispose = function () {
  5238. var index = this._animation.runtimeAnimations.indexOf(this);
  5239. if (index > -1) {
  5240. this._animation.runtimeAnimations.splice(index, 1);
  5241. }
  5242. };
  5243. /**
  5244. * Interpolates the animation from the current frame
  5245. * @param currentFrame The frame to interpolate the animation to
  5246. * @param repeatCount The number of times that the animation should loop
  5247. * @param loopMode The type of looping mode to use
  5248. * @param offsetValue Animation offset value
  5249. * @param highLimitValue The high limit value
  5250. * @returns The interpolated value
  5251. */
  5252. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5253. this._currentFrame = currentFrame;
  5254. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5255. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5256. }
  5257. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5258. };
  5259. /**
  5260. * Apply the interpolated value to the target
  5261. * @param currentValue defines the value computed by the animation
  5262. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5263. */
  5264. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5265. if (weight === void 0) { weight = 1.0; }
  5266. if (this._target instanceof Array) {
  5267. var index = 0;
  5268. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5269. var target = _a[_i];
  5270. this._setValue(target, currentValue, weight, index);
  5271. index++;
  5272. }
  5273. }
  5274. else {
  5275. this._setValue(this._target, currentValue, weight);
  5276. }
  5277. };
  5278. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5279. if (targetIndex === void 0) { targetIndex = 0; }
  5280. // Set value
  5281. var path;
  5282. var destination;
  5283. var targetPropertyPath = this._animation.targetPropertyPath;
  5284. if (targetPropertyPath.length > 1) {
  5285. var property = target[targetPropertyPath[0]];
  5286. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5287. property = property[targetPropertyPath[index]];
  5288. }
  5289. path = targetPropertyPath[targetPropertyPath.length - 1];
  5290. destination = property;
  5291. }
  5292. else {
  5293. path = targetPropertyPath[0];
  5294. destination = target;
  5295. }
  5296. this._targetPath = path;
  5297. this._activeTarget = destination;
  5298. this._weight = weight;
  5299. if (this._originalValue[targetIndex] === undefined) {
  5300. var originalValue = void 0;
  5301. if (destination.getRestPose && path === "_matrix") { // For bones
  5302. originalValue = destination.getRestPose();
  5303. }
  5304. else {
  5305. originalValue = destination[path];
  5306. }
  5307. if (originalValue && originalValue.clone) {
  5308. this._originalValue[targetIndex] = originalValue.clone();
  5309. }
  5310. else {
  5311. this._originalValue[targetIndex] = originalValue;
  5312. }
  5313. }
  5314. // Blending
  5315. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5316. if (enableBlending && this._blendingFactor <= 1.0) {
  5317. if (!this._originalBlendValue) {
  5318. var originalValue = destination[path];
  5319. if (originalValue.clone) {
  5320. this._originalBlendValue = originalValue.clone();
  5321. }
  5322. else {
  5323. this._originalBlendValue = originalValue;
  5324. }
  5325. }
  5326. if (this._originalBlendValue.m) { // Matrix
  5327. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5328. if (this._currentValue) {
  5329. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5330. }
  5331. else {
  5332. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5333. }
  5334. }
  5335. else {
  5336. if (this._currentValue) {
  5337. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5338. }
  5339. else {
  5340. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5341. }
  5342. }
  5343. }
  5344. else {
  5345. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5346. }
  5347. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5348. this._blendingFactor += blendingSpeed;
  5349. }
  5350. else {
  5351. this._currentValue = currentValue;
  5352. }
  5353. if (weight !== -1.0) {
  5354. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5355. }
  5356. else {
  5357. destination[path] = this._currentValue;
  5358. }
  5359. if (target.markAsDirty) {
  5360. target.markAsDirty(this._animation.targetProperty);
  5361. }
  5362. };
  5363. /**
  5364. * Gets the loop pmode of the runtime animation
  5365. * @returns Loop Mode
  5366. */
  5367. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5368. if (this._target && this._target.animationPropertiesOverride) {
  5369. return this._target.animationPropertiesOverride.loopMode;
  5370. }
  5371. return this._animation.loopMode;
  5372. };
  5373. /**
  5374. * Move the current animation to a given frame
  5375. * @param frame defines the frame to move to
  5376. */
  5377. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5378. var keys = this._animation.getKeys();
  5379. if (frame < keys[0].frame) {
  5380. frame = keys[0].frame;
  5381. }
  5382. else if (frame > keys[keys.length - 1].frame) {
  5383. frame = keys[keys.length - 1].frame;
  5384. }
  5385. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5386. this.setValue(currentValue, -1);
  5387. };
  5388. /**
  5389. * @hidden Internal use only
  5390. */
  5391. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5392. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5393. this._ratioOffset = this._previousRatio - newRatio;
  5394. };
  5395. /**
  5396. * Execute the current animation
  5397. * @param delay defines the delay to add to the current frame
  5398. * @param from defines the lower bound of the animation range
  5399. * @param to defines the upper bound of the animation range
  5400. * @param loop defines if the current animation must loop
  5401. * @param speedRatio defines the current speed ratio
  5402. * @param weight defines the weight of the animation (default is -1 so no weight)
  5403. * @param onLoop optional callback called when animation loops
  5404. * @returns a boolean indicating if the animation is running
  5405. */
  5406. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5407. if (weight === void 0) { weight = -1.0; }
  5408. var targetPropertyPath = this._animation.targetPropertyPath;
  5409. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5410. this._stopped = true;
  5411. return false;
  5412. }
  5413. var returnValue = true;
  5414. var keys = this._animation.getKeys();
  5415. // Adding a start key at frame 0 if missing
  5416. if (keys[0].frame !== 0) {
  5417. var newKey = { frame: 0, value: keys[0].value };
  5418. keys.splice(0, 0, newKey);
  5419. }
  5420. // Adding a duplicate key when there is only one key at frame zero
  5421. else if (keys.length === 1) {
  5422. var newKey = { frame: 0.001, value: keys[0].value };
  5423. keys.push(newKey);
  5424. }
  5425. // Check limits
  5426. if (from < keys[0].frame || from > keys[keys.length - 1].frame) {
  5427. from = keys[0].frame;
  5428. }
  5429. if (to < keys[0].frame || to > keys[keys.length - 1].frame) {
  5430. to = keys[keys.length - 1].frame;
  5431. }
  5432. //to and from cannot be the same key
  5433. if (from === to) {
  5434. if (from > keys[0].frame) {
  5435. from--;
  5436. }
  5437. else if (to < keys[keys.length - 1].frame) {
  5438. to++;
  5439. }
  5440. }
  5441. // Compute ratio
  5442. var range = to - from;
  5443. var offsetValue;
  5444. // ratio represents the frame delta between from and to
  5445. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5446. var highLimitValue = 0;
  5447. this._previousDelay = delay;
  5448. this._previousRatio = ratio;
  5449. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5450. returnValue = false;
  5451. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5452. }
  5453. else {
  5454. // Get max value if required
  5455. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5456. var keyOffset = to.toString() + from.toString();
  5457. if (!this._offsetsCache[keyOffset]) {
  5458. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5459. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5460. switch (this._animation.dataType) {
  5461. // Float
  5462. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5463. this._offsetsCache[keyOffset] = toValue - fromValue;
  5464. break;
  5465. // Quaternion
  5466. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5467. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5468. break;
  5469. // Vector3
  5470. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5471. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5472. // Vector2
  5473. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5474. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5475. // Size
  5476. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5477. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5478. // Color3
  5479. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5480. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5481. default:
  5482. break;
  5483. }
  5484. this._highLimitsCache[keyOffset] = toValue;
  5485. }
  5486. highLimitValue = this._highLimitsCache[keyOffset];
  5487. offsetValue = this._offsetsCache[keyOffset];
  5488. }
  5489. }
  5490. if (offsetValue === undefined) {
  5491. switch (this._animation.dataType) {
  5492. // Float
  5493. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5494. offsetValue = 0;
  5495. break;
  5496. // Quaternion
  5497. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5498. offsetValue = _staticOffsetValueQuaternion;
  5499. break;
  5500. // Vector3
  5501. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5502. offsetValue = _staticOffsetValueVector3;
  5503. break;
  5504. // Vector2
  5505. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5506. offsetValue = _staticOffsetValueVector2;
  5507. break;
  5508. // Size
  5509. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5510. offsetValue = _staticOffsetValueSize;
  5511. break;
  5512. // Color3
  5513. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5514. offsetValue = _staticOffsetValueColor3;
  5515. }
  5516. }
  5517. // Compute value
  5518. var repeatCount = (ratio / range) >> 0;
  5519. var currentFrame = returnValue ? from + ratio % range : to;
  5520. // Need to normalize?
  5521. if (this._host && this._host.syncRoot) {
  5522. var syncRoot = this._host.syncRoot;
  5523. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5524. currentFrame = from + (to - from) * hostNormalizedFrame;
  5525. }
  5526. // Reset events if looping
  5527. var events = this._events;
  5528. if (range > 0 && this.currentFrame > currentFrame ||
  5529. range < 0 && this.currentFrame < currentFrame) {
  5530. if (onLoop) {
  5531. onLoop();
  5532. }
  5533. // Need to reset animation events
  5534. for (var index = 0; index < events.length; index++) {
  5535. if (!events[index].onlyOnce) {
  5536. // reset event, the animation is looping
  5537. events[index].isDone = false;
  5538. }
  5539. }
  5540. }
  5541. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5542. // Set value
  5543. this.setValue(currentValue, weight);
  5544. // Check events
  5545. for (var index = 0; index < events.length; index++) {
  5546. // Make sure current frame has passed event frame and that event frame is within the current range
  5547. // Also, handle both forward and reverse animations
  5548. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5549. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5550. var event = events[index];
  5551. if (!event.isDone) {
  5552. // If event should be done only once, remove it.
  5553. if (event.onlyOnce) {
  5554. events.splice(index, 1);
  5555. index--;
  5556. }
  5557. event.isDone = true;
  5558. event.action(currentFrame);
  5559. } // Don't do anything if the event has already be done.
  5560. }
  5561. }
  5562. if (!returnValue) {
  5563. this._stopped = true;
  5564. }
  5565. return returnValue;
  5566. };
  5567. return RuntimeAnimation;
  5568. }());
  5569. /***/ }),
  5570. /***/ "./Audio/analyser.ts":
  5571. /*!***************************!*\
  5572. !*** ./Audio/analyser.ts ***!
  5573. \***************************/
  5574. /*! exports provided: Analyser */
  5575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5576. "use strict";
  5577. __webpack_require__.r(__webpack_exports__);
  5578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5579. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5580. /**
  5581. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5583. */
  5584. var Analyser = /** @class */ (function () {
  5585. /**
  5586. * Creates a new analyser
  5587. * @param scene defines hosting scene
  5588. */
  5589. function Analyser(scene) {
  5590. /**
  5591. * Gets or sets the smoothing
  5592. * @ignorenaming
  5593. */
  5594. this.SMOOTHING = 0.75;
  5595. /**
  5596. * Gets or sets the FFT table size
  5597. * @ignorenaming
  5598. */
  5599. this.FFT_SIZE = 512;
  5600. /**
  5601. * Gets or sets the bar graph amplitude
  5602. * @ignorenaming
  5603. */
  5604. this.BARGRAPHAMPLITUDE = 256;
  5605. /**
  5606. * Gets or sets the position of the debug canvas
  5607. * @ignorenaming
  5608. */
  5609. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5610. /**
  5611. * Gets or sets the debug canvas size
  5612. * @ignorenaming
  5613. */
  5614. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5615. this._scene = scene;
  5616. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5617. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5618. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5619. this._webAudioAnalyser.minDecibels = -140;
  5620. this._webAudioAnalyser.maxDecibels = 0;
  5621. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5622. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5623. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5624. }
  5625. }
  5626. /**
  5627. * Get the number of data values you will have to play with for the visualization
  5628. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5629. * @returns a number
  5630. */
  5631. Analyser.prototype.getFrequencyBinCount = function () {
  5632. if (this._audioEngine.canUseWebAudio) {
  5633. return this._webAudioAnalyser.frequencyBinCount;
  5634. }
  5635. else {
  5636. return 0;
  5637. }
  5638. };
  5639. /**
  5640. * Gets the current frequency data as a byte array
  5641. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5642. * @returns a Uint8Array
  5643. */
  5644. Analyser.prototype.getByteFrequencyData = function () {
  5645. if (this._audioEngine.canUseWebAudio) {
  5646. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5647. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5648. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5649. }
  5650. return this._byteFreqs;
  5651. };
  5652. /**
  5653. * Gets the current waveform as a byte array
  5654. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5655. * @returns a Uint8Array
  5656. */
  5657. Analyser.prototype.getByteTimeDomainData = function () {
  5658. if (this._audioEngine.canUseWebAudio) {
  5659. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5660. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5661. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5662. }
  5663. return this._byteTime;
  5664. };
  5665. /**
  5666. * Gets the current frequency data as a float array
  5667. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5668. * @returns a Float32Array
  5669. */
  5670. Analyser.prototype.getFloatFrequencyData = function () {
  5671. if (this._audioEngine.canUseWebAudio) {
  5672. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5673. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5674. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5675. }
  5676. return this._floatFreqs;
  5677. };
  5678. /**
  5679. * Renders the debug canvas
  5680. */
  5681. Analyser.prototype.drawDebugCanvas = function () {
  5682. var _this = this;
  5683. if (this._audioEngine.canUseWebAudio) {
  5684. if (!this._debugCanvas) {
  5685. this._debugCanvas = document.createElement("canvas");
  5686. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5687. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5688. this._debugCanvas.style.position = "absolute";
  5689. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5690. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5691. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5692. document.body.appendChild(this._debugCanvas);
  5693. this._registerFunc = function () {
  5694. _this.drawDebugCanvas();
  5695. };
  5696. this._scene.registerBeforeRender(this._registerFunc);
  5697. }
  5698. if (this._registerFunc && this._debugCanvasContext) {
  5699. var workingArray = this.getByteFrequencyData();
  5700. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5701. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5702. // Draw the frequency domain chart.
  5703. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5704. var value = workingArray[i];
  5705. var percent = value / this.BARGRAPHAMPLITUDE;
  5706. var height = this.DEBUGCANVASSIZE.height * percent;
  5707. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5708. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5709. var hue = i / this.getFrequencyBinCount() * 360;
  5710. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5711. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5712. }
  5713. }
  5714. }
  5715. };
  5716. /**
  5717. * Stops rendering the debug canvas and removes it
  5718. */
  5719. Analyser.prototype.stopDebugCanvas = function () {
  5720. if (this._debugCanvas) {
  5721. if (this._registerFunc) {
  5722. this._scene.unregisterBeforeRender(this._registerFunc);
  5723. this._registerFunc = null;
  5724. }
  5725. document.body.removeChild(this._debugCanvas);
  5726. this._debugCanvas = null;
  5727. this._debugCanvasContext = null;
  5728. }
  5729. };
  5730. /**
  5731. * Connects two audio nodes
  5732. * @param inputAudioNode defines first node to connect
  5733. * @param outputAudioNode defines second node to connect
  5734. */
  5735. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5736. if (this._audioEngine.canUseWebAudio) {
  5737. inputAudioNode.connect(this._webAudioAnalyser);
  5738. this._webAudioAnalyser.connect(outputAudioNode);
  5739. }
  5740. };
  5741. /**
  5742. * Releases all associated resources
  5743. */
  5744. Analyser.prototype.dispose = function () {
  5745. if (this._audioEngine.canUseWebAudio) {
  5746. this._webAudioAnalyser.disconnect();
  5747. }
  5748. };
  5749. return Analyser;
  5750. }());
  5751. /***/ }),
  5752. /***/ "./Audio/audioEngine.ts":
  5753. /*!******************************!*\
  5754. !*** ./Audio/audioEngine.ts ***!
  5755. \******************************/
  5756. /*! exports provided: AudioEngine */
  5757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5758. "use strict";
  5759. __webpack_require__.r(__webpack_exports__);
  5760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5761. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5762. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5763. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5764. // Sets the default audio engine to Babylon.js
  5765. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5766. /**
  5767. * This represents the default audio engine used in babylon.
  5768. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5770. */
  5771. var AudioEngine = /** @class */ (function () {
  5772. /**
  5773. * Instantiates a new audio engine.
  5774. *
  5775. * There should be only one per page as some browsers restrict the number
  5776. * of audio contexts you can create.
  5777. * @param hostElement defines the host element where to display the mute icon if necessary
  5778. */
  5779. function AudioEngine(hostElement) {
  5780. if (hostElement === void 0) { hostElement = null; }
  5781. var _this = this;
  5782. this._audioContext = null;
  5783. this._audioContextInitialized = false;
  5784. this._muteButton = null;
  5785. /**
  5786. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5787. */
  5788. this.canUseWebAudio = false;
  5789. /**
  5790. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5791. * @ignoreNaming
  5792. */
  5793. this.WarnedWebAudioUnsupported = false;
  5794. /**
  5795. * Gets whether or not mp3 are supported by your browser.
  5796. */
  5797. this.isMP3supported = false;
  5798. /**
  5799. * Gets whether or not ogg are supported by your browser.
  5800. */
  5801. this.isOGGsupported = false;
  5802. /**
  5803. * Gets whether audio has been unlocked on the device.
  5804. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5805. * a user interaction has happened.
  5806. */
  5807. this.unlocked = true;
  5808. /**
  5809. * Defines if the audio engine relies on a custom unlocked button.
  5810. * In this case, the embedded button will not be displayed.
  5811. */
  5812. this.useCustomUnlockedButton = false;
  5813. /**
  5814. * Event raised when audio has been unlocked on the browser.
  5815. */
  5816. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5817. /**
  5818. * Event raised when audio has been locked on the browser.
  5819. */
  5820. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5821. this._tryToRun = false;
  5822. this._onResize = function () {
  5823. _this._moveButtonToTopLeft();
  5824. };
  5825. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5826. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5827. this.canUseWebAudio = true;
  5828. }
  5829. var audioElem = document.createElement('audio');
  5830. this._hostElement = hostElement;
  5831. try {
  5832. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5833. this.isMP3supported = true;
  5834. }
  5835. }
  5836. catch (e) {
  5837. // protect error during capability check.
  5838. }
  5839. try {
  5840. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5841. this.isOGGsupported = true;
  5842. }
  5843. }
  5844. catch (e) {
  5845. // protect error during capability check.
  5846. }
  5847. }
  5848. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5849. /**
  5850. * Gets the current AudioContext if available.
  5851. */
  5852. get: function () {
  5853. if (!this._audioContextInitialized) {
  5854. this._initializeAudioContext();
  5855. }
  5856. else {
  5857. if (!this.unlocked && !this._muteButton) {
  5858. this._displayMuteButton();
  5859. }
  5860. }
  5861. return this._audioContext;
  5862. },
  5863. enumerable: true,
  5864. configurable: true
  5865. });
  5866. /**
  5867. * Flags the audio engine in Locked state.
  5868. * This happens due to new browser policies preventing audio to autoplay.
  5869. */
  5870. AudioEngine.prototype.lock = function () {
  5871. this._triggerSuspendedState();
  5872. };
  5873. /**
  5874. * Unlocks the audio engine once a user action has been done on the dom.
  5875. * This is helpful to resume play once browser policies have been satisfied.
  5876. */
  5877. AudioEngine.prototype.unlock = function () {
  5878. this._triggerRunningState();
  5879. };
  5880. AudioEngine.prototype._resumeAudioContext = function () {
  5881. var result;
  5882. if (this._audioContext.resume) {
  5883. result = this._audioContext.resume();
  5884. }
  5885. return result || Promise.resolve();
  5886. };
  5887. AudioEngine.prototype._initializeAudioContext = function () {
  5888. try {
  5889. if (this.canUseWebAudio) {
  5890. this._audioContext = new AudioContext();
  5891. // create a global volume gain node
  5892. this.masterGain = this._audioContext.createGain();
  5893. this.masterGain.gain.value = 1;
  5894. this.masterGain.connect(this._audioContext.destination);
  5895. this._audioContextInitialized = true;
  5896. if (this._audioContext.state === "running") {
  5897. // Do not wait for the promise to unlock.
  5898. this._triggerRunningState();
  5899. }
  5900. }
  5901. }
  5902. catch (e) {
  5903. this.canUseWebAudio = false;
  5904. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5905. }
  5906. };
  5907. AudioEngine.prototype._triggerRunningState = function () {
  5908. var _this = this;
  5909. if (this._tryToRun) {
  5910. return;
  5911. }
  5912. this._tryToRun = true;
  5913. this._resumeAudioContext()
  5914. .then(function () {
  5915. _this._tryToRun = false;
  5916. if (_this._muteButton) {
  5917. _this._hideMuteButton();
  5918. }
  5919. }).catch(function () {
  5920. _this._tryToRun = false;
  5921. _this.unlocked = false;
  5922. });
  5923. // Notify users that the audio stack is unlocked/unmuted
  5924. this.unlocked = true;
  5925. this.onAudioUnlockedObservable.notifyObservers(this);
  5926. };
  5927. AudioEngine.prototype._triggerSuspendedState = function () {
  5928. this.unlocked = false;
  5929. this.onAudioLockedObservable.notifyObservers(this);
  5930. this._displayMuteButton();
  5931. };
  5932. AudioEngine.prototype._displayMuteButton = function () {
  5933. var _this = this;
  5934. if (this.useCustomUnlockedButton || this._muteButton) {
  5935. return;
  5936. }
  5937. this._muteButton = document.createElement("BUTTON");
  5938. this._muteButton.className = "babylonUnmuteIcon";
  5939. this._muteButton.id = "babylonUnmuteIconBtn";
  5940. this._muteButton.title = "Unmute";
  5941. 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) }";
  5942. var style = document.createElement('style');
  5943. style.appendChild(document.createTextNode(css));
  5944. document.getElementsByTagName('head')[0].appendChild(style);
  5945. document.body.appendChild(this._muteButton);
  5946. this._moveButtonToTopLeft();
  5947. this._muteButton.addEventListener('touchend', function () {
  5948. _this._triggerRunningState();
  5949. }, true);
  5950. this._muteButton.addEventListener('click', function () {
  5951. _this._triggerRunningState();
  5952. }, true);
  5953. window.addEventListener("resize", this._onResize);
  5954. };
  5955. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5956. if (this._hostElement && this._muteButton) {
  5957. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5958. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5959. }
  5960. };
  5961. AudioEngine.prototype._hideMuteButton = function () {
  5962. if (this._muteButton) {
  5963. document.body.removeChild(this._muteButton);
  5964. this._muteButton = null;
  5965. }
  5966. };
  5967. /**
  5968. * Destroy and release the resources associated with the audio ccontext.
  5969. */
  5970. AudioEngine.prototype.dispose = function () {
  5971. if (this.canUseWebAudio && this._audioContextInitialized) {
  5972. if (this._connectedAnalyser && this._audioContext) {
  5973. this._connectedAnalyser.stopDebugCanvas();
  5974. this._connectedAnalyser.dispose();
  5975. this.masterGain.disconnect();
  5976. this.masterGain.connect(this._audioContext.destination);
  5977. this._connectedAnalyser = null;
  5978. }
  5979. this.masterGain.gain.value = 1;
  5980. }
  5981. this.WarnedWebAudioUnsupported = false;
  5982. this._hideMuteButton();
  5983. window.removeEventListener("resize", this._onResize);
  5984. this.onAudioUnlockedObservable.clear();
  5985. this.onAudioLockedObservable.clear();
  5986. };
  5987. /**
  5988. * Gets the global volume sets on the master gain.
  5989. * @returns the global volume if set or -1 otherwise
  5990. */
  5991. AudioEngine.prototype.getGlobalVolume = function () {
  5992. if (this.canUseWebAudio && this._audioContextInitialized) {
  5993. return this.masterGain.gain.value;
  5994. }
  5995. else {
  5996. return -1;
  5997. }
  5998. };
  5999. /**
  6000. * Sets the global volume of your experience (sets on the master gain).
  6001. * @param newVolume Defines the new global volume of the application
  6002. */
  6003. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  6004. if (this.canUseWebAudio && this._audioContextInitialized) {
  6005. this.masterGain.gain.value = newVolume;
  6006. }
  6007. };
  6008. /**
  6009. * Connect the audio engine to an audio analyser allowing some amazing
  6010. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6012. * @param analyser The analyser to connect to the engine
  6013. */
  6014. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6015. if (this._connectedAnalyser) {
  6016. this._connectedAnalyser.stopDebugCanvas();
  6017. }
  6018. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6019. this._connectedAnalyser = analyser;
  6020. this.masterGain.disconnect();
  6021. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6022. }
  6023. };
  6024. return AudioEngine;
  6025. }());
  6026. /***/ }),
  6027. /***/ "./Audio/audioSceneComponent.ts":
  6028. /*!**************************************!*\
  6029. !*** ./Audio/audioSceneComponent.ts ***!
  6030. \**************************************/
  6031. /*! exports provided: AudioSceneComponent */
  6032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6033. "use strict";
  6034. __webpack_require__.r(__webpack_exports__);
  6035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6036. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6037. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6038. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6039. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6040. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6041. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6042. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6043. // Adds the parser to the scene parsers.
  6044. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6045. // TODO: add sound
  6046. var loadedSounds = [];
  6047. var loadedSound;
  6048. container.sounds = container.sounds || [];
  6049. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6050. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6051. var parsedSound = parsedData.sounds[index];
  6052. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6053. if (!parsedSound.url) {
  6054. parsedSound.url = parsedSound.name;
  6055. }
  6056. if (!loadedSounds[parsedSound.url]) {
  6057. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6058. loadedSounds[parsedSound.url] = loadedSound;
  6059. container.sounds.push(loadedSound);
  6060. }
  6061. else {
  6062. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6063. }
  6064. }
  6065. else {
  6066. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6067. }
  6068. }
  6069. }
  6070. loadedSounds = [];
  6071. });
  6072. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6073. get: function () {
  6074. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6075. if (!compo) {
  6076. compo = new AudioSceneComponent(this);
  6077. this._addComponent(compo);
  6078. }
  6079. if (!this._mainSoundTrack) {
  6080. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6081. }
  6082. return this._mainSoundTrack;
  6083. },
  6084. enumerable: true,
  6085. configurable: true
  6086. });
  6087. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6088. var index;
  6089. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6090. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6091. return this.mainSoundTrack.soundCollection[index];
  6092. }
  6093. }
  6094. if (this.soundTracks) {
  6095. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6096. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6097. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6098. return this.soundTracks[sdIndex].soundCollection[index];
  6099. }
  6100. }
  6101. }
  6102. }
  6103. return null;
  6104. };
  6105. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6106. get: function () {
  6107. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6108. if (!compo) {
  6109. compo = new AudioSceneComponent(this);
  6110. this._addComponent(compo);
  6111. }
  6112. return compo.audioEnabled;
  6113. },
  6114. set: function (value) {
  6115. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6116. if (!compo) {
  6117. compo = new AudioSceneComponent(this);
  6118. this._addComponent(compo);
  6119. }
  6120. if (value) {
  6121. compo.enableAudio();
  6122. }
  6123. else {
  6124. compo.disableAudio();
  6125. }
  6126. },
  6127. enumerable: true,
  6128. configurable: true
  6129. });
  6130. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6131. get: function () {
  6132. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6133. if (!compo) {
  6134. compo = new AudioSceneComponent(this);
  6135. this._addComponent(compo);
  6136. }
  6137. return compo.headphone;
  6138. },
  6139. set: function (value) {
  6140. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6141. if (!compo) {
  6142. compo = new AudioSceneComponent(this);
  6143. this._addComponent(compo);
  6144. }
  6145. if (value) {
  6146. compo.switchAudioModeForHeadphones();
  6147. }
  6148. else {
  6149. compo.switchAudioModeForNormalSpeakers();
  6150. }
  6151. },
  6152. enumerable: true,
  6153. configurable: true
  6154. });
  6155. /**
  6156. * Defines the sound scene component responsible to manage any sounds
  6157. * in a given scene.
  6158. */
  6159. var AudioSceneComponent = /** @class */ (function () {
  6160. /**
  6161. * Creates a new instance of the component for the given scene
  6162. * @param scene Defines the scene to register the component in
  6163. */
  6164. function AudioSceneComponent(scene) {
  6165. /**
  6166. * The component name helpfull to identify the component in the list of scene components.
  6167. */
  6168. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6169. this._audioEnabled = true;
  6170. this._headphone = false;
  6171. this.scene = scene;
  6172. scene.soundTracks = new Array();
  6173. scene.sounds = new Array();
  6174. }
  6175. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6176. /**
  6177. * Gets whether audio is enabled or not.
  6178. * Please use related enable/disable method to switch state.
  6179. */
  6180. get: function () {
  6181. return this._audioEnabled;
  6182. },
  6183. enumerable: true,
  6184. configurable: true
  6185. });
  6186. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6187. /**
  6188. * Gets whether audio is outputing to headphone or not.
  6189. * Please use the according Switch methods to change output.
  6190. */
  6191. get: function () {
  6192. return this._headphone;
  6193. },
  6194. enumerable: true,
  6195. configurable: true
  6196. });
  6197. /**
  6198. * Registers the component in a given scene
  6199. */
  6200. AudioSceneComponent.prototype.register = function () {
  6201. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6202. };
  6203. /**
  6204. * Rebuilds the elements related to this component in case of
  6205. * context lost for instance.
  6206. */
  6207. AudioSceneComponent.prototype.rebuild = function () {
  6208. // Nothing to do here. (Not rendering related)
  6209. };
  6210. /**
  6211. * Serializes the component data to the specified json object
  6212. * @param serializationObject The object to serialize to
  6213. */
  6214. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6215. serializationObject.sounds = [];
  6216. if (this.scene.soundTracks) {
  6217. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6218. var soundtrack = this.scene.soundTracks[index];
  6219. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6220. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6221. }
  6222. }
  6223. }
  6224. };
  6225. /**
  6226. * Adds all the element from the container to the scene
  6227. * @param container the container holding the elements
  6228. */
  6229. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6230. var _this = this;
  6231. if (!container.sounds) {
  6232. return;
  6233. }
  6234. container.sounds.forEach(function (sound) {
  6235. sound.play();
  6236. sound.autoplay = true;
  6237. _this.scene.mainSoundTrack.AddSound(sound);
  6238. });
  6239. };
  6240. /**
  6241. * Removes all the elements in the container from the scene
  6242. * @param container contains the elements to remove
  6243. */
  6244. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6245. var _this = this;
  6246. if (!container.sounds) {
  6247. return;
  6248. }
  6249. container.sounds.forEach(function (sound) {
  6250. sound.stop();
  6251. sound.autoplay = false;
  6252. _this.scene.mainSoundTrack.RemoveSound(sound);
  6253. });
  6254. };
  6255. /**
  6256. * Disposes the component and the associated ressources.
  6257. */
  6258. AudioSceneComponent.prototype.dispose = function () {
  6259. var scene = this.scene;
  6260. if (scene._mainSoundTrack) {
  6261. scene.mainSoundTrack.dispose();
  6262. }
  6263. if (scene.soundTracks) {
  6264. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6265. scene.soundTracks[scIndex].dispose();
  6266. }
  6267. }
  6268. };
  6269. /**
  6270. * Disables audio in the associated scene.
  6271. */
  6272. AudioSceneComponent.prototype.disableAudio = function () {
  6273. var scene = this.scene;
  6274. this._audioEnabled = false;
  6275. var i;
  6276. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6277. scene.mainSoundTrack.soundCollection[i].pause();
  6278. }
  6279. if (scene.soundTracks) {
  6280. for (i = 0; i < scene.soundTracks.length; i++) {
  6281. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6282. scene.soundTracks[i].soundCollection[j].pause();
  6283. }
  6284. }
  6285. }
  6286. };
  6287. /**
  6288. * Enables audio in the associated scene.
  6289. */
  6290. AudioSceneComponent.prototype.enableAudio = function () {
  6291. var scene = this.scene;
  6292. this._audioEnabled = true;
  6293. var i;
  6294. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6295. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6296. scene.mainSoundTrack.soundCollection[i].play();
  6297. }
  6298. }
  6299. if (scene.soundTracks) {
  6300. for (i = 0; i < scene.soundTracks.length; i++) {
  6301. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6302. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6303. scene.soundTracks[i].soundCollection[j].play();
  6304. }
  6305. }
  6306. }
  6307. }
  6308. };
  6309. /**
  6310. * Switch audio to headphone output.
  6311. */
  6312. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6313. var scene = this.scene;
  6314. this._headphone = true;
  6315. scene.mainSoundTrack.switchPanningModelToHRTF();
  6316. if (scene.soundTracks) {
  6317. for (var i = 0; i < scene.soundTracks.length; i++) {
  6318. scene.soundTracks[i].switchPanningModelToHRTF();
  6319. }
  6320. }
  6321. };
  6322. /**
  6323. * Switch audio to normal speakers.
  6324. */
  6325. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6326. var scene = this.scene;
  6327. this._headphone = false;
  6328. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6329. if (scene.soundTracks) {
  6330. for (var i = 0; i < scene.soundTracks.length; i++) {
  6331. scene.soundTracks[i].switchPanningModelToEqualPower();
  6332. }
  6333. }
  6334. };
  6335. AudioSceneComponent.prototype._afterRender = function () {
  6336. var scene = this.scene;
  6337. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6338. return;
  6339. }
  6340. var listeningCamera;
  6341. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6342. if (scene.activeCameras.length > 0) {
  6343. listeningCamera = scene.activeCameras[0];
  6344. }
  6345. else {
  6346. listeningCamera = scene.activeCamera;
  6347. }
  6348. if (listeningCamera && audioEngine.audioContext) {
  6349. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6350. // for VR cameras
  6351. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6352. listeningCamera = listeningCamera.rigCameras[0];
  6353. }
  6354. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6355. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6356. cameraDirection.normalize();
  6357. // To avoid some errors on GearVR
  6358. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6359. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6360. }
  6361. var i;
  6362. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6363. var sound = scene.mainSoundTrack.soundCollection[i];
  6364. if (sound.useCustomAttenuation) {
  6365. sound.updateDistanceFromListener();
  6366. }
  6367. }
  6368. if (scene.soundTracks) {
  6369. for (i = 0; i < scene.soundTracks.length; i++) {
  6370. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6371. sound = scene.soundTracks[i].soundCollection[j];
  6372. if (sound.useCustomAttenuation) {
  6373. sound.updateDistanceFromListener();
  6374. }
  6375. }
  6376. }
  6377. }
  6378. }
  6379. };
  6380. return AudioSceneComponent;
  6381. }());
  6382. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6383. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6384. if (!compo) {
  6385. compo = new AudioSceneComponent(scene);
  6386. scene._addComponent(compo);
  6387. }
  6388. };
  6389. /***/ }),
  6390. /***/ "./Audio/index.ts":
  6391. /*!************************!*\
  6392. !*** ./Audio/index.ts ***!
  6393. \************************/
  6394. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6396. "use strict";
  6397. __webpack_require__.r(__webpack_exports__);
  6398. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6400. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6402. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6404. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6406. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6408. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6410. /***/ }),
  6411. /***/ "./Audio/sound.ts":
  6412. /*!************************!*\
  6413. !*** ./Audio/sound.ts ***!
  6414. \************************/
  6415. /*! exports provided: Sound */
  6416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6417. "use strict";
  6418. __webpack_require__.r(__webpack_exports__);
  6419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6420. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6421. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6422. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6423. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6424. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6425. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6426. /**
  6427. * Defines a sound that can be played in the application.
  6428. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6430. */
  6431. var Sound = /** @class */ (function () {
  6432. /**
  6433. * Create a sound and attach it to a scene
  6434. * @param name Name of your sound
  6435. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6436. * @param scene defines the scene the sound belongs to
  6437. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6438. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6439. */
  6440. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6441. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6442. var _this = this;
  6443. /**
  6444. * Does the sound autoplay once loaded.
  6445. */
  6446. this.autoplay = false;
  6447. /**
  6448. * Does the sound loop after it finishes playing once.
  6449. */
  6450. this.loop = false;
  6451. /**
  6452. * Does the sound use a custom attenuation curve to simulate the falloff
  6453. * happening when the source gets further away from the camera.
  6454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6455. */
  6456. this.useCustomAttenuation = false;
  6457. /**
  6458. * Is this sound currently played.
  6459. */
  6460. this.isPlaying = false;
  6461. /**
  6462. * Is this sound currently paused.
  6463. */
  6464. this.isPaused = false;
  6465. /**
  6466. * Does this sound enables spatial sound.
  6467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6468. */
  6469. this.spatialSound = false;
  6470. /**
  6471. * Define the reference distance the sound should be heard perfectly.
  6472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6473. */
  6474. this.refDistance = 1;
  6475. /**
  6476. * Define the roll off factor of spatial sounds.
  6477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6478. */
  6479. this.rolloffFactor = 1;
  6480. /**
  6481. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6483. */
  6484. this.maxDistance = 100;
  6485. /**
  6486. * Define the distance attenuation model the sound will follow.
  6487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6488. */
  6489. this.distanceModel = "linear";
  6490. /**
  6491. * Observable event when the current playing sound finishes.
  6492. */
  6493. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6494. this._panningModel = "equalpower";
  6495. this._playbackRate = 1;
  6496. this._streaming = false;
  6497. this._startTime = 0;
  6498. this._startOffset = 0;
  6499. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6500. /** @hidden */
  6501. this._positionInEmitterSpace = false;
  6502. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6503. this._volume = 1;
  6504. this._isReadyToPlay = false;
  6505. this._isDirectional = false;
  6506. // Used if you'd like to create a directional sound.
  6507. // If not set, the sound will be omnidirectional
  6508. this._coneInnerAngle = 360;
  6509. this._coneOuterAngle = 360;
  6510. this._coneOuterGain = 0;
  6511. this._isOutputConnected = false;
  6512. this._urlType = "Unknown";
  6513. this.name = name;
  6514. this._scene = scene;
  6515. Sound._SceneComponentInitialization(scene);
  6516. this._readyToPlayCallback = readyToPlayCallback;
  6517. // Default custom attenuation function is a linear attenuation
  6518. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6519. if (currentDistance < maxDistance) {
  6520. return currentVolume * (1 - currentDistance / maxDistance);
  6521. }
  6522. else {
  6523. return 0;
  6524. }
  6525. };
  6526. if (options) {
  6527. this.autoplay = options.autoplay || false;
  6528. this.loop = options.loop || false;
  6529. // if volume === 0, we need another way to check this option
  6530. if (options.volume !== undefined) {
  6531. this._volume = options.volume;
  6532. }
  6533. this.spatialSound = options.spatialSound || false;
  6534. this.maxDistance = options.maxDistance || 100;
  6535. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6536. this.rolloffFactor = options.rolloffFactor || 1;
  6537. this.refDistance = options.refDistance || 1;
  6538. this.distanceModel = options.distanceModel || "linear";
  6539. this._playbackRate = options.playbackRate || 1;
  6540. this._streaming = options.streaming || false;
  6541. }
  6542. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6543. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6544. this._soundGain.gain.value = this._volume;
  6545. this._inputAudioNode = this._soundGain;
  6546. this._outputAudioNode = this._soundGain;
  6547. if (this.spatialSound) {
  6548. this._createSpatialParameters();
  6549. }
  6550. this._scene.mainSoundTrack.AddSound(this);
  6551. var validParameter = true;
  6552. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6553. if (urlOrArrayBuffer) {
  6554. try {
  6555. if (typeof (urlOrArrayBuffer) === "string") {
  6556. this._urlType = "String";
  6557. }
  6558. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6559. this._urlType = "ArrayBuffer";
  6560. }
  6561. else if (urlOrArrayBuffer instanceof MediaStream) {
  6562. this._urlType = "MediaStream";
  6563. }
  6564. else if (Array.isArray(urlOrArrayBuffer)) {
  6565. this._urlType = "Array";
  6566. }
  6567. var urls = [];
  6568. var codecSupportedFound = false;
  6569. switch (this._urlType) {
  6570. case "MediaStream":
  6571. this._streaming = true;
  6572. this._isReadyToPlay = true;
  6573. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6574. if (this.autoplay) {
  6575. this.play();
  6576. }
  6577. if (this._readyToPlayCallback) {
  6578. this._readyToPlayCallback();
  6579. }
  6580. break;
  6581. case "ArrayBuffer":
  6582. if (urlOrArrayBuffer.byteLength > 0) {
  6583. codecSupportedFound = true;
  6584. this._soundLoaded(urlOrArrayBuffer);
  6585. }
  6586. break;
  6587. case "String":
  6588. urls.push(urlOrArrayBuffer);
  6589. case "Array":
  6590. if (urls.length === 0) {
  6591. urls = urlOrArrayBuffer;
  6592. }
  6593. // If we found a supported format, we load it immediately and stop the loop
  6594. for (var i = 0; i < urls.length; i++) {
  6595. var url = urls[i];
  6596. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6597. codecSupportedFound = true;
  6598. }
  6599. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6600. codecSupportedFound = true;
  6601. }
  6602. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6603. codecSupportedFound = true;
  6604. }
  6605. if (url.indexOf("blob:") !== -1) {
  6606. codecSupportedFound = true;
  6607. }
  6608. if (codecSupportedFound) {
  6609. // Loading sound using XHR2
  6610. if (!this._streaming) {
  6611. this._scene._loadFile(url, function (data) {
  6612. _this._soundLoaded(data);
  6613. }, undefined, true, true, function (exception) {
  6614. if (exception) {
  6615. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6616. }
  6617. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6618. _this._scene.mainSoundTrack.RemoveSound(_this);
  6619. });
  6620. }
  6621. // Streaming sound using HTML5 Audio tag
  6622. else {
  6623. this._htmlAudioElement = new Audio(url);
  6624. this._htmlAudioElement.controls = false;
  6625. this._htmlAudioElement.loop = this.loop;
  6626. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6627. this._htmlAudioElement.preload = "auto";
  6628. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6629. _this._isReadyToPlay = true;
  6630. if (_this.autoplay) {
  6631. _this.play();
  6632. }
  6633. if (_this._readyToPlayCallback) {
  6634. _this._readyToPlayCallback();
  6635. }
  6636. });
  6637. document.body.appendChild(this._htmlAudioElement);
  6638. this._htmlAudioElement.load();
  6639. }
  6640. break;
  6641. }
  6642. }
  6643. break;
  6644. default:
  6645. validParameter = false;
  6646. break;
  6647. }
  6648. if (!validParameter) {
  6649. _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.");
  6650. }
  6651. else {
  6652. if (!codecSupportedFound) {
  6653. this._isReadyToPlay = true;
  6654. // Simulating a ready to play event to avoid breaking code path
  6655. if (this._readyToPlayCallback) {
  6656. window.setTimeout(function () {
  6657. if (_this._readyToPlayCallback) {
  6658. _this._readyToPlayCallback();
  6659. }
  6660. }, 1000);
  6661. }
  6662. }
  6663. }
  6664. }
  6665. catch (ex) {
  6666. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6667. this._scene.mainSoundTrack.RemoveSound(this);
  6668. }
  6669. }
  6670. }
  6671. else {
  6672. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6673. this._scene.mainSoundTrack.AddSound(this);
  6674. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6675. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6676. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6677. }
  6678. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6679. if (this._readyToPlayCallback) {
  6680. window.setTimeout(function () {
  6681. if (_this._readyToPlayCallback) {
  6682. _this._readyToPlayCallback();
  6683. }
  6684. }, 1000);
  6685. }
  6686. }
  6687. }
  6688. /**
  6689. * Release the sound and its associated resources
  6690. */
  6691. Sound.prototype.dispose = function () {
  6692. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6693. if (this.isPlaying) {
  6694. this.stop();
  6695. }
  6696. this._isReadyToPlay = false;
  6697. if (this.soundTrackId === -1) {
  6698. this._scene.mainSoundTrack.RemoveSound(this);
  6699. }
  6700. else if (this._scene.soundTracks) {
  6701. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6702. }
  6703. if (this._soundGain) {
  6704. this._soundGain.disconnect();
  6705. this._soundGain = null;
  6706. }
  6707. if (this._soundPanner) {
  6708. this._soundPanner.disconnect();
  6709. this._soundPanner = null;
  6710. }
  6711. if (this._soundSource) {
  6712. this._soundSource.disconnect();
  6713. this._soundSource = null;
  6714. }
  6715. this._audioBuffer = null;
  6716. if (this._htmlAudioElement) {
  6717. this._htmlAudioElement.pause();
  6718. this._htmlAudioElement.src = "";
  6719. document.body.removeChild(this._htmlAudioElement);
  6720. }
  6721. if (this._streamingSource) {
  6722. this._streamingSource.disconnect();
  6723. }
  6724. if (this._connectedTransformNode && this._registerFunc) {
  6725. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6726. this._connectedTransformNode = null;
  6727. }
  6728. }
  6729. };
  6730. /**
  6731. * Gets if the sounds is ready to be played or not.
  6732. * @returns true if ready, otherwise false
  6733. */
  6734. Sound.prototype.isReady = function () {
  6735. return this._isReadyToPlay;
  6736. };
  6737. Sound.prototype._soundLoaded = function (audioData) {
  6738. var _this = this;
  6739. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6740. return;
  6741. }
  6742. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6743. _this._audioBuffer = buffer;
  6744. _this._isReadyToPlay = true;
  6745. if (_this.autoplay) {
  6746. _this.play();
  6747. }
  6748. if (_this._readyToPlayCallback) {
  6749. _this._readyToPlayCallback();
  6750. }
  6751. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6752. };
  6753. /**
  6754. * Sets the data of the sound from an audiobuffer
  6755. * @param audioBuffer The audioBuffer containing the data
  6756. */
  6757. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6758. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6759. this._audioBuffer = audioBuffer;
  6760. this._isReadyToPlay = true;
  6761. }
  6762. };
  6763. /**
  6764. * Updates the current sounds options such as maxdistance, loop...
  6765. * @param options A JSON object containing values named as the object properties
  6766. */
  6767. Sound.prototype.updateOptions = function (options) {
  6768. if (options) {
  6769. this.loop = options.loop || this.loop;
  6770. this.maxDistance = options.maxDistance || this.maxDistance;
  6771. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6772. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6773. this.refDistance = options.refDistance || this.refDistance;
  6774. this.distanceModel = options.distanceModel || this.distanceModel;
  6775. this._playbackRate = options.playbackRate || this._playbackRate;
  6776. this._updateSpatialParameters();
  6777. if (this.isPlaying) {
  6778. if (this._streaming && this._htmlAudioElement) {
  6779. this._htmlAudioElement.playbackRate = this._playbackRate;
  6780. }
  6781. else {
  6782. if (this._soundSource) {
  6783. this._soundSource.playbackRate.value = this._playbackRate;
  6784. }
  6785. }
  6786. }
  6787. }
  6788. };
  6789. Sound.prototype._createSpatialParameters = function () {
  6790. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6791. if (this._scene.headphone) {
  6792. this._panningModel = "HRTF";
  6793. }
  6794. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6795. this._updateSpatialParameters();
  6796. this._soundPanner.connect(this._outputAudioNode);
  6797. this._inputAudioNode = this._soundPanner;
  6798. }
  6799. };
  6800. Sound.prototype._updateSpatialParameters = function () {
  6801. if (this.spatialSound && this._soundPanner) {
  6802. if (this.useCustomAttenuation) {
  6803. // Tricks to disable in a way embedded Web Audio attenuation
  6804. this._soundPanner.distanceModel = "linear";
  6805. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6806. this._soundPanner.refDistance = 1;
  6807. this._soundPanner.rolloffFactor = 1;
  6808. this._soundPanner.panningModel = this._panningModel;
  6809. }
  6810. else {
  6811. this._soundPanner.distanceModel = this.distanceModel;
  6812. this._soundPanner.maxDistance = this.maxDistance;
  6813. this._soundPanner.refDistance = this.refDistance;
  6814. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6815. this._soundPanner.panningModel = this._panningModel;
  6816. }
  6817. }
  6818. };
  6819. /**
  6820. * Switch the panning model to HRTF:
  6821. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6823. */
  6824. Sound.prototype.switchPanningModelToHRTF = function () {
  6825. this._panningModel = "HRTF";
  6826. this._switchPanningModel();
  6827. };
  6828. /**
  6829. * Switch the panning model to Equal Power:
  6830. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6832. */
  6833. Sound.prototype.switchPanningModelToEqualPower = function () {
  6834. this._panningModel = "equalpower";
  6835. this._switchPanningModel();
  6836. };
  6837. Sound.prototype._switchPanningModel = function () {
  6838. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6839. this._soundPanner.panningModel = this._panningModel;
  6840. }
  6841. };
  6842. /**
  6843. * Connect this sound to a sound track audio node like gain...
  6844. * @param soundTrackAudioNode the sound track audio node to connect to
  6845. */
  6846. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6847. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6848. if (this._isOutputConnected) {
  6849. this._outputAudioNode.disconnect();
  6850. }
  6851. this._outputAudioNode.connect(soundTrackAudioNode);
  6852. this._isOutputConnected = true;
  6853. }
  6854. };
  6855. /**
  6856. * Transform this sound into a directional source
  6857. * @param coneInnerAngle Size of the inner cone in degree
  6858. * @param coneOuterAngle Size of the outer cone in degree
  6859. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6860. */
  6861. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6862. if (coneOuterAngle < coneInnerAngle) {
  6863. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6864. return;
  6865. }
  6866. this._coneInnerAngle = coneInnerAngle;
  6867. this._coneOuterAngle = coneOuterAngle;
  6868. this._coneOuterGain = coneOuterGain;
  6869. this._isDirectional = true;
  6870. if (this.isPlaying && this.loop) {
  6871. this.stop();
  6872. this.play();
  6873. }
  6874. };
  6875. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6876. /**
  6877. * Gets or sets the inner angle for the directional cone.
  6878. */
  6879. get: function () {
  6880. return this._coneInnerAngle;
  6881. },
  6882. /**
  6883. * Gets or sets the inner angle for the directional cone.
  6884. */
  6885. set: function (value) {
  6886. if (value != this._coneInnerAngle) {
  6887. if (this._coneOuterAngle < value) {
  6888. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6889. return;
  6890. }
  6891. this._coneInnerAngle = value;
  6892. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6893. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6894. }
  6895. }
  6896. },
  6897. enumerable: true,
  6898. configurable: true
  6899. });
  6900. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6901. /**
  6902. * Gets or sets the outer angle for the directional cone.
  6903. */
  6904. get: function () {
  6905. return this._coneOuterAngle;
  6906. },
  6907. /**
  6908. * Gets or sets the outer angle for the directional cone.
  6909. */
  6910. set: function (value) {
  6911. if (value != this._coneOuterAngle) {
  6912. if (value < this._coneInnerAngle) {
  6913. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6914. return;
  6915. }
  6916. this._coneOuterAngle = value;
  6917. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6918. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6919. }
  6920. }
  6921. },
  6922. enumerable: true,
  6923. configurable: true
  6924. });
  6925. /**
  6926. * Sets the position of the emitter if spatial sound is enabled
  6927. * @param newPosition Defines the new posisiton
  6928. */
  6929. Sound.prototype.setPosition = function (newPosition) {
  6930. this._position = newPosition;
  6931. 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)) {
  6932. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6933. }
  6934. };
  6935. /**
  6936. * Sets the local direction of the emitter if spatial sound is enabled
  6937. * @param newLocalDirection Defines the new local direction
  6938. */
  6939. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6940. this._localDirection = newLocalDirection;
  6941. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6942. this._updateDirection();
  6943. }
  6944. };
  6945. Sound.prototype._updateDirection = function () {
  6946. if (!this._connectedTransformNode || !this._soundPanner) {
  6947. return;
  6948. }
  6949. var mat = this._connectedTransformNode.getWorldMatrix();
  6950. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6951. direction.normalize();
  6952. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6953. };
  6954. /** @hidden */
  6955. Sound.prototype.updateDistanceFromListener = function () {
  6956. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6957. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6958. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6959. }
  6960. };
  6961. /**
  6962. * Sets a new custom attenuation function for the sound.
  6963. * @param callback Defines the function used for the attenuation
  6964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6965. */
  6966. Sound.prototype.setAttenuationFunction = function (callback) {
  6967. this._customAttenuationFunction = callback;
  6968. };
  6969. /**
  6970. * Play the sound
  6971. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6972. * @param offset (optional) Start the sound setting it at a specific time
  6973. */
  6974. Sound.prototype.play = function (time, offset) {
  6975. var _this = this;
  6976. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6977. try {
  6978. if (this._startOffset < 0) {
  6979. time = -this._startOffset;
  6980. this._startOffset = 0;
  6981. }
  6982. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6983. if (!this._soundSource || !this._streamingSource) {
  6984. if (this.spatialSound && this._soundPanner) {
  6985. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6986. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6987. }
  6988. if (this._isDirectional) {
  6989. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6990. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6991. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6992. if (this._connectedTransformNode) {
  6993. this._updateDirection();
  6994. }
  6995. else {
  6996. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6997. }
  6998. }
  6999. }
  7000. }
  7001. if (this._streaming) {
  7002. if (!this._streamingSource) {
  7003. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  7004. this._htmlAudioElement.onended = function () { _this._onended(); };
  7005. this._htmlAudioElement.playbackRate = this._playbackRate;
  7006. }
  7007. this._streamingSource.disconnect();
  7008. this._streamingSource.connect(this._inputAudioNode);
  7009. if (this._htmlAudioElement) {
  7010. // required to manage properly the new suspended default state of Chrome
  7011. // When the option 'streaming: true' is used, we need first to wait for
  7012. // the audio engine to be unlocked by a user gesture before trying to play
  7013. // an HTML Audio elememt
  7014. var tryToPlay = function () {
  7015. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7016. var playPromise = _this._htmlAudioElement.play();
  7017. // In browsers that don’t yet support this functionality,
  7018. // playPromise won’t be defined.
  7019. if (playPromise !== undefined) {
  7020. playPromise.catch(function (error) {
  7021. // Automatic playback failed.
  7022. // Waiting for the audio engine to be unlocked by user click on unmute
  7023. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7024. if (_this.loop || _this.autoplay) {
  7025. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7026. }
  7027. });
  7028. }
  7029. }
  7030. else {
  7031. if (_this.loop || _this.autoplay) {
  7032. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7033. }
  7034. }
  7035. };
  7036. tryToPlay();
  7037. }
  7038. }
  7039. else {
  7040. var tryToPlay = function () {
  7041. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7042. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7043. _this._soundSource.buffer = _this._audioBuffer;
  7044. _this._soundSource.connect(_this._inputAudioNode);
  7045. _this._soundSource.loop = _this.loop;
  7046. _this._soundSource.playbackRate.value = _this._playbackRate;
  7047. _this._soundSource.onended = function () { _this._onended(); };
  7048. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7049. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7050. }
  7051. };
  7052. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7053. // Wait a bit for FF as context seems late to be ready.
  7054. setTimeout(function () {
  7055. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7056. // Automatic playback failed.
  7057. // Waiting for the audio engine to be unlocked by user click on unmute
  7058. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7059. if (_this.loop || _this.autoplay) {
  7060. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7061. }
  7062. }
  7063. else {
  7064. tryToPlay();
  7065. }
  7066. }, 500);
  7067. }
  7068. else {
  7069. tryToPlay();
  7070. }
  7071. }
  7072. this._startTime = startTime;
  7073. this.isPlaying = true;
  7074. this.isPaused = false;
  7075. }
  7076. catch (ex) {
  7077. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7078. }
  7079. }
  7080. };
  7081. Sound.prototype._onended = function () {
  7082. this.isPlaying = false;
  7083. if (this.onended) {
  7084. this.onended();
  7085. }
  7086. this.onEndedObservable.notifyObservers(this);
  7087. };
  7088. /**
  7089. * Stop the sound
  7090. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7091. */
  7092. Sound.prototype.stop = function (time) {
  7093. if (this.isPlaying) {
  7094. if (this._streaming) {
  7095. if (this._htmlAudioElement) {
  7096. this._htmlAudioElement.pause();
  7097. // Test needed for Firefox or it will generate an Invalid State Error
  7098. if (this._htmlAudioElement.currentTime > 0) {
  7099. this._htmlAudioElement.currentTime = 0;
  7100. }
  7101. }
  7102. else {
  7103. this._streamingSource.disconnect();
  7104. }
  7105. }
  7106. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7107. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7108. this._soundSource.stop(stopTime);
  7109. this._soundSource.onended = function () { };
  7110. if (!this.isPaused) {
  7111. this._startOffset = 0;
  7112. }
  7113. }
  7114. this.isPlaying = false;
  7115. }
  7116. };
  7117. /**
  7118. * Put the sound in pause
  7119. */
  7120. Sound.prototype.pause = function () {
  7121. if (this.isPlaying) {
  7122. this.isPaused = true;
  7123. if (this._streaming) {
  7124. if (this._htmlAudioElement) {
  7125. this._htmlAudioElement.pause();
  7126. }
  7127. else {
  7128. this._streamingSource.disconnect();
  7129. }
  7130. }
  7131. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7132. this.stop(0);
  7133. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7134. }
  7135. }
  7136. };
  7137. /**
  7138. * Sets a dedicated volume for this sounds
  7139. * @param newVolume Define the new volume of the sound
  7140. * @param time Define in how long the sound should be at this value
  7141. */
  7142. Sound.prototype.setVolume = function (newVolume, time) {
  7143. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7144. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7145. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7146. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7147. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7148. }
  7149. else {
  7150. this._soundGain.gain.value = newVolume;
  7151. }
  7152. }
  7153. this._volume = newVolume;
  7154. };
  7155. /**
  7156. * Set the sound play back rate
  7157. * @param newPlaybackRate Define the playback rate the sound should be played at
  7158. */
  7159. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7160. this._playbackRate = newPlaybackRate;
  7161. if (this.isPlaying) {
  7162. if (this._streaming && this._htmlAudioElement) {
  7163. this._htmlAudioElement.playbackRate = this._playbackRate;
  7164. }
  7165. else if (this._soundSource) {
  7166. this._soundSource.playbackRate.value = this._playbackRate;
  7167. }
  7168. }
  7169. };
  7170. /**
  7171. * Gets the volume of the sound.
  7172. * @returns the volume of the sound
  7173. */
  7174. Sound.prototype.getVolume = function () {
  7175. return this._volume;
  7176. };
  7177. /**
  7178. * Attach the sound to a dedicated mesh
  7179. * @param transformNode The transform node to connect the sound with
  7180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7181. */
  7182. Sound.prototype.attachToMesh = function (transformNode) {
  7183. var _this = this;
  7184. if (this._connectedTransformNode && this._registerFunc) {
  7185. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7186. this._registerFunc = null;
  7187. }
  7188. this._connectedTransformNode = transformNode;
  7189. if (!this.spatialSound) {
  7190. this.spatialSound = true;
  7191. this._createSpatialParameters();
  7192. if (this.isPlaying && this.loop) {
  7193. this.stop();
  7194. this.play();
  7195. }
  7196. }
  7197. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7198. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7199. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7200. };
  7201. /**
  7202. * Detach the sound from the previously attached mesh
  7203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7204. */
  7205. Sound.prototype.detachFromMesh = function () {
  7206. if (this._connectedTransformNode && this._registerFunc) {
  7207. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7208. this._registerFunc = null;
  7209. this._connectedTransformNode = null;
  7210. }
  7211. };
  7212. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7213. if (!node.getBoundingInfo) {
  7214. return;
  7215. }
  7216. var mesh = node;
  7217. if (this._positionInEmitterSpace) {
  7218. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7219. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7220. }
  7221. else {
  7222. var boundingInfo = mesh.getBoundingInfo();
  7223. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7224. }
  7225. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7226. this._updateDirection();
  7227. }
  7228. };
  7229. /**
  7230. * Clone the current sound in the scene.
  7231. * @returns the new sound clone
  7232. */
  7233. Sound.prototype.clone = function () {
  7234. var _this = this;
  7235. if (!this._streaming) {
  7236. var setBufferAndRun = function () {
  7237. if (_this._isReadyToPlay) {
  7238. clonedSound._audioBuffer = _this.getAudioBuffer();
  7239. clonedSound._isReadyToPlay = true;
  7240. if (clonedSound.autoplay) {
  7241. clonedSound.play();
  7242. }
  7243. }
  7244. else {
  7245. window.setTimeout(setBufferAndRun, 300);
  7246. }
  7247. };
  7248. var currentOptions = {
  7249. autoplay: this.autoplay, loop: this.loop,
  7250. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7251. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7252. refDistance: this.refDistance, distanceModel: this.distanceModel
  7253. };
  7254. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7255. if (this.useCustomAttenuation) {
  7256. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7257. }
  7258. clonedSound.setPosition(this._position);
  7259. clonedSound.setPlaybackRate(this._playbackRate);
  7260. setBufferAndRun();
  7261. return clonedSound;
  7262. }
  7263. // Can't clone a streaming sound
  7264. else {
  7265. return null;
  7266. }
  7267. };
  7268. /**
  7269. * Gets the current underlying audio buffer containing the data
  7270. * @returns the audio buffer
  7271. */
  7272. Sound.prototype.getAudioBuffer = function () {
  7273. return this._audioBuffer;
  7274. };
  7275. /**
  7276. * Serializes the Sound in a JSON representation
  7277. * @returns the JSON representation of the sound
  7278. */
  7279. Sound.prototype.serialize = function () {
  7280. var serializationObject = {
  7281. name: this.name,
  7282. url: this.name,
  7283. autoplay: this.autoplay,
  7284. loop: this.loop,
  7285. volume: this._volume,
  7286. spatialSound: this.spatialSound,
  7287. maxDistance: this.maxDistance,
  7288. rolloffFactor: this.rolloffFactor,
  7289. refDistance: this.refDistance,
  7290. distanceModel: this.distanceModel,
  7291. playbackRate: this._playbackRate,
  7292. panningModel: this._panningModel,
  7293. soundTrackId: this.soundTrackId
  7294. };
  7295. if (this.spatialSound) {
  7296. if (this._connectedTransformNode) {
  7297. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7298. }
  7299. serializationObject.position = this._position.asArray();
  7300. serializationObject.refDistance = this.refDistance;
  7301. serializationObject.distanceModel = this.distanceModel;
  7302. serializationObject.isDirectional = this._isDirectional;
  7303. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7304. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7305. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7306. serializationObject.coneOuterGain = this._coneOuterGain;
  7307. }
  7308. return serializationObject;
  7309. };
  7310. /**
  7311. * Parse a JSON representation of a sound to innstantiate in a given scene
  7312. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7313. * @param scene Define the scene the new parsed sound should be created in
  7314. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7315. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7316. * @returns the newly parsed sound
  7317. */
  7318. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7319. var soundName = parsedSound.name;
  7320. var soundUrl;
  7321. if (parsedSound.url) {
  7322. soundUrl = rootUrl + parsedSound.url;
  7323. }
  7324. else {
  7325. soundUrl = rootUrl + soundName;
  7326. }
  7327. var options = {
  7328. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7329. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7330. rolloffFactor: parsedSound.rolloffFactor,
  7331. refDistance: parsedSound.refDistance,
  7332. distanceModel: parsedSound.distanceModel,
  7333. playbackRate: parsedSound.playbackRate
  7334. };
  7335. var newSound;
  7336. if (!sourceSound) {
  7337. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7338. scene._addPendingData(newSound);
  7339. }
  7340. else {
  7341. var setBufferAndRun = function () {
  7342. if (sourceSound._isReadyToPlay) {
  7343. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7344. newSound._isReadyToPlay = true;
  7345. if (newSound.autoplay) {
  7346. newSound.play();
  7347. }
  7348. }
  7349. else {
  7350. window.setTimeout(setBufferAndRun, 300);
  7351. }
  7352. };
  7353. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7354. setBufferAndRun();
  7355. }
  7356. if (parsedSound.position) {
  7357. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7358. newSound.setPosition(soundPosition);
  7359. }
  7360. if (parsedSound.isDirectional) {
  7361. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7362. if (parsedSound.localDirectionToMesh) {
  7363. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7364. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7365. }
  7366. }
  7367. if (parsedSound.connectedMeshId) {
  7368. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7369. if (connectedMesh) {
  7370. newSound.attachToMesh(connectedMesh);
  7371. }
  7372. }
  7373. return newSound;
  7374. };
  7375. /** @hidden */
  7376. Sound._SceneComponentInitialization = function (_) {
  7377. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7378. };
  7379. return Sound;
  7380. }());
  7381. /***/ }),
  7382. /***/ "./Audio/soundTrack.ts":
  7383. /*!*****************************!*\
  7384. !*** ./Audio/soundTrack.ts ***!
  7385. \*****************************/
  7386. /*! exports provided: SoundTrack */
  7387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7388. "use strict";
  7389. __webpack_require__.r(__webpack_exports__);
  7390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7391. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7392. /**
  7393. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7394. * It will be also used in a future release to apply effects on a specific track.
  7395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7396. */
  7397. var SoundTrack = /** @class */ (function () {
  7398. /**
  7399. * Creates a new sound track.
  7400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7401. * @param scene Define the scene the sound track belongs to
  7402. * @param options
  7403. */
  7404. function SoundTrack(scene, options) {
  7405. if (options === void 0) { options = {}; }
  7406. /**
  7407. * The unique identifier of the sound track in the scene.
  7408. */
  7409. this.id = -1;
  7410. this._isMainTrack = false;
  7411. this._isInitialized = false;
  7412. this._scene = scene;
  7413. this.soundCollection = new Array();
  7414. this._options = options;
  7415. if (!this._isMainTrack && this._scene.soundTracks) {
  7416. this._scene.soundTracks.push(this);
  7417. this.id = this._scene.soundTracks.length - 1;
  7418. }
  7419. }
  7420. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7421. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7422. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7423. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7424. if (this._options) {
  7425. if (this._options.volume) {
  7426. this._outputAudioNode.gain.value = this._options.volume;
  7427. }
  7428. if (this._options.mainTrack) {
  7429. this._isMainTrack = this._options.mainTrack;
  7430. }
  7431. }
  7432. this._isInitialized = true;
  7433. }
  7434. };
  7435. /**
  7436. * Release the sound track and its associated resources
  7437. */
  7438. SoundTrack.prototype.dispose = function () {
  7439. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7440. if (this._connectedAnalyser) {
  7441. this._connectedAnalyser.stopDebugCanvas();
  7442. }
  7443. while (this.soundCollection.length) {
  7444. this.soundCollection[0].dispose();
  7445. }
  7446. if (this._outputAudioNode) {
  7447. this._outputAudioNode.disconnect();
  7448. }
  7449. this._outputAudioNode = null;
  7450. }
  7451. };
  7452. /**
  7453. * Adds a sound to this sound track
  7454. * @param sound define the cound to add
  7455. * @ignoreNaming
  7456. */
  7457. SoundTrack.prototype.AddSound = function (sound) {
  7458. if (!this._isInitialized) {
  7459. this._initializeSoundTrackAudioGraph();
  7460. }
  7461. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7462. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7463. }
  7464. if (sound.soundTrackId) {
  7465. if (sound.soundTrackId === -1) {
  7466. this._scene.mainSoundTrack.RemoveSound(sound);
  7467. }
  7468. else if (this._scene.soundTracks) {
  7469. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7470. }
  7471. }
  7472. this.soundCollection.push(sound);
  7473. sound.soundTrackId = this.id;
  7474. };
  7475. /**
  7476. * Removes a sound to this sound track
  7477. * @param sound define the cound to remove
  7478. * @ignoreNaming
  7479. */
  7480. SoundTrack.prototype.RemoveSound = function (sound) {
  7481. var index = this.soundCollection.indexOf(sound);
  7482. if (index !== -1) {
  7483. this.soundCollection.splice(index, 1);
  7484. }
  7485. };
  7486. /**
  7487. * Set a global volume for the full sound track.
  7488. * @param newVolume Define the new volume of the sound track
  7489. */
  7490. SoundTrack.prototype.setVolume = function (newVolume) {
  7491. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7492. this._outputAudioNode.gain.value = newVolume;
  7493. }
  7494. };
  7495. /**
  7496. * Switch the panning model to HRTF:
  7497. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7499. */
  7500. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7501. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7502. for (var i = 0; i < this.soundCollection.length; i++) {
  7503. this.soundCollection[i].switchPanningModelToHRTF();
  7504. }
  7505. }
  7506. };
  7507. /**
  7508. * Switch the panning model to Equal Power:
  7509. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7511. */
  7512. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7513. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7514. for (var i = 0; i < this.soundCollection.length; i++) {
  7515. this.soundCollection[i].switchPanningModelToEqualPower();
  7516. }
  7517. }
  7518. };
  7519. /**
  7520. * Connect the sound track to an audio analyser allowing some amazing
  7521. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7523. * @param analyser The analyser to connect to the engine
  7524. */
  7525. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7526. if (this._connectedAnalyser) {
  7527. this._connectedAnalyser.stopDebugCanvas();
  7528. }
  7529. this._connectedAnalyser = analyser;
  7530. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7531. this._outputAudioNode.disconnect();
  7532. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7533. }
  7534. };
  7535. return SoundTrack;
  7536. }());
  7537. /***/ }),
  7538. /***/ "./Audio/weightedsound.ts":
  7539. /*!********************************!*\
  7540. !*** ./Audio/weightedsound.ts ***!
  7541. \********************************/
  7542. /*! exports provided: WeightedSound */
  7543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7544. "use strict";
  7545. __webpack_require__.r(__webpack_exports__);
  7546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7547. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7548. /**
  7549. * Wraps one or more Sound objects and selects one with random weight for playback.
  7550. */
  7551. var WeightedSound = /** @class */ (function () {
  7552. /**
  7553. * Creates a new WeightedSound from the list of sounds given.
  7554. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7555. * @param sounds Array of Sounds that will be selected from.
  7556. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7557. */
  7558. function WeightedSound(loop, sounds, weights) {
  7559. var _this = this;
  7560. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7561. this.loop = false;
  7562. this._coneInnerAngle = 360;
  7563. this._coneOuterAngle = 360;
  7564. this._volume = 1;
  7565. /** A Sound is currently playing. */
  7566. this.isPlaying = false;
  7567. /** A Sound is currently paused. */
  7568. this.isPaused = false;
  7569. this._sounds = [];
  7570. this._weights = [];
  7571. if (sounds.length !== weights.length) {
  7572. throw new Error('Sounds length does not equal weights length');
  7573. }
  7574. this.loop = loop;
  7575. this._weights = weights;
  7576. // Normalize the weights
  7577. var weightSum = 0;
  7578. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7579. var weight = weights_1[_i];
  7580. weightSum += weight;
  7581. }
  7582. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7583. for (var i = 0; i < this._weights.length; i++) {
  7584. this._weights[i] *= invWeightSum;
  7585. }
  7586. this._sounds = sounds;
  7587. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7588. var sound = _b[_a];
  7589. sound.onEndedObservable.add(function () { _this._onended(); });
  7590. }
  7591. }
  7592. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7593. /**
  7594. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7595. */
  7596. get: function () {
  7597. return this._coneInnerAngle;
  7598. },
  7599. /**
  7600. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7601. */
  7602. set: function (value) {
  7603. if (value !== this._coneInnerAngle) {
  7604. if (this._coneOuterAngle < value) {
  7605. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7606. return;
  7607. }
  7608. this._coneInnerAngle = value;
  7609. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7610. var sound = _a[_i];
  7611. sound.directionalConeInnerAngle = value;
  7612. }
  7613. }
  7614. },
  7615. enumerable: true,
  7616. configurable: true
  7617. });
  7618. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7619. /**
  7620. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7621. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7622. */
  7623. get: function () {
  7624. return this._coneOuterAngle;
  7625. },
  7626. /**
  7627. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7628. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7629. */
  7630. set: function (value) {
  7631. if (value !== this._coneOuterAngle) {
  7632. if (value < this._coneInnerAngle) {
  7633. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7634. return;
  7635. }
  7636. this._coneOuterAngle = value;
  7637. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7638. var sound = _a[_i];
  7639. sound.directionalConeOuterAngle = value;
  7640. }
  7641. }
  7642. },
  7643. enumerable: true,
  7644. configurable: true
  7645. });
  7646. Object.defineProperty(WeightedSound.prototype, "volume", {
  7647. /**
  7648. * Playback volume.
  7649. */
  7650. get: function () {
  7651. return this._volume;
  7652. },
  7653. /**
  7654. * Playback volume.
  7655. */
  7656. set: function (value) {
  7657. if (value !== this._volume) {
  7658. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7659. var sound = _a[_i];
  7660. sound.setVolume(value);
  7661. }
  7662. }
  7663. },
  7664. enumerable: true,
  7665. configurable: true
  7666. });
  7667. WeightedSound.prototype._onended = function () {
  7668. if (this._currentIndex !== undefined) {
  7669. this._sounds[this._currentIndex].autoplay = false;
  7670. }
  7671. if (this.loop && this.isPlaying) {
  7672. this.play();
  7673. }
  7674. else {
  7675. this.isPlaying = false;
  7676. }
  7677. };
  7678. /**
  7679. * Suspend playback
  7680. */
  7681. WeightedSound.prototype.pause = function () {
  7682. this.isPaused = true;
  7683. if (this._currentIndex !== undefined) {
  7684. this._sounds[this._currentIndex].pause();
  7685. }
  7686. };
  7687. /**
  7688. * Stop playback
  7689. */
  7690. WeightedSound.prototype.stop = function () {
  7691. this.isPlaying = false;
  7692. if (this._currentIndex !== undefined) {
  7693. this._sounds[this._currentIndex].stop();
  7694. }
  7695. };
  7696. /**
  7697. * Start playback.
  7698. * @param startOffset Position the clip head at a specific time in seconds.
  7699. */
  7700. WeightedSound.prototype.play = function (startOffset) {
  7701. if (!this.isPaused) {
  7702. this.stop();
  7703. var randomValue = Math.random();
  7704. var total = 0;
  7705. for (var i = 0; i < this._weights.length; i++) {
  7706. total += this._weights[i];
  7707. if (randomValue <= total) {
  7708. this._currentIndex = i;
  7709. break;
  7710. }
  7711. }
  7712. }
  7713. var sound = this._sounds[this._currentIndex];
  7714. if (sound.isReady()) {
  7715. sound.play(0, this.isPaused ? undefined : startOffset);
  7716. }
  7717. else {
  7718. sound.autoplay = true;
  7719. }
  7720. this.isPlaying = true;
  7721. this.isPaused = false;
  7722. };
  7723. return WeightedSound;
  7724. }());
  7725. /***/ }),
  7726. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7727. /*!***************************************************!*\
  7728. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7729. \***************************************************/
  7730. /*! exports provided: AutoRotationBehavior */
  7731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7732. "use strict";
  7733. __webpack_require__.r(__webpack_exports__);
  7734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7735. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7736. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7737. /**
  7738. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7739. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7740. */
  7741. var AutoRotationBehavior = /** @class */ (function () {
  7742. function AutoRotationBehavior() {
  7743. this._zoomStopsAnimation = false;
  7744. this._idleRotationSpeed = 0.05;
  7745. this._idleRotationWaitTime = 2000;
  7746. this._idleRotationSpinupTime = 2000;
  7747. this._isPointerDown = false;
  7748. this._lastFrameTime = null;
  7749. this._lastInteractionTime = -Infinity;
  7750. this._cameraRotationSpeed = 0;
  7751. this._lastFrameRadius = 0;
  7752. }
  7753. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7754. /**
  7755. * Gets the name of the behavior.
  7756. */
  7757. get: function () {
  7758. return "AutoRotation";
  7759. },
  7760. enumerable: true,
  7761. configurable: true
  7762. });
  7763. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7764. /**
  7765. * Gets the flag that indicates if user zooming should stop animation.
  7766. */
  7767. get: function () {
  7768. return this._zoomStopsAnimation;
  7769. },
  7770. /**
  7771. * Sets the flag that indicates if user zooming should stop animation.
  7772. */
  7773. set: function (flag) {
  7774. this._zoomStopsAnimation = flag;
  7775. },
  7776. enumerable: true,
  7777. configurable: true
  7778. });
  7779. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7780. /**
  7781. * Gets the default speed at which the camera rotates around the model.
  7782. */
  7783. get: function () {
  7784. return this._idleRotationSpeed;
  7785. },
  7786. /**
  7787. * Sets the default speed at which the camera rotates around the model.
  7788. */
  7789. set: function (speed) {
  7790. this._idleRotationSpeed = speed;
  7791. },
  7792. enumerable: true,
  7793. configurable: true
  7794. });
  7795. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7796. /**
  7797. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7798. */
  7799. get: function () {
  7800. return this._idleRotationWaitTime;
  7801. },
  7802. /**
  7803. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7804. */
  7805. set: function (time) {
  7806. this._idleRotationWaitTime = time;
  7807. },
  7808. enumerable: true,
  7809. configurable: true
  7810. });
  7811. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7812. /**
  7813. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7814. */
  7815. get: function () {
  7816. return this._idleRotationSpinupTime;
  7817. },
  7818. /**
  7819. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7820. */
  7821. set: function (time) {
  7822. this._idleRotationSpinupTime = time;
  7823. },
  7824. enumerable: true,
  7825. configurable: true
  7826. });
  7827. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7828. /**
  7829. * Gets a value indicating if the camera is currently rotating because of this behavior
  7830. */
  7831. get: function () {
  7832. return Math.abs(this._cameraRotationSpeed) > 0;
  7833. },
  7834. enumerable: true,
  7835. configurable: true
  7836. });
  7837. /**
  7838. * Initializes the behavior.
  7839. */
  7840. AutoRotationBehavior.prototype.init = function () {
  7841. // Do notihng
  7842. };
  7843. /**
  7844. * Attaches the behavior to its arc rotate camera.
  7845. * @param camera Defines the camera to attach the behavior to
  7846. */
  7847. AutoRotationBehavior.prototype.attach = function (camera) {
  7848. var _this = this;
  7849. this._attachedCamera = camera;
  7850. var scene = this._attachedCamera.getScene();
  7851. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7852. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7853. _this._isPointerDown = true;
  7854. return;
  7855. }
  7856. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7857. _this._isPointerDown = false;
  7858. }
  7859. });
  7860. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7861. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7862. var dt = 0;
  7863. if (_this._lastFrameTime != null) {
  7864. dt = now - _this._lastFrameTime;
  7865. }
  7866. _this._lastFrameTime = now;
  7867. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7868. _this._applyUserInteraction();
  7869. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7870. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7871. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7872. // Step camera rotation by rotation speed
  7873. if (_this._attachedCamera) {
  7874. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7875. }
  7876. });
  7877. };
  7878. /**
  7879. * Detaches the behavior from its current arc rotate camera.
  7880. */
  7881. AutoRotationBehavior.prototype.detach = function () {
  7882. if (!this._attachedCamera) {
  7883. return;
  7884. }
  7885. var scene = this._attachedCamera.getScene();
  7886. if (this._onPrePointerObservableObserver) {
  7887. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7888. }
  7889. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7890. this._attachedCamera = null;
  7891. };
  7892. /**
  7893. * Returns true if user is scrolling.
  7894. * @return true if user is scrolling.
  7895. */
  7896. AutoRotationBehavior.prototype._userIsZooming = function () {
  7897. if (!this._attachedCamera) {
  7898. return false;
  7899. }
  7900. return this._attachedCamera.inertialRadiusOffset !== 0;
  7901. };
  7902. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7903. if (!this._attachedCamera) {
  7904. return false;
  7905. }
  7906. var zoomHasHitLimit = false;
  7907. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7908. zoomHasHitLimit = true;
  7909. }
  7910. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7911. this._lastFrameRadius = this._attachedCamera.radius;
  7912. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7913. };
  7914. /**
  7915. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7916. */
  7917. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7918. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7919. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7920. }
  7921. };
  7922. // Tools
  7923. AutoRotationBehavior.prototype._userIsMoving = function () {
  7924. if (!this._attachedCamera) {
  7925. return false;
  7926. }
  7927. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7928. this._attachedCamera.inertialBetaOffset !== 0 ||
  7929. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7930. this._attachedCamera.inertialPanningX !== 0 ||
  7931. this._attachedCamera.inertialPanningY !== 0 ||
  7932. this._isPointerDown;
  7933. };
  7934. return AutoRotationBehavior;
  7935. }());
  7936. /***/ }),
  7937. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7938. /*!***********************************************!*\
  7939. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7940. \***********************************************/
  7941. /*! exports provided: BouncingBehavior */
  7942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7943. "use strict";
  7944. __webpack_require__.r(__webpack_exports__);
  7945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7946. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7947. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7948. /**
  7949. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7950. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7951. */
  7952. var BouncingBehavior = /** @class */ (function () {
  7953. function BouncingBehavior() {
  7954. /**
  7955. * The duration of the animation, in milliseconds
  7956. */
  7957. this.transitionDuration = 450;
  7958. /**
  7959. * Length of the distance animated by the transition when lower radius is reached
  7960. */
  7961. this.lowerRadiusTransitionRange = 2;
  7962. /**
  7963. * Length of the distance animated by the transition when upper radius is reached
  7964. */
  7965. this.upperRadiusTransitionRange = -2;
  7966. this._autoTransitionRange = false;
  7967. // Animations
  7968. this._radiusIsAnimating = false;
  7969. this._radiusBounceTransition = null;
  7970. this._animatables = new Array();
  7971. }
  7972. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7973. /**
  7974. * Gets the name of the behavior.
  7975. */
  7976. get: function () {
  7977. return "Bouncing";
  7978. },
  7979. enumerable: true,
  7980. configurable: true
  7981. });
  7982. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7983. /**
  7984. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7985. */
  7986. get: function () {
  7987. return this._autoTransitionRange;
  7988. },
  7989. /**
  7990. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7991. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7992. */
  7993. set: function (value) {
  7994. var _this = this;
  7995. if (this._autoTransitionRange === value) {
  7996. return;
  7997. }
  7998. this._autoTransitionRange = value;
  7999. var camera = this._attachedCamera;
  8000. if (!camera) {
  8001. return;
  8002. }
  8003. if (value) {
  8004. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8005. if (!mesh) {
  8006. return;
  8007. }
  8008. mesh.computeWorldMatrix(true);
  8009. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8010. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8011. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8012. });
  8013. }
  8014. else if (this._onMeshTargetChangedObserver) {
  8015. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8016. }
  8017. },
  8018. enumerable: true,
  8019. configurable: true
  8020. });
  8021. /**
  8022. * Initializes the behavior.
  8023. */
  8024. BouncingBehavior.prototype.init = function () {
  8025. // Do notihng
  8026. };
  8027. /**
  8028. * Attaches the behavior to its arc rotate camera.
  8029. * @param camera Defines the camera to attach the behavior to
  8030. */
  8031. BouncingBehavior.prototype.attach = function (camera) {
  8032. var _this = this;
  8033. this._attachedCamera = camera;
  8034. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8035. if (!_this._attachedCamera) {
  8036. return;
  8037. }
  8038. // Add the bounce animation to the lower radius limit
  8039. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8040. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8041. }
  8042. // Add the bounce animation to the upper radius limit
  8043. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8044. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8045. }
  8046. });
  8047. };
  8048. /**
  8049. * Detaches the behavior from its current arc rotate camera.
  8050. */
  8051. BouncingBehavior.prototype.detach = function () {
  8052. if (!this._attachedCamera) {
  8053. return;
  8054. }
  8055. if (this._onAfterCheckInputsObserver) {
  8056. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8057. }
  8058. if (this._onMeshTargetChangedObserver) {
  8059. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8060. }
  8061. this._attachedCamera = null;
  8062. };
  8063. /**
  8064. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8065. * @param radiusLimit The limit to check against.
  8066. * @return Bool to indicate if at limit.
  8067. */
  8068. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8069. if (!this._attachedCamera) {
  8070. return false;
  8071. }
  8072. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8073. return true;
  8074. }
  8075. return false;
  8076. };
  8077. /**
  8078. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8079. * @param radiusDelta The delta by which to animate to. Can be negative.
  8080. */
  8081. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8082. var _this = this;
  8083. if (!this._attachedCamera) {
  8084. return;
  8085. }
  8086. if (!this._radiusBounceTransition) {
  8087. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8088. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8089. }
  8090. // Prevent zoom until bounce has completed
  8091. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8092. this._attachedCamera.wheelPrecision = Infinity;
  8093. this._attachedCamera.inertialRadiusOffset = 0;
  8094. // Animate to the radius limit
  8095. this.stopAllAnimations();
  8096. this._radiusIsAnimating = true;
  8097. 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(); });
  8098. if (animatable) {
  8099. this._animatables.push(animatable);
  8100. }
  8101. };
  8102. /**
  8103. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8104. */
  8105. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8106. this._radiusIsAnimating = false;
  8107. if (this._attachedCamera) {
  8108. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8109. }
  8110. };
  8111. /**
  8112. * Stops and removes all animations that have been applied to the camera
  8113. */
  8114. BouncingBehavior.prototype.stopAllAnimations = function () {
  8115. if (this._attachedCamera) {
  8116. this._attachedCamera.animations = [];
  8117. }
  8118. while (this._animatables.length) {
  8119. this._animatables[0].onAnimationEnd = null;
  8120. this._animatables[0].stop();
  8121. this._animatables.shift();
  8122. }
  8123. };
  8124. /**
  8125. * The easing function used by animations
  8126. */
  8127. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8128. /**
  8129. * The easing mode used by animations
  8130. */
  8131. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8132. return BouncingBehavior;
  8133. }());
  8134. /***/ }),
  8135. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8136. /*!**********************************************!*\
  8137. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8138. \**********************************************/
  8139. /*! exports provided: FramingBehavior */
  8140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8141. "use strict";
  8142. __webpack_require__.r(__webpack_exports__);
  8143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8144. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8145. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8146. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8147. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8148. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8149. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8150. /**
  8151. * 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.
  8152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8153. */
  8154. var FramingBehavior = /** @class */ (function () {
  8155. function FramingBehavior() {
  8156. this._mode = FramingBehavior.FitFrustumSidesMode;
  8157. this._radiusScale = 1.0;
  8158. this._positionScale = 0.5;
  8159. this._defaultElevation = 0.3;
  8160. this._elevationReturnTime = 1500;
  8161. this._elevationReturnWaitTime = 1000;
  8162. this._zoomStopsAnimation = false;
  8163. this._framingTime = 1500;
  8164. /**
  8165. * Define if the behavior should automatically change the configured
  8166. * camera limits and sensibilities.
  8167. */
  8168. this.autoCorrectCameraLimitsAndSensibility = true;
  8169. this._isPointerDown = false;
  8170. this._lastInteractionTime = -Infinity;
  8171. // Framing control
  8172. this._animatables = new Array();
  8173. this._betaIsAnimating = false;
  8174. }
  8175. Object.defineProperty(FramingBehavior.prototype, "name", {
  8176. /**
  8177. * Gets the name of the behavior.
  8178. */
  8179. get: function () {
  8180. return "Framing";
  8181. },
  8182. enumerable: true,
  8183. configurable: true
  8184. });
  8185. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8186. /**
  8187. * Gets current mode used by the behavior.
  8188. */
  8189. get: function () {
  8190. return this._mode;
  8191. },
  8192. /**
  8193. * Sets the current mode used by the behavior
  8194. */
  8195. set: function (mode) {
  8196. this._mode = mode;
  8197. },
  8198. enumerable: true,
  8199. configurable: true
  8200. });
  8201. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8202. /**
  8203. * Gets the scale applied to the radius
  8204. */
  8205. get: function () {
  8206. return this._radiusScale;
  8207. },
  8208. /**
  8209. * Sets the scale applied to the radius (1 by default)
  8210. */
  8211. set: function (radius) {
  8212. this._radiusScale = radius;
  8213. },
  8214. enumerable: true,
  8215. configurable: true
  8216. });
  8217. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8218. /**
  8219. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8220. */
  8221. get: function () {
  8222. return this._positionScale;
  8223. },
  8224. /**
  8225. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8226. */
  8227. set: function (scale) {
  8228. this._positionScale = scale;
  8229. },
  8230. enumerable: true,
  8231. configurable: true
  8232. });
  8233. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8234. /**
  8235. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8236. * behaviour is triggered, in radians.
  8237. */
  8238. get: function () {
  8239. return this._defaultElevation;
  8240. },
  8241. /**
  8242. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8243. * behaviour is triggered, in radians.
  8244. */
  8245. set: function (elevation) {
  8246. this._defaultElevation = elevation;
  8247. },
  8248. enumerable: true,
  8249. configurable: true
  8250. });
  8251. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8252. /**
  8253. * Gets the time (in milliseconds) taken to return to the default beta position.
  8254. * Negative value indicates camera should not return to default.
  8255. */
  8256. get: function () {
  8257. return this._elevationReturnTime;
  8258. },
  8259. /**
  8260. * Sets the time (in milliseconds) taken to return to the default beta position.
  8261. * Negative value indicates camera should not return to default.
  8262. */
  8263. set: function (speed) {
  8264. this._elevationReturnTime = speed;
  8265. },
  8266. enumerable: true,
  8267. configurable: true
  8268. });
  8269. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8270. /**
  8271. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8272. */
  8273. get: function () {
  8274. return this._elevationReturnWaitTime;
  8275. },
  8276. /**
  8277. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8278. */
  8279. set: function (time) {
  8280. this._elevationReturnWaitTime = time;
  8281. },
  8282. enumerable: true,
  8283. configurable: true
  8284. });
  8285. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8286. /**
  8287. * Gets the flag that indicates if user zooming should stop animation.
  8288. */
  8289. get: function () {
  8290. return this._zoomStopsAnimation;
  8291. },
  8292. /**
  8293. * Sets the flag that indicates if user zooming should stop animation.
  8294. */
  8295. set: function (flag) {
  8296. this._zoomStopsAnimation = flag;
  8297. },
  8298. enumerable: true,
  8299. configurable: true
  8300. });
  8301. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8302. /**
  8303. * Gets the transition time when framing the mesh, in milliseconds
  8304. */
  8305. get: function () {
  8306. return this._framingTime;
  8307. },
  8308. /**
  8309. * Sets the transition time when framing the mesh, in milliseconds
  8310. */
  8311. set: function (time) {
  8312. this._framingTime = time;
  8313. },
  8314. enumerable: true,
  8315. configurable: true
  8316. });
  8317. /**
  8318. * Initializes the behavior.
  8319. */
  8320. FramingBehavior.prototype.init = function () {
  8321. // Do notihng
  8322. };
  8323. /**
  8324. * Attaches the behavior to its arc rotate camera.
  8325. * @param camera Defines the camera to attach the behavior to
  8326. */
  8327. FramingBehavior.prototype.attach = function (camera) {
  8328. var _this = this;
  8329. this._attachedCamera = camera;
  8330. var scene = this._attachedCamera.getScene();
  8331. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8332. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8333. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8334. _this._isPointerDown = true;
  8335. return;
  8336. }
  8337. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8338. _this._isPointerDown = false;
  8339. }
  8340. });
  8341. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8342. if (mesh) {
  8343. _this.zoomOnMesh(mesh);
  8344. }
  8345. });
  8346. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8347. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8348. _this._applyUserInteraction();
  8349. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8350. // back to the default position after a given timeout
  8351. _this._maintainCameraAboveGround();
  8352. });
  8353. };
  8354. /**
  8355. * Detaches the behavior from its current arc rotate camera.
  8356. */
  8357. FramingBehavior.prototype.detach = function () {
  8358. if (!this._attachedCamera) {
  8359. return;
  8360. }
  8361. var scene = this._attachedCamera.getScene();
  8362. if (this._onPrePointerObservableObserver) {
  8363. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8364. }
  8365. if (this._onAfterCheckInputsObserver) {
  8366. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8367. }
  8368. if (this._onMeshTargetChangedObserver) {
  8369. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8370. }
  8371. this._attachedCamera = null;
  8372. };
  8373. /**
  8374. * Targets the given mesh 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.zoomOnMesh = 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.getBoundingInfo().boundingBox;
  8386. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8387. };
  8388. /**
  8389. * Targets the given mesh with its children and updates zoom level accordingly.
  8390. * @param mesh 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.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8397. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8398. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8399. mesh.computeWorldMatrix(true);
  8400. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8401. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8402. };
  8403. /**
  8404. * Targets the given meshes with their children and updates zoom level accordingly.
  8405. * @param meshes The mesh to target.
  8406. * @param radius Optional. If a cached radius position already exists, overrides default.
  8407. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8408. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8409. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8410. */
  8411. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8412. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8413. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8414. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8415. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8416. for (var i = 0; i < meshes.length; i++) {
  8417. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8418. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8419. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8420. }
  8421. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8422. };
  8423. /**
  8424. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8425. * @param minimumWorld Determines the smaller position of the bounding box extend
  8426. * @param maximumWorld Determines the bigger position of the bounding box extend
  8427. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8428. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8429. */
  8430. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8431. var _this = this;
  8432. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8433. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8434. var zoomTarget;
  8435. if (!this._attachedCamera) {
  8436. return;
  8437. }
  8438. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8439. var bottom = minimumWorld.y;
  8440. var top = maximumWorld.y;
  8441. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8442. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8443. if (focusOnOriginXZ) {
  8444. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8445. }
  8446. else {
  8447. var centerWorld = minimumWorld.add(radiusWorld);
  8448. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8449. }
  8450. if (!this._vectorTransition) {
  8451. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8452. }
  8453. this._betaIsAnimating = true;
  8454. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8455. if (animatable) {
  8456. this._animatables.push(animatable);
  8457. }
  8458. // sets the radius and lower radius bounds
  8459. // Small delta ensures camera is not always at lower zoom limit.
  8460. var radius = 0;
  8461. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8462. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8463. if (this.autoCorrectCameraLimitsAndSensibility) {
  8464. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8465. }
  8466. radius = position;
  8467. }
  8468. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8469. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8470. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8471. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8472. }
  8473. }
  8474. // Set sensibilities
  8475. if (this.autoCorrectCameraLimitsAndSensibility) {
  8476. var extend = maximumWorld.subtract(minimumWorld).length();
  8477. this._attachedCamera.panningSensibility = 5000 / extend;
  8478. this._attachedCamera.wheelPrecision = 100 / radius;
  8479. }
  8480. // transition to new radius
  8481. if (!this._radiusTransition) {
  8482. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8483. }
  8484. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8485. _this.stopAllAnimations();
  8486. if (onAnimationEnd) {
  8487. onAnimationEnd();
  8488. }
  8489. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8490. _this._attachedCamera.storeState();
  8491. }
  8492. });
  8493. if (animatable) {
  8494. this._animatables.push(animatable);
  8495. }
  8496. };
  8497. /**
  8498. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8499. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8500. * frustum width.
  8501. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8502. * to fully enclose the mesh in the viewing frustum.
  8503. */
  8504. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8505. var size = maximumWorld.subtract(minimumWorld);
  8506. var boxVectorGlobalDiagonal = size.length();
  8507. var frustumSlope = this._getFrustumSlope();
  8508. // Formula for setting distance
  8509. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8510. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8511. // Horizon distance
  8512. var radius = radiusWithoutFraming * this._radiusScale;
  8513. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8514. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8515. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8516. var camera = this._attachedCamera;
  8517. if (!camera) {
  8518. return 0;
  8519. }
  8520. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8521. // Don't exceed the requested limit
  8522. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8523. }
  8524. // Don't exceed the upper radius limit
  8525. if (camera.upperRadiusLimit) {
  8526. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8527. }
  8528. return distance;
  8529. };
  8530. /**
  8531. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8532. * is automatically returned to its default position (expected to be above ground plane).
  8533. */
  8534. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8535. var _this = this;
  8536. if (this._elevationReturnTime < 0) {
  8537. return;
  8538. }
  8539. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8540. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8541. var limitBeta = Math.PI * 0.5;
  8542. // Bring the camera back up if below the ground plane
  8543. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8544. this._betaIsAnimating = true;
  8545. //Transition to new position
  8546. this.stopAllAnimations();
  8547. if (!this._betaTransition) {
  8548. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8549. }
  8550. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8551. _this._clearAnimationLocks();
  8552. _this.stopAllAnimations();
  8553. });
  8554. if (animatabe) {
  8555. this._animatables.push(animatabe);
  8556. }
  8557. }
  8558. };
  8559. /**
  8560. * Returns the frustum slope based on the canvas ratio and camera FOV
  8561. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8562. */
  8563. FramingBehavior.prototype._getFrustumSlope = function () {
  8564. // Calculate the viewport ratio
  8565. // Aspect Ratio is Height/Width.
  8566. var camera = this._attachedCamera;
  8567. if (!camera) {
  8568. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8569. }
  8570. var engine = camera.getScene().getEngine();
  8571. var aspectRatio = engine.getAspectRatio(camera);
  8572. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8573. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8574. var frustumSlopeY = Math.tan(camera.fov / 2);
  8575. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8576. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8577. // along the forward vector.
  8578. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8579. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8580. };
  8581. /**
  8582. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8583. */
  8584. FramingBehavior.prototype._clearAnimationLocks = function () {
  8585. this._betaIsAnimating = false;
  8586. };
  8587. /**
  8588. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8589. */
  8590. FramingBehavior.prototype._applyUserInteraction = function () {
  8591. if (this.isUserIsMoving) {
  8592. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8593. this.stopAllAnimations();
  8594. this._clearAnimationLocks();
  8595. }
  8596. };
  8597. /**
  8598. * Stops and removes all animations that have been applied to the camera
  8599. */
  8600. FramingBehavior.prototype.stopAllAnimations = function () {
  8601. if (this._attachedCamera) {
  8602. this._attachedCamera.animations = [];
  8603. }
  8604. while (this._animatables.length) {
  8605. if (this._animatables[0]) {
  8606. this._animatables[0].onAnimationEnd = null;
  8607. this._animatables[0].stop();
  8608. }
  8609. this._animatables.shift();
  8610. }
  8611. };
  8612. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8613. /**
  8614. * Gets a value indicating if the user is moving the camera
  8615. */
  8616. get: function () {
  8617. if (!this._attachedCamera) {
  8618. return false;
  8619. }
  8620. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8621. this._attachedCamera.inertialBetaOffset !== 0 ||
  8622. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8623. this._attachedCamera.inertialPanningX !== 0 ||
  8624. this._attachedCamera.inertialPanningY !== 0 ||
  8625. this._isPointerDown;
  8626. },
  8627. enumerable: true,
  8628. configurable: true
  8629. });
  8630. /**
  8631. * The easing function used by animations
  8632. */
  8633. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8634. /**
  8635. * The easing mode used by animations
  8636. */
  8637. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8638. // Statics
  8639. /**
  8640. * The camera can move all the way towards the mesh.
  8641. */
  8642. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8643. /**
  8644. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8645. */
  8646. FramingBehavior.FitFrustumSidesMode = 1;
  8647. return FramingBehavior;
  8648. }());
  8649. /***/ }),
  8650. /***/ "./Behaviors/Cameras/index.ts":
  8651. /*!************************************!*\
  8652. !*** ./Behaviors/Cameras/index.ts ***!
  8653. \************************************/
  8654. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8656. "use strict";
  8657. __webpack_require__.r(__webpack_exports__);
  8658. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8660. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8662. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8664. /***/ }),
  8665. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8666. /*!*************************************************!*\
  8667. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8668. \*************************************************/
  8669. /*! exports provided: AttachToBoxBehavior */
  8670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8671. "use strict";
  8672. __webpack_require__.r(__webpack_exports__);
  8673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8674. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8675. /**
  8676. * @hidden
  8677. */
  8678. var FaceDirectionInfo = /** @class */ (function () {
  8679. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8680. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8681. if (diff === void 0) { diff = 0; }
  8682. if (ignore === void 0) { ignore = false; }
  8683. this.direction = direction;
  8684. this.rotatedDirection = rotatedDirection;
  8685. this.diff = diff;
  8686. this.ignore = ignore;
  8687. }
  8688. return FaceDirectionInfo;
  8689. }());
  8690. /**
  8691. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8692. */
  8693. var AttachToBoxBehavior = /** @class */ (function () {
  8694. /**
  8695. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8696. * @param ui The transform node that should be attched to the mesh
  8697. */
  8698. function AttachToBoxBehavior(ui) {
  8699. this.ui = ui;
  8700. /**
  8701. * The name of the behavior
  8702. */
  8703. this.name = "AttachToBoxBehavior";
  8704. /**
  8705. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8706. */
  8707. this.distanceAwayFromFace = 0.15;
  8708. /**
  8709. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8710. */
  8711. this.distanceAwayFromBottomOfFace = 0.15;
  8712. 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))];
  8713. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8714. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8715. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8716. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8717. /* Does nothing */
  8718. }
  8719. /**
  8720. * Initializes the behavior
  8721. */
  8722. AttachToBoxBehavior.prototype.init = function () {
  8723. /* Does nothing */
  8724. };
  8725. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8726. var _this = this;
  8727. // Go over each face and calculate the angle between the face's normal and targetDirection
  8728. this._faceVectors.forEach(function (v) {
  8729. if (!_this._target.rotationQuaternion) {
  8730. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8731. }
  8732. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8733. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8734. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8735. });
  8736. // Return the face information of the one with the normal closeset to target direction
  8737. return this._faceVectors.reduce(function (min, p) {
  8738. if (min.ignore) {
  8739. return p;
  8740. }
  8741. else if (p.ignore) {
  8742. return min;
  8743. }
  8744. else {
  8745. return min.diff < p.diff ? min : p;
  8746. }
  8747. }, this._faceVectors[0]);
  8748. };
  8749. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8750. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8751. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8752. this._lookAtTmpMatrix.invert();
  8753. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8754. };
  8755. /**
  8756. * Attaches the AttachToBoxBehavior to the passed in mesh
  8757. * @param target The mesh that the specified node will be attached to
  8758. */
  8759. AttachToBoxBehavior.prototype.attach = function (target) {
  8760. var _this = this;
  8761. this._target = target;
  8762. this._scene = this._target.getScene();
  8763. // Every frame, update the app bars position
  8764. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8765. if (!_this._scene.activeCamera) {
  8766. return;
  8767. }
  8768. // Find the face closest to the cameras position
  8769. var cameraPos = _this._scene.activeCamera.position;
  8770. if (_this._scene.activeCamera.devicePosition) {
  8771. cameraPos = _this._scene.activeCamera.devicePosition;
  8772. }
  8773. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8774. if (_this._scene.activeCamera.leftCamera) {
  8775. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8776. }
  8777. else {
  8778. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8779. }
  8780. // Get camera up direction
  8781. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8782. // Ignore faces to not select a parrelel face for the up vector of the UI
  8783. _this._faceVectors.forEach(function (v) {
  8784. if (facing.direction.x && v.direction.x) {
  8785. v.ignore = true;
  8786. }
  8787. if (facing.direction.y && v.direction.y) {
  8788. v.ignore = true;
  8789. }
  8790. if (facing.direction.z && v.direction.z) {
  8791. v.ignore = true;
  8792. }
  8793. });
  8794. var facingUp = _this._closestFace(_this._tmpVector);
  8795. // Unignore faces
  8796. _this._faceVectors.forEach(function (v) {
  8797. v.ignore = false;
  8798. });
  8799. // Position the app bar on that face
  8800. _this.ui.position.copyFrom(target.position);
  8801. if (facing.direction.x) {
  8802. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8803. _this.ui.position.addInPlace(_this._tmpVector);
  8804. }
  8805. if (facing.direction.y) {
  8806. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8807. _this.ui.position.addInPlace(_this._tmpVector);
  8808. }
  8809. if (facing.direction.z) {
  8810. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8811. _this.ui.position.addInPlace(_this._tmpVector);
  8812. }
  8813. // Rotate to be oriented properly to the camera
  8814. if (!_this.ui.rotationQuaternion) {
  8815. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8816. }
  8817. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8818. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8819. // Place ui the correct distance from the bottom of the mesh
  8820. if (facingUp.direction.x) {
  8821. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8822. }
  8823. if (facingUp.direction.y) {
  8824. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8825. }
  8826. if (facingUp.direction.z) {
  8827. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8828. }
  8829. _this.ui.position.addInPlace(_this._tmpVector);
  8830. });
  8831. };
  8832. /**
  8833. * Detaches the behavior from the mesh
  8834. */
  8835. AttachToBoxBehavior.prototype.detach = function () {
  8836. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8837. };
  8838. return AttachToBoxBehavior;
  8839. }());
  8840. /***/ }),
  8841. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8842. /*!***********************************************!*\
  8843. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8844. \***********************************************/
  8845. /*! exports provided: FadeInOutBehavior */
  8846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8847. "use strict";
  8848. __webpack_require__.r(__webpack_exports__);
  8849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8850. /**
  8851. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8852. */
  8853. var FadeInOutBehavior = /** @class */ (function () {
  8854. /**
  8855. * Instatiates the FadeInOutBehavior
  8856. */
  8857. function FadeInOutBehavior() {
  8858. var _this = this;
  8859. /**
  8860. * Time in milliseconds to delay before fading in (Default: 0)
  8861. */
  8862. this.delay = 0;
  8863. /**
  8864. * Time in milliseconds for the mesh to fade in (Default: 300)
  8865. */
  8866. this.fadeInTime = 300;
  8867. this._millisecondsPerFrame = 1000 / 60;
  8868. this._hovered = false;
  8869. this._hoverValue = 0;
  8870. this._ownerNode = null;
  8871. this._update = function () {
  8872. if (_this._ownerNode) {
  8873. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8874. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8875. if (_this._ownerNode.visibility > 1) {
  8876. _this._setAllVisibility(_this._ownerNode, 1);
  8877. _this._hoverValue = _this.fadeInTime + _this.delay;
  8878. return;
  8879. }
  8880. else if (_this._ownerNode.visibility < 0) {
  8881. _this._setAllVisibility(_this._ownerNode, 0);
  8882. if (_this._hoverValue < 0) {
  8883. _this._hoverValue = 0;
  8884. return;
  8885. }
  8886. }
  8887. setTimeout(_this._update, _this._millisecondsPerFrame);
  8888. }
  8889. };
  8890. }
  8891. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8892. /**
  8893. * The name of the behavior
  8894. */
  8895. get: function () {
  8896. return "FadeInOut";
  8897. },
  8898. enumerable: true,
  8899. configurable: true
  8900. });
  8901. /**
  8902. * Initializes the behavior
  8903. */
  8904. FadeInOutBehavior.prototype.init = function () {
  8905. };
  8906. /**
  8907. * Attaches the fade behavior on the passed in mesh
  8908. * @param ownerNode The mesh that will be faded in/out once attached
  8909. */
  8910. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8911. this._ownerNode = ownerNode;
  8912. this._setAllVisibility(this._ownerNode, 0);
  8913. };
  8914. /**
  8915. * Detaches the behavior from the mesh
  8916. */
  8917. FadeInOutBehavior.prototype.detach = function () {
  8918. this._ownerNode = null;
  8919. };
  8920. /**
  8921. * Triggers the mesh to begin fading in or out
  8922. * @param value if the object should fade in or out (true to fade in)
  8923. */
  8924. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8925. this._hovered = value;
  8926. this._update();
  8927. };
  8928. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8929. var _this = this;
  8930. mesh.visibility = value;
  8931. mesh.getChildMeshes().forEach(function (c) {
  8932. _this._setAllVisibility(c, value);
  8933. });
  8934. };
  8935. return FadeInOutBehavior;
  8936. }());
  8937. /***/ }),
  8938. /***/ "./Behaviors/Meshes/index.ts":
  8939. /*!***********************************!*\
  8940. !*** ./Behaviors/Meshes/index.ts ***!
  8941. \***********************************/
  8942. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8944. "use strict";
  8945. __webpack_require__.r(__webpack_exports__);
  8946. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8948. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8950. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8952. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8954. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8956. /***/ }),
  8957. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8958. /*!*******************************************************!*\
  8959. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8960. \*******************************************************/
  8961. /*! exports provided: MultiPointerScaleBehavior */
  8962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8963. "use strict";
  8964. __webpack_require__.r(__webpack_exports__);
  8965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8966. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8967. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8968. /**
  8969. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8970. */
  8971. var MultiPointerScaleBehavior = /** @class */ (function () {
  8972. /**
  8973. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8974. */
  8975. function MultiPointerScaleBehavior() {
  8976. this._startDistance = 0;
  8977. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8978. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8979. this._sceneRenderObserver = null;
  8980. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8981. this._dragBehaviorA.moveAttached = false;
  8982. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8983. this._dragBehaviorB.moveAttached = false;
  8984. }
  8985. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8986. /**
  8987. * The name of the behavior
  8988. */
  8989. get: function () {
  8990. return "MultiPointerScale";
  8991. },
  8992. enumerable: true,
  8993. configurable: true
  8994. });
  8995. /**
  8996. * Initializes the behavior
  8997. */
  8998. MultiPointerScaleBehavior.prototype.init = function () { };
  8999. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  9000. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  9001. };
  9002. /**
  9003. * Attaches the scale behavior the passed in mesh
  9004. * @param ownerNode The mesh that will be scaled around once attached
  9005. */
  9006. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9007. var _this = this;
  9008. this._ownerNode = ownerNode;
  9009. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9010. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9011. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9012. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9013. _this._dragBehaviorA.releaseDrag();
  9014. }
  9015. else {
  9016. _this._initialScale.copyFrom(ownerNode.scaling);
  9017. _this._startDistance = _this._getCurrentDistance();
  9018. }
  9019. }
  9020. });
  9021. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9022. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9023. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9024. _this._dragBehaviorB.releaseDrag();
  9025. }
  9026. else {
  9027. _this._initialScale.copyFrom(ownerNode.scaling);
  9028. _this._startDistance = _this._getCurrentDistance();
  9029. }
  9030. }
  9031. });
  9032. // Once both drag behaviors are active scale based on the distance between the two pointers
  9033. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9034. behavior.onDragObservable.add(function () {
  9035. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9036. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9037. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9038. }
  9039. });
  9040. });
  9041. ownerNode.addBehavior(this._dragBehaviorA);
  9042. ownerNode.addBehavior(this._dragBehaviorB);
  9043. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9044. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9045. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9046. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9047. if (change.length() > 0.01) {
  9048. ownerNode.scaling.addInPlace(change);
  9049. }
  9050. }
  9051. });
  9052. };
  9053. /**
  9054. * Detaches the behavior from the mesh
  9055. */
  9056. MultiPointerScaleBehavior.prototype.detach = function () {
  9057. var _this = this;
  9058. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9059. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9060. behavior.onDragStartObservable.clear();
  9061. behavior.onDragObservable.clear();
  9062. _this._ownerNode.removeBehavior(behavior);
  9063. });
  9064. };
  9065. return MultiPointerScaleBehavior;
  9066. }());
  9067. /***/ }),
  9068. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9069. /*!*************************************************!*\
  9070. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9071. \*************************************************/
  9072. /*! exports provided: PointerDragBehavior */
  9073. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9074. "use strict";
  9075. __webpack_require__.r(__webpack_exports__);
  9076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9077. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9078. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9079. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9080. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9081. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9082. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9083. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9084. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9085. /**
  9086. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9087. */
  9088. var PointerDragBehavior = /** @class */ (function () {
  9089. /**
  9090. * Creates a pointer drag behavior that can be attached to a mesh
  9091. * @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)
  9092. */
  9093. function PointerDragBehavior(options) {
  9094. /**
  9095. * 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)
  9096. */
  9097. this.maxDragAngle = 0;
  9098. /**
  9099. * @hidden
  9100. */
  9101. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9102. /**
  9103. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9104. */
  9105. this.currentDraggingPointerID = -1;
  9106. /**
  9107. * If the behavior is currently in a dragging state
  9108. */
  9109. this.dragging = false;
  9110. /**
  9111. * 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)
  9112. */
  9113. this.dragDeltaRatio = 0.2;
  9114. /**
  9115. * If the drag plane orientation should be updated during the dragging (Default: true)
  9116. */
  9117. this.updateDragPlane = true;
  9118. // Debug mode will display drag planes to help visualize behavior
  9119. this._debugMode = false;
  9120. this._moving = false;
  9121. /**
  9122. * Fires each time the attached mesh is dragged with the pointer
  9123. * * delta between last drag position and current drag position in world space
  9124. * * dragDistance along the drag axis
  9125. * * dragPlaneNormal normal of the current drag plane used during the drag
  9126. * * dragPlanePoint in world space where the drag intersects the drag plane
  9127. */
  9128. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9129. /**
  9130. * Fires each time a drag begins (eg. mouse down on mesh)
  9131. */
  9132. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9133. /**
  9134. * Fires each time a drag ends (eg. mouse release after drag)
  9135. */
  9136. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9137. /**
  9138. * If the attached mesh should be moved when dragged
  9139. */
  9140. this.moveAttached = true;
  9141. /**
  9142. * If the drag behavior will react to drag events (Default: true)
  9143. */
  9144. this.enabled = true;
  9145. /**
  9146. * If camera controls should be detached during the drag
  9147. */
  9148. this.detachCameraControls = true;
  9149. /**
  9150. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9151. */
  9152. this.useObjectOrienationForDragging = true;
  9153. /**
  9154. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9155. */
  9156. this.validateDrag = function (targetPosition) { return true; };
  9157. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9158. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9159. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9160. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9161. this._attachedElement = null;
  9162. 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"]());
  9163. this._lastPointerRay = {};
  9164. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9165. // Variables to avoid instantiation in the below method
  9166. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9167. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9168. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9169. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9170. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9171. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9172. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9173. this._options = options ? options : {};
  9174. var optionCount = 0;
  9175. if (this._options.dragAxis) {
  9176. optionCount++;
  9177. }
  9178. if (this._options.dragPlaneNormal) {
  9179. optionCount++;
  9180. }
  9181. if (optionCount > 1) {
  9182. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9183. }
  9184. }
  9185. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9186. /**
  9187. * The name of the behavior
  9188. */
  9189. get: function () {
  9190. return "PointerDrag";
  9191. },
  9192. enumerable: true,
  9193. configurable: true
  9194. });
  9195. /**
  9196. * Initializes the behavior
  9197. */
  9198. PointerDragBehavior.prototype.init = function () { };
  9199. /**
  9200. * Attaches the drag behavior the passed in mesh
  9201. * @param ownerNode The mesh that will be dragged around once attached
  9202. */
  9203. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9204. var _this = this;
  9205. this._scene = ownerNode.getScene();
  9206. this._attachedNode = ownerNode;
  9207. // Initialize drag plane to not interfere with existing scene
  9208. if (!PointerDragBehavior._planeScene) {
  9209. if (this._debugMode) {
  9210. PointerDragBehavior._planeScene = this._scene;
  9211. }
  9212. else {
  9213. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9214. PointerDragBehavior._planeScene.detachControl();
  9215. this._scene.getEngine().scenes.pop();
  9216. this._scene.onDisposeObservable.addOnce(function () {
  9217. PointerDragBehavior._planeScene.dispose();
  9218. PointerDragBehavior._planeScene = null;
  9219. });
  9220. }
  9221. }
  9222. 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);
  9223. // State of the drag
  9224. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9225. var pickPredicate = function (m) {
  9226. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9227. };
  9228. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9229. if (!_this.enabled) {
  9230. return;
  9231. }
  9232. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9233. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9234. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9235. }
  9236. }
  9237. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9238. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9239. _this.releaseDrag();
  9240. }
  9241. }
  9242. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9243. var pointerId = pointerInfo.event.pointerId;
  9244. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9245. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9246. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9247. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9248. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9249. }
  9250. _this.currentDraggingPointerID = pointerId;
  9251. }
  9252. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9253. if (!_this._lastPointerRay[pointerId]) {
  9254. _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"]());
  9255. }
  9256. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9257. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9258. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9259. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9260. _this._moveDrag(pointerInfo.pickInfo.ray);
  9261. }
  9262. }
  9263. }
  9264. });
  9265. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9266. if (_this._moving && _this.moveAttached) {
  9267. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9268. // Slowly move mesh to avoid jitter
  9269. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9270. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9271. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9272. if (_this.validateDrag(_this._tmpVector)) {
  9273. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9274. }
  9275. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9276. }
  9277. });
  9278. };
  9279. /**
  9280. * Force relase the drag action by code.
  9281. */
  9282. PointerDragBehavior.prototype.releaseDrag = function () {
  9283. this.dragging = false;
  9284. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9285. this.currentDraggingPointerID = -1;
  9286. this._moving = false;
  9287. // Reattach camera controls
  9288. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9289. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9290. }
  9291. };
  9292. /**
  9293. * Simulates the start of a pointer drag event on the behavior
  9294. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9295. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9296. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9297. */
  9298. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9299. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9300. this._startDrag(pointerId, fromRay, startPickedPoint);
  9301. var lastRay = this._lastPointerRay[pointerId];
  9302. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9303. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9304. }
  9305. if (lastRay) {
  9306. // if there was a last pointer ray drag the object there
  9307. this._moveDrag(lastRay);
  9308. }
  9309. };
  9310. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9311. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9312. return;
  9313. }
  9314. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9315. // Create start ray from the camera to the object
  9316. if (fromRay) {
  9317. this._startDragRay.direction.copyFrom(fromRay.direction);
  9318. this._startDragRay.origin.copyFrom(fromRay.origin);
  9319. }
  9320. else {
  9321. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9322. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9323. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9324. }
  9325. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9326. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9327. if (pickedPoint) {
  9328. this.dragging = true;
  9329. this.currentDraggingPointerID = pointerId;
  9330. this.lastDragPosition.copyFrom(pickedPoint);
  9331. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9332. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9333. // Detatch camera controls
  9334. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9335. if (this._scene.activeCamera.inputs.attachedElement) {
  9336. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9337. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9338. }
  9339. else {
  9340. this._attachedElement = null;
  9341. }
  9342. }
  9343. }
  9344. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9345. };
  9346. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9347. this._moving = true;
  9348. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9349. if (pickedPoint) {
  9350. if (this.updateDragPlane) {
  9351. this._updateDragPlanePosition(ray, pickedPoint);
  9352. }
  9353. var dragLength = 0;
  9354. // depending on the drag mode option drag accordingly
  9355. if (this._options.dragAxis) {
  9356. // Convert local drag axis to world
  9357. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9358. // Project delta drag from the drag plane onto the drag axis
  9359. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9360. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9361. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9362. }
  9363. else {
  9364. dragLength = this._dragDelta.length();
  9365. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9366. }
  9367. this._targetPosition.addInPlace(this._dragDelta);
  9368. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9369. this.lastDragPosition.copyFrom(pickedPoint);
  9370. }
  9371. };
  9372. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9373. var _this = this;
  9374. if (!ray) {
  9375. return null;
  9376. }
  9377. // Calculate angle between plane normal and ray
  9378. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9379. // Correct if ray is casted from oposite side
  9380. if (angle > Math.PI / 2) {
  9381. angle = Math.PI - angle;
  9382. }
  9383. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9384. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9385. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9386. // Invert ray direction along the towards object axis
  9387. this._tmpVector.copyFrom(ray.direction);
  9388. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9389. this._alternatePickedPoint.normalize();
  9390. this._alternatePickedPoint.scaleInPlace(-2 * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9391. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9392. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9393. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9394. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9395. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9396. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9397. return this._alternatePickedPoint;
  9398. }
  9399. else {
  9400. return null;
  9401. }
  9402. }
  9403. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9404. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9405. return pickResult.pickedPoint;
  9406. }
  9407. else {
  9408. return null;
  9409. }
  9410. };
  9411. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9412. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9413. this._pointA.copyFrom(dragPlanePosition);
  9414. if (this._options.dragAxis) {
  9415. 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);
  9416. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9417. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9418. ray.origin.subtractToRef(this._pointA, this._pointC);
  9419. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9420. // Get perpendicular line from direction to camera and drag axis
  9421. this._pointB.subtractToRef(this._pointA, this._lineA);
  9422. this._pointC.subtractToRef(this._pointA, this._lineB);
  9423. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9424. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9425. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9426. this._lookAt.normalize();
  9427. this._dragPlane.position.copyFrom(this._pointA);
  9428. this._pointA.addToRef(this._lookAt, this._lookAt);
  9429. this._dragPlane.lookAt(this._lookAt);
  9430. }
  9431. else if (this._options.dragPlaneNormal) {
  9432. 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);
  9433. this._dragPlane.position.copyFrom(this._pointA);
  9434. this._pointA.addToRef(this._localAxis, this._lookAt);
  9435. this._dragPlane.lookAt(this._lookAt);
  9436. }
  9437. else {
  9438. this._dragPlane.position.copyFrom(this._pointA);
  9439. this._dragPlane.lookAt(ray.origin);
  9440. }
  9441. // Update the position of the drag plane so it doesn't get out of sync with the node (eg. when moving back and forth quickly)
  9442. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9443. this._dragPlane.computeWorldMatrix(true);
  9444. };
  9445. /**
  9446. * Detaches the behavior from the mesh
  9447. */
  9448. PointerDragBehavior.prototype.detach = function () {
  9449. if (this._pointerObserver) {
  9450. this._scene.onPointerObservable.remove(this._pointerObserver);
  9451. }
  9452. if (this._beforeRenderObserver) {
  9453. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9454. }
  9455. };
  9456. PointerDragBehavior._AnyMouseID = -2;
  9457. return PointerDragBehavior;
  9458. }());
  9459. /***/ }),
  9460. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9461. /*!************************************************!*\
  9462. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9463. \************************************************/
  9464. /*! exports provided: SixDofDragBehavior */
  9465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9466. "use strict";
  9467. __webpack_require__.r(__webpack_exports__);
  9468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9469. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9470. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9471. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9472. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9473. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9474. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9475. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9476. /**
  9477. * 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
  9478. */
  9479. var SixDofDragBehavior = /** @class */ (function () {
  9480. /**
  9481. * 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
  9482. */
  9483. function SixDofDragBehavior() {
  9484. this._sceneRenderObserver = null;
  9485. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9486. this._moving = false;
  9487. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9488. /**
  9489. * 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)
  9490. */
  9491. this.zDragFactor = 3;
  9492. /**
  9493. * If the object should rotate to face the drag origin
  9494. */
  9495. this.rotateDraggedObject = true;
  9496. /**
  9497. * If the behavior is currently in a dragging state
  9498. */
  9499. this.dragging = false;
  9500. /**
  9501. * 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)
  9502. */
  9503. this.dragDeltaRatio = 0.2;
  9504. /**
  9505. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9506. */
  9507. this.currentDraggingPointerID = -1;
  9508. /**
  9509. * If camera controls should be detached during the drag
  9510. */
  9511. this.detachCameraControls = true;
  9512. /**
  9513. * Fires each time a drag starts
  9514. */
  9515. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9516. /**
  9517. * Fires each time a drag ends (eg. mouse release after drag)
  9518. */
  9519. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9520. }
  9521. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9522. /**
  9523. * The name of the behavior
  9524. */
  9525. get: function () {
  9526. return "SixDofDrag";
  9527. },
  9528. enumerable: true,
  9529. configurable: true
  9530. });
  9531. /**
  9532. * Initializes the behavior
  9533. */
  9534. SixDofDragBehavior.prototype.init = function () { };
  9535. /**
  9536. * Attaches the scale behavior the passed in mesh
  9537. * @param ownerNode The mesh that will be scaled around once attached
  9538. */
  9539. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9540. var _this = this;
  9541. this._ownerNode = ownerNode;
  9542. this._scene = this._ownerNode.getScene();
  9543. if (!SixDofDragBehavior._virtualScene) {
  9544. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9545. SixDofDragBehavior._virtualScene.detachControl();
  9546. this._scene.getEngine().scenes.pop();
  9547. }
  9548. var pickedMesh = null;
  9549. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9550. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9551. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9552. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9553. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9554. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9555. var pickPredicate = function (m) {
  9556. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9557. };
  9558. var attachedElement = null;
  9559. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9560. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9561. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9562. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9563. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9564. }
  9565. pickedMesh = _this._ownerNode;
  9566. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9567. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9568. // Set position and orientation of the controller
  9569. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9570. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9571. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9572. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9573. pickedMesh.computeWorldMatrix();
  9574. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9575. if (!pickedMesh.rotationQuaternion) {
  9576. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9577. }
  9578. var oldParent = pickedMesh.parent;
  9579. pickedMesh.setParent(null);
  9580. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9581. pickedMesh.setParent(oldParent);
  9582. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9583. // Update state
  9584. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9585. _this.dragging = true;
  9586. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9587. // Detatch camera controls
  9588. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9589. if (_this._scene.activeCamera.inputs.attachedElement) {
  9590. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9591. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9592. }
  9593. else {
  9594. attachedElement = null;
  9595. }
  9596. }
  9597. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9598. _this.onDragStartObservable.notifyObservers({});
  9599. }
  9600. }
  9601. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9602. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9603. _this.dragging = false;
  9604. _this._moving = false;
  9605. _this.currentDraggingPointerID = -1;
  9606. pickedMesh = null;
  9607. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9608. // Reattach camera controls
  9609. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9610. _this._scene.activeCamera.attachControl(attachedElement, true);
  9611. }
  9612. _this.onDragEndObservable.notifyObservers({});
  9613. }
  9614. }
  9615. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9616. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9617. var zDragFactor = _this.zDragFactor;
  9618. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9619. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9620. zDragFactor = 0;
  9621. }
  9622. // Calculate controller drag distance in controller space
  9623. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9624. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9625. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9626. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9627. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9628. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9629. if (_this._virtualDragMesh.position.z < 0) {
  9630. _this._virtualDragMesh.position.z = 0;
  9631. }
  9632. // Update the controller position
  9633. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9634. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9635. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9636. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9637. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9638. if (pickedMesh.parent) {
  9639. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9640. }
  9641. if (!_this._moving) {
  9642. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9643. }
  9644. _this._moving = true;
  9645. }
  9646. }
  9647. });
  9648. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9649. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9650. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9651. if (_this.dragging && _this._moving && pickedMesh) {
  9652. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9653. // Slowly move mesh to avoid jitter
  9654. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9655. if (_this.rotateDraggedObject) {
  9656. // Get change in rotation
  9657. tmpQuaternion.copyFrom(_this._startingOrientation);
  9658. tmpQuaternion.x = -tmpQuaternion.x;
  9659. tmpQuaternion.y = -tmpQuaternion.y;
  9660. tmpQuaternion.z = -tmpQuaternion.z;
  9661. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9662. // Convert change in rotation to only y axis rotation
  9663. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9664. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9665. // Slowly move mesh to avoid jitter
  9666. var oldParent = pickedMesh.parent;
  9667. // Only rotate the mesh if it's parent has uniform scaling
  9668. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9669. pickedMesh.setParent(null);
  9670. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9671. pickedMesh.setParent(oldParent);
  9672. }
  9673. }
  9674. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9675. }
  9676. });
  9677. };
  9678. /**
  9679. * Detaches the behavior from the mesh
  9680. */
  9681. SixDofDragBehavior.prototype.detach = function () {
  9682. if (this._scene) {
  9683. this._scene.onPointerObservable.remove(this._pointerObserver);
  9684. }
  9685. if (this._ownerNode) {
  9686. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9687. }
  9688. if (this._virtualOriginMesh) {
  9689. this._virtualOriginMesh.dispose();
  9690. }
  9691. if (this._virtualDragMesh) {
  9692. this._virtualDragMesh.dispose();
  9693. }
  9694. this.onDragEndObservable.clear();
  9695. this.onDragStartObservable.clear();
  9696. };
  9697. return SixDofDragBehavior;
  9698. }());
  9699. /***/ }),
  9700. /***/ "./Behaviors/index.ts":
  9701. /*!****************************!*\
  9702. !*** ./Behaviors/index.ts ***!
  9703. \****************************/
  9704. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9706. "use strict";
  9707. __webpack_require__.r(__webpack_exports__);
  9708. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9712. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9718. /***/ }),
  9719. /***/ "./Bones/bone.ts":
  9720. /*!***********************!*\
  9721. !*** ./Bones/bone.ts ***!
  9722. \***********************/
  9723. /*! exports provided: Bone */
  9724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9725. "use strict";
  9726. __webpack_require__.r(__webpack_exports__);
  9727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9728. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9729. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9730. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9731. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9732. /**
  9733. * Class used to store bone information
  9734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9735. */
  9736. var Bone = /** @class */ (function (_super) {
  9737. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9738. /**
  9739. * Create a new bone
  9740. * @param name defines the bone name
  9741. * @param skeleton defines the parent skeleton
  9742. * @param parentBone defines the parent (can be null if the bone is the root)
  9743. * @param localMatrix defines the local matrix
  9744. * @param restPose defines the rest pose matrix
  9745. * @param baseMatrix defines the base matrix
  9746. * @param index defines index of the bone in the hiearchy
  9747. */
  9748. function Bone(
  9749. /**
  9750. * defines the bone name
  9751. */
  9752. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9753. if (parentBone === void 0) { parentBone = null; }
  9754. if (localMatrix === void 0) { localMatrix = null; }
  9755. if (restPose === void 0) { restPose = null; }
  9756. if (baseMatrix === void 0) { baseMatrix = null; }
  9757. if (index === void 0) { index = null; }
  9758. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9759. _this.name = name;
  9760. /**
  9761. * Gets the list of child bones
  9762. */
  9763. _this.children = new Array();
  9764. /** Gets the animations associated with this bone */
  9765. _this.animations = new Array();
  9766. /**
  9767. * @hidden Internal only
  9768. * Set this value to map this bone to a different index in the transform matrices
  9769. * Set this value to -1 to exclude the bone from the transform matrices
  9770. */
  9771. _this._index = null;
  9772. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9773. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9774. _this._scalingDeterminant = 1;
  9775. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9776. _this._needToDecompose = true;
  9777. _this._needToCompose = false;
  9778. /** @hidden */
  9779. _this._linkedTransformNode = null;
  9780. _this._skeleton = skeleton;
  9781. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9782. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9783. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9784. _this._index = index;
  9785. skeleton.bones.push(_this);
  9786. _this.setParent(parentBone, false);
  9787. if (baseMatrix || localMatrix) {
  9788. _this._updateDifferenceMatrix();
  9789. }
  9790. return _this;
  9791. }
  9792. Object.defineProperty(Bone.prototype, "_matrix", {
  9793. /** @hidden */
  9794. get: function () {
  9795. this._compose();
  9796. return this._localMatrix;
  9797. },
  9798. /** @hidden */
  9799. set: function (value) {
  9800. this._localMatrix.copyFrom(value);
  9801. this._needToDecompose = true;
  9802. },
  9803. enumerable: true,
  9804. configurable: true
  9805. });
  9806. // Members
  9807. /**
  9808. * Gets the parent skeleton
  9809. * @returns a skeleton
  9810. */
  9811. Bone.prototype.getSkeleton = function () {
  9812. return this._skeleton;
  9813. };
  9814. /**
  9815. * Gets parent bone
  9816. * @returns a bone or null if the bone is the root of the bone hierarchy
  9817. */
  9818. Bone.prototype.getParent = function () {
  9819. return this._parent;
  9820. };
  9821. /**
  9822. * Sets the parent bone
  9823. * @param parent defines the parent (can be null if the bone is the root)
  9824. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9825. */
  9826. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9827. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9828. if (this._parent === parent) {
  9829. return;
  9830. }
  9831. if (this._parent) {
  9832. var index = this._parent.children.indexOf(this);
  9833. if (index !== -1) {
  9834. this._parent.children.splice(index, 1);
  9835. }
  9836. }
  9837. this._parent = parent;
  9838. if (this._parent) {
  9839. this._parent.children.push(this);
  9840. }
  9841. if (updateDifferenceMatrix) {
  9842. this._updateDifferenceMatrix();
  9843. }
  9844. this.markAsDirty();
  9845. };
  9846. /**
  9847. * Gets the local matrix
  9848. * @returns a matrix
  9849. */
  9850. Bone.prototype.getLocalMatrix = function () {
  9851. this._compose();
  9852. return this._localMatrix;
  9853. };
  9854. /**
  9855. * Gets the base matrix (initial matrix which remains unchanged)
  9856. * @returns a matrix
  9857. */
  9858. Bone.prototype.getBaseMatrix = function () {
  9859. return this._baseMatrix;
  9860. };
  9861. /**
  9862. * Gets the rest pose matrix
  9863. * @returns a matrix
  9864. */
  9865. Bone.prototype.getRestPose = function () {
  9866. return this._restPose;
  9867. };
  9868. /**
  9869. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9870. */
  9871. Bone.prototype.getWorldMatrix = function () {
  9872. return this._worldTransform;
  9873. };
  9874. /**
  9875. * Sets the local matrix to rest pose matrix
  9876. */
  9877. Bone.prototype.returnToRest = function () {
  9878. this.updateMatrix(this._restPose.clone());
  9879. };
  9880. /**
  9881. * Gets the inverse of the absolute transform matrix.
  9882. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9883. * @returns a matrix
  9884. */
  9885. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9886. return this._invertedAbsoluteTransform;
  9887. };
  9888. /**
  9889. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9890. * @returns a matrix
  9891. */
  9892. Bone.prototype.getAbsoluteTransform = function () {
  9893. return this._absoluteTransform;
  9894. };
  9895. /**
  9896. * Links with the given transform node.
  9897. * The local matrix of this bone is copied from the transform node every frame.
  9898. * @param transformNode defines the transform node to link to
  9899. */
  9900. Bone.prototype.linkTransformNode = function (transformNode) {
  9901. if (this._linkedTransformNode) {
  9902. this._skeleton._numBonesWithLinkedTransformNode--;
  9903. }
  9904. this._linkedTransformNode = transformNode;
  9905. if (this._linkedTransformNode) {
  9906. this._skeleton._numBonesWithLinkedTransformNode++;
  9907. }
  9908. };
  9909. Object.defineProperty(Bone.prototype, "position", {
  9910. // Properties (matches AbstractMesh properties)
  9911. /** Gets or sets current position (in local space) */
  9912. get: function () {
  9913. this._decompose();
  9914. return this._localPosition;
  9915. },
  9916. set: function (newPosition) {
  9917. this._decompose();
  9918. this._localPosition.copyFrom(newPosition);
  9919. this._markAsDirtyAndCompose();
  9920. },
  9921. enumerable: true,
  9922. configurable: true
  9923. });
  9924. Object.defineProperty(Bone.prototype, "rotation", {
  9925. /** Gets or sets current rotation (in local space) */
  9926. get: function () {
  9927. return this.getRotation();
  9928. },
  9929. set: function (newRotation) {
  9930. this.setRotation(newRotation);
  9931. },
  9932. enumerable: true,
  9933. configurable: true
  9934. });
  9935. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9936. /** Gets or sets current rotation quaternion (in local space) */
  9937. get: function () {
  9938. this._decompose();
  9939. return this._localRotation;
  9940. },
  9941. set: function (newRotation) {
  9942. this.setRotationQuaternion(newRotation);
  9943. },
  9944. enumerable: true,
  9945. configurable: true
  9946. });
  9947. Object.defineProperty(Bone.prototype, "scaling", {
  9948. /** Gets or sets current scaling (in local space) */
  9949. get: function () {
  9950. return this.getScale();
  9951. },
  9952. set: function (newScaling) {
  9953. this.setScale(newScaling);
  9954. },
  9955. enumerable: true,
  9956. configurable: true
  9957. });
  9958. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9959. /**
  9960. * Gets the animation properties override
  9961. */
  9962. get: function () {
  9963. return this._skeleton.animationPropertiesOverride;
  9964. },
  9965. enumerable: true,
  9966. configurable: true
  9967. });
  9968. // Methods
  9969. Bone.prototype._decompose = function () {
  9970. if (!this._needToDecompose) {
  9971. return;
  9972. }
  9973. this._needToDecompose = false;
  9974. if (!this._localScaling) {
  9975. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9976. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9977. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9978. }
  9979. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9980. };
  9981. Bone.prototype._compose = function () {
  9982. if (!this._needToCompose) {
  9983. return;
  9984. }
  9985. this._needToCompose = false;
  9986. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9987. };
  9988. /**
  9989. * Update the base and local matrices
  9990. * @param matrix defines the new base or local matrix
  9991. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9992. * @param updateLocalMatrix defines if the local matrix should be updated
  9993. */
  9994. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9995. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9996. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9997. this._baseMatrix.copyFrom(matrix);
  9998. if (updateDifferenceMatrix) {
  9999. this._updateDifferenceMatrix();
  10000. }
  10001. if (updateLocalMatrix) {
  10002. this._localMatrix.copyFrom(matrix);
  10003. this._markAsDirtyAndDecompose();
  10004. }
  10005. else {
  10006. this.markAsDirty();
  10007. }
  10008. };
  10009. /** @hidden */
  10010. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10011. if (updateChildren === void 0) { updateChildren = true; }
  10012. if (!rootMatrix) {
  10013. rootMatrix = this._baseMatrix;
  10014. }
  10015. if (this._parent) {
  10016. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10017. }
  10018. else {
  10019. this._absoluteTransform.copyFrom(rootMatrix);
  10020. }
  10021. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10022. if (updateChildren) {
  10023. for (var index = 0; index < this.children.length; index++) {
  10024. this.children[index]._updateDifferenceMatrix();
  10025. }
  10026. }
  10027. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10028. };
  10029. /**
  10030. * Flag the bone as dirty (Forcing it to update everything)
  10031. */
  10032. Bone.prototype.markAsDirty = function () {
  10033. this._currentRenderId++;
  10034. this._childRenderId++;
  10035. this._skeleton._markAsDirty();
  10036. };
  10037. Bone.prototype._markAsDirtyAndCompose = function () {
  10038. this.markAsDirty();
  10039. this._needToCompose = true;
  10040. };
  10041. Bone.prototype._markAsDirtyAndDecompose = function () {
  10042. this.markAsDirty();
  10043. this._needToDecompose = true;
  10044. };
  10045. /**
  10046. * Translate the bone in local or world space
  10047. * @param vec The amount to translate the bone
  10048. * @param space The space that the translation is in
  10049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10050. */
  10051. Bone.prototype.translate = function (vec, space, mesh) {
  10052. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10053. var lm = this.getLocalMatrix();
  10054. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10055. lm.addAtIndex(12, vec.x);
  10056. lm.addAtIndex(13, vec.y);
  10057. lm.addAtIndex(14, vec.z);
  10058. }
  10059. else {
  10060. var wm = null;
  10061. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10062. if (mesh) {
  10063. wm = mesh.getWorldMatrix();
  10064. }
  10065. this._skeleton.computeAbsoluteTransforms();
  10066. var tmat = Bone._tmpMats[0];
  10067. var tvec = Bone._tmpVecs[0];
  10068. if (this._parent) {
  10069. if (mesh && wm) {
  10070. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10071. tmat.multiplyToRef(wm, tmat);
  10072. }
  10073. else {
  10074. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10075. }
  10076. }
  10077. tmat.setTranslationFromFloats(0, 0, 0);
  10078. tmat.invert();
  10079. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10080. lm.addAtIndex(12, tvec.x);
  10081. lm.addAtIndex(13, tvec.y);
  10082. lm.addAtIndex(14, tvec.z);
  10083. }
  10084. this._markAsDirtyAndDecompose();
  10085. };
  10086. /**
  10087. * Set the postion of the bone in local or world space
  10088. * @param position The position to set the bone
  10089. * @param space The space that the position is in
  10090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10091. */
  10092. Bone.prototype.setPosition = function (position, space, mesh) {
  10093. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10094. var lm = this.getLocalMatrix();
  10095. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10096. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10097. }
  10098. else {
  10099. var wm = null;
  10100. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10101. if (mesh) {
  10102. wm = mesh.getWorldMatrix();
  10103. }
  10104. this._skeleton.computeAbsoluteTransforms();
  10105. var tmat = Bone._tmpMats[0];
  10106. var vec = Bone._tmpVecs[0];
  10107. if (this._parent) {
  10108. if (mesh && wm) {
  10109. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10110. tmat.multiplyToRef(wm, tmat);
  10111. }
  10112. else {
  10113. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10114. }
  10115. }
  10116. tmat.invert();
  10117. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10118. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10119. }
  10120. this._markAsDirtyAndDecompose();
  10121. };
  10122. /**
  10123. * Set the absolute position of the bone (world space)
  10124. * @param position The position to set the bone
  10125. * @param mesh The mesh that this bone is attached to
  10126. */
  10127. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10128. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10129. };
  10130. /**
  10131. * Scale the bone on the x, y and z axes (in local space)
  10132. * @param x The amount to scale the bone on the x axis
  10133. * @param y The amount to scale the bone on the y axis
  10134. * @param z The amount to scale the bone on the z axis
  10135. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10136. */
  10137. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10138. if (scaleChildren === void 0) { scaleChildren = false; }
  10139. var locMat = this.getLocalMatrix();
  10140. // Apply new scaling on top of current local matrix
  10141. var scaleMat = Bone._tmpMats[0];
  10142. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10143. scaleMat.multiplyToRef(locMat, locMat);
  10144. // Invert scaling matrix and apply the inverse to all children
  10145. scaleMat.invert();
  10146. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10147. var child = _a[_i];
  10148. var cm = child.getLocalMatrix();
  10149. cm.multiplyToRef(scaleMat, cm);
  10150. cm.multiplyAtIndex(12, x);
  10151. cm.multiplyAtIndex(13, y);
  10152. cm.multiplyAtIndex(14, z);
  10153. child._markAsDirtyAndDecompose();
  10154. }
  10155. this._markAsDirtyAndDecompose();
  10156. if (scaleChildren) {
  10157. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10158. var child = _c[_b];
  10159. child.scale(x, y, z, scaleChildren);
  10160. }
  10161. }
  10162. };
  10163. /**
  10164. * Set the bone scaling in local space
  10165. * @param scale defines the scaling vector
  10166. */
  10167. Bone.prototype.setScale = function (scale) {
  10168. this._decompose();
  10169. this._localScaling.copyFrom(scale);
  10170. this._markAsDirtyAndCompose();
  10171. };
  10172. /**
  10173. * Gets the current scaling in local space
  10174. * @returns the current scaling vector
  10175. */
  10176. Bone.prototype.getScale = function () {
  10177. this._decompose();
  10178. return this._localScaling;
  10179. };
  10180. /**
  10181. * Gets the current scaling in local space and stores it in a target vector
  10182. * @param result defines the target vector
  10183. */
  10184. Bone.prototype.getScaleToRef = function (result) {
  10185. this._decompose();
  10186. result.copyFrom(this._localScaling);
  10187. };
  10188. /**
  10189. * Set the yaw, pitch, and roll of the bone in local or world space
  10190. * @param yaw The rotation of the bone on the y axis
  10191. * @param pitch The rotation of the bone on the x axis
  10192. * @param roll The rotation of the bone on the z axis
  10193. * @param space The space that the axes of rotation are in
  10194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10195. */
  10196. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10197. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10198. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10199. var quat = Bone._tmpQuat;
  10200. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10201. this.setRotationQuaternion(quat, space, mesh);
  10202. return;
  10203. }
  10204. var rotMatInv = Bone._tmpMats[0];
  10205. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10206. return;
  10207. }
  10208. var rotMat = Bone._tmpMats[1];
  10209. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10210. rotMatInv.multiplyToRef(rotMat, rotMat);
  10211. this._rotateWithMatrix(rotMat, space, mesh);
  10212. };
  10213. /**
  10214. * Add a rotation to the bone on an axis in local or world space
  10215. * @param axis The axis to rotate the bone on
  10216. * @param amount The amount to rotate the bone
  10217. * @param space The space that the axis is in
  10218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10219. */
  10220. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10221. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10222. var rmat = Bone._tmpMats[0];
  10223. rmat.setTranslationFromFloats(0, 0, 0);
  10224. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10225. this._rotateWithMatrix(rmat, space, mesh);
  10226. };
  10227. /**
  10228. * Set the rotation of the bone to a particular axis angle in local or world space
  10229. * @param axis The axis to rotate the bone on
  10230. * @param angle The angle that the bone should be rotated to
  10231. * @param space The space that the axis is in
  10232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10233. */
  10234. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10235. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10236. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10237. var quat = Bone._tmpQuat;
  10238. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10239. this.setRotationQuaternion(quat, space, mesh);
  10240. return;
  10241. }
  10242. var rotMatInv = Bone._tmpMats[0];
  10243. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10244. return;
  10245. }
  10246. var rotMat = Bone._tmpMats[1];
  10247. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10248. rotMatInv.multiplyToRef(rotMat, rotMat);
  10249. this._rotateWithMatrix(rotMat, space, mesh);
  10250. };
  10251. /**
  10252. * Set the euler rotation of the bone in local of world space
  10253. * @param rotation The euler rotation that the bone should be set to
  10254. * @param space The space that the rotation is in
  10255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10256. */
  10257. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10258. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10259. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10260. };
  10261. /**
  10262. * Set the quaternion rotation of the bone in local of world space
  10263. * @param quat The quaternion rotation that the bone should be set to
  10264. * @param space The space that the rotation is in
  10265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10266. */
  10267. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10268. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10269. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10270. this._decompose();
  10271. this._localRotation.copyFrom(quat);
  10272. this._markAsDirtyAndCompose();
  10273. return;
  10274. }
  10275. var rotMatInv = Bone._tmpMats[0];
  10276. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10277. return;
  10278. }
  10279. var rotMat = Bone._tmpMats[1];
  10280. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10281. rotMatInv.multiplyToRef(rotMat, rotMat);
  10282. this._rotateWithMatrix(rotMat, space, mesh);
  10283. };
  10284. /**
  10285. * Set the rotation matrix of the bone in local of world space
  10286. * @param rotMat The rotation matrix that the bone should be set to
  10287. * @param space The space that the rotation is in
  10288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10289. */
  10290. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10291. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10292. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10293. var quat = Bone._tmpQuat;
  10294. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10295. this.setRotationQuaternion(quat, space, mesh);
  10296. return;
  10297. }
  10298. var rotMatInv = Bone._tmpMats[0];
  10299. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10300. return;
  10301. }
  10302. var rotMat2 = Bone._tmpMats[1];
  10303. rotMat2.copyFrom(rotMat);
  10304. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10305. this._rotateWithMatrix(rotMat2, space, mesh);
  10306. };
  10307. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10308. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10309. var lmat = this.getLocalMatrix();
  10310. var lx = lmat.m[12];
  10311. var ly = lmat.m[13];
  10312. var lz = lmat.m[14];
  10313. var parent = this.getParent();
  10314. var parentScale = Bone._tmpMats[3];
  10315. var parentScaleInv = Bone._tmpMats[4];
  10316. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10317. if (mesh) {
  10318. parentScale.copyFrom(mesh.getWorldMatrix());
  10319. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10320. }
  10321. else {
  10322. parentScale.copyFrom(parent.getAbsoluteTransform());
  10323. }
  10324. parentScaleInv.copyFrom(parentScale);
  10325. parentScaleInv.invert();
  10326. lmat.multiplyToRef(parentScale, lmat);
  10327. lmat.multiplyToRef(rmat, lmat);
  10328. lmat.multiplyToRef(parentScaleInv, lmat);
  10329. }
  10330. else {
  10331. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10332. parentScale.copyFrom(mesh.getWorldMatrix());
  10333. parentScaleInv.copyFrom(parentScale);
  10334. parentScaleInv.invert();
  10335. lmat.multiplyToRef(parentScale, lmat);
  10336. lmat.multiplyToRef(rmat, lmat);
  10337. lmat.multiplyToRef(parentScaleInv, lmat);
  10338. }
  10339. else {
  10340. lmat.multiplyToRef(rmat, lmat);
  10341. }
  10342. }
  10343. lmat.setTranslationFromFloats(lx, ly, lz);
  10344. this.computeAbsoluteTransforms();
  10345. this._markAsDirtyAndDecompose();
  10346. };
  10347. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10348. var scaleMatrix = Bone._tmpMats[2];
  10349. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10350. if (mesh) {
  10351. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10352. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10353. }
  10354. rotMatInv.invert();
  10355. if (isNaN(rotMatInv.m[0])) {
  10356. // Matrix failed to invert.
  10357. // This can happen if scale is zero for example.
  10358. return false;
  10359. }
  10360. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10361. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10362. return true;
  10363. };
  10364. /**
  10365. * Get the position of the bone in local or world space
  10366. * @param space The space that the returned position is in
  10367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10368. * @returns The position of the bone
  10369. */
  10370. Bone.prototype.getPosition = function (space, mesh) {
  10371. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10372. if (mesh === void 0) { mesh = null; }
  10373. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10374. this.getPositionToRef(space, mesh, pos);
  10375. return pos;
  10376. };
  10377. /**
  10378. * Copy the position of the bone to a vector3 in local or world space
  10379. * @param space The space that the returned position is in
  10380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10381. * @param result The vector3 to copy the position to
  10382. */
  10383. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10384. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10385. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10386. var lm = this.getLocalMatrix();
  10387. result.x = lm.m[12];
  10388. result.y = lm.m[13];
  10389. result.z = lm.m[14];
  10390. }
  10391. else {
  10392. var wm = null;
  10393. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10394. if (mesh) {
  10395. wm = mesh.getWorldMatrix();
  10396. }
  10397. this._skeleton.computeAbsoluteTransforms();
  10398. var tmat = Bone._tmpMats[0];
  10399. if (mesh && wm) {
  10400. tmat.copyFrom(this.getAbsoluteTransform());
  10401. tmat.multiplyToRef(wm, tmat);
  10402. }
  10403. else {
  10404. tmat = this.getAbsoluteTransform();
  10405. }
  10406. result.x = tmat.m[12];
  10407. result.y = tmat.m[13];
  10408. result.z = tmat.m[14];
  10409. }
  10410. };
  10411. /**
  10412. * Get the absolute position of the bone (world space)
  10413. * @param mesh The mesh that this bone is attached to
  10414. * @returns The absolute position of the bone
  10415. */
  10416. Bone.prototype.getAbsolutePosition = function (mesh) {
  10417. if (mesh === void 0) { mesh = null; }
  10418. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10419. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10420. return pos;
  10421. };
  10422. /**
  10423. * Copy the absolute position of the bone (world space) to the result param
  10424. * @param mesh The mesh that this bone is attached to
  10425. * @param result The vector3 to copy the absolute position to
  10426. */
  10427. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10428. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10429. };
  10430. /**
  10431. * Compute the absolute transforms of this bone and its children
  10432. */
  10433. Bone.prototype.computeAbsoluteTransforms = function () {
  10434. this._compose();
  10435. if (this._parent) {
  10436. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10437. }
  10438. else {
  10439. this._absoluteTransform.copyFrom(this._localMatrix);
  10440. var poseMatrix = this._skeleton.getPoseMatrix();
  10441. if (poseMatrix) {
  10442. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10443. }
  10444. }
  10445. var children = this.children;
  10446. var len = children.length;
  10447. for (var i = 0; i < len; i++) {
  10448. children[i].computeAbsoluteTransforms();
  10449. }
  10450. };
  10451. /**
  10452. * Get the world direction from an axis that is in the local space of the bone
  10453. * @param localAxis The local direction that is used to compute the world direction
  10454. * @param mesh The mesh that this bone is attached to
  10455. * @returns The world direction
  10456. */
  10457. Bone.prototype.getDirection = function (localAxis, mesh) {
  10458. if (mesh === void 0) { mesh = null; }
  10459. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10460. this.getDirectionToRef(localAxis, mesh, result);
  10461. return result;
  10462. };
  10463. /**
  10464. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10465. * @param localAxis The local direction that is used to compute the world direction
  10466. * @param mesh The mesh that this bone is attached to
  10467. * @param result The vector3 that the world direction will be copied to
  10468. */
  10469. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10470. if (mesh === void 0) { mesh = null; }
  10471. var wm = null;
  10472. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10473. if (mesh) {
  10474. wm = mesh.getWorldMatrix();
  10475. }
  10476. this._skeleton.computeAbsoluteTransforms();
  10477. var mat = Bone._tmpMats[0];
  10478. mat.copyFrom(this.getAbsoluteTransform());
  10479. if (mesh && wm) {
  10480. mat.multiplyToRef(wm, mat);
  10481. }
  10482. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10483. result.normalize();
  10484. };
  10485. /**
  10486. * Get the euler rotation of the bone in local or world space
  10487. * @param space The space that the rotation should be in
  10488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10489. * @returns The euler rotation
  10490. */
  10491. Bone.prototype.getRotation = function (space, mesh) {
  10492. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10493. if (mesh === void 0) { mesh = null; }
  10494. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10495. this.getRotationToRef(space, mesh, result);
  10496. return result;
  10497. };
  10498. /**
  10499. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10500. * @param space The space that the rotation should be in
  10501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10502. * @param result The vector3 that the rotation should be copied to
  10503. */
  10504. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10505. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10506. if (mesh === void 0) { mesh = null; }
  10507. var quat = Bone._tmpQuat;
  10508. this.getRotationQuaternionToRef(space, mesh, quat);
  10509. quat.toEulerAnglesToRef(result);
  10510. };
  10511. /**
  10512. * Get the quaternion rotation of the bone in either local or world space
  10513. * @param space The space that the rotation should be in
  10514. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10515. * @returns The quaternion rotation
  10516. */
  10517. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10518. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10519. if (mesh === void 0) { mesh = null; }
  10520. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10521. this.getRotationQuaternionToRef(space, mesh, result);
  10522. return result;
  10523. };
  10524. /**
  10525. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10526. * @param space The space that the rotation should be in
  10527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10528. * @param result The quaternion that the rotation should be copied to
  10529. */
  10530. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10531. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10532. if (mesh === void 0) { mesh = null; }
  10533. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10534. this._decompose();
  10535. result.copyFrom(this._localRotation);
  10536. }
  10537. else {
  10538. var mat = Bone._tmpMats[0];
  10539. var amat = this.getAbsoluteTransform();
  10540. if (mesh) {
  10541. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10542. }
  10543. else {
  10544. mat.copyFrom(amat);
  10545. }
  10546. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10547. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10548. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10549. mat.decompose(undefined, result, undefined);
  10550. }
  10551. };
  10552. /**
  10553. * Get the rotation matrix of the bone in local or world space
  10554. * @param space The space that the rotation should be in
  10555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10556. * @returns The rotation matrix
  10557. */
  10558. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10559. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10560. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10561. this.getRotationMatrixToRef(space, mesh, result);
  10562. return result;
  10563. };
  10564. /**
  10565. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10566. * @param space The space that the rotation should be in
  10567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10568. * @param result The quaternion that the rotation should be copied to
  10569. */
  10570. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10571. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10572. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10573. this.getLocalMatrix().getRotationMatrixToRef(result);
  10574. }
  10575. else {
  10576. var mat = Bone._tmpMats[0];
  10577. var amat = this.getAbsoluteTransform();
  10578. if (mesh) {
  10579. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10580. }
  10581. else {
  10582. mat.copyFrom(amat);
  10583. }
  10584. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10585. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10586. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10587. mat.getRotationMatrixToRef(result);
  10588. }
  10589. };
  10590. /**
  10591. * Get the world position of a point that is in the local space of the bone
  10592. * @param position The local position
  10593. * @param mesh The mesh that this bone is attached to
  10594. * @returns The world position
  10595. */
  10596. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10597. if (mesh === void 0) { mesh = null; }
  10598. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10599. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10600. return result;
  10601. };
  10602. /**
  10603. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10604. * @param position The local position
  10605. * @param mesh The mesh that this bone is attached to
  10606. * @param result The vector3 that the world position should be copied to
  10607. */
  10608. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10609. if (mesh === void 0) { mesh = null; }
  10610. var wm = null;
  10611. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10612. if (mesh) {
  10613. wm = mesh.getWorldMatrix();
  10614. }
  10615. this._skeleton.computeAbsoluteTransforms();
  10616. var tmat = Bone._tmpMats[0];
  10617. if (mesh && wm) {
  10618. tmat.copyFrom(this.getAbsoluteTransform());
  10619. tmat.multiplyToRef(wm, tmat);
  10620. }
  10621. else {
  10622. tmat = this.getAbsoluteTransform();
  10623. }
  10624. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10625. };
  10626. /**
  10627. * Get the local position of a point that is in world space
  10628. * @param position The world position
  10629. * @param mesh The mesh that this bone is attached to
  10630. * @returns The local position
  10631. */
  10632. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10633. if (mesh === void 0) { mesh = null; }
  10634. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10635. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10636. return result;
  10637. };
  10638. /**
  10639. * Get the local position of a point that is in world space and copy it to the result param
  10640. * @param position The world position
  10641. * @param mesh The mesh that this bone is attached to
  10642. * @param result The vector3 that the local position should be copied to
  10643. */
  10644. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10645. if (mesh === void 0) { mesh = null; }
  10646. var wm = null;
  10647. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10648. if (mesh) {
  10649. wm = mesh.getWorldMatrix();
  10650. }
  10651. this._skeleton.computeAbsoluteTransforms();
  10652. var tmat = Bone._tmpMats[0];
  10653. tmat.copyFrom(this.getAbsoluteTransform());
  10654. if (mesh && wm) {
  10655. tmat.multiplyToRef(wm, tmat);
  10656. }
  10657. tmat.invert();
  10658. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10659. };
  10660. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10661. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10662. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10663. return Bone;
  10664. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10665. /***/ }),
  10666. /***/ "./Bones/boneIKController.ts":
  10667. /*!***********************************!*\
  10668. !*** ./Bones/boneIKController.ts ***!
  10669. \***********************************/
  10670. /*! exports provided: BoneIKController */
  10671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10672. "use strict";
  10673. __webpack_require__.r(__webpack_exports__);
  10674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10675. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10676. /**
  10677. * Class used to apply inverse kinematics to bones
  10678. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10679. */
  10680. var BoneIKController = /** @class */ (function () {
  10681. /**
  10682. * Creates a new BoneIKController
  10683. * @param mesh defines the mesh to control
  10684. * @param bone defines the bone to control
  10685. * @param options defines options to set up the controller
  10686. */
  10687. function BoneIKController(mesh, bone, options) {
  10688. /**
  10689. * Gets or sets the target position
  10690. */
  10691. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10692. /**
  10693. * Gets or sets the pole target position
  10694. */
  10695. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10696. /**
  10697. * Gets or sets the pole target local offset
  10698. */
  10699. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10700. /**
  10701. * Gets or sets the pole angle
  10702. */
  10703. this.poleAngle = 0;
  10704. /**
  10705. * 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)
  10706. */
  10707. this.slerpAmount = 1;
  10708. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10709. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10710. this._bone2Ang = Math.PI;
  10711. this._maxAngle = Math.PI;
  10712. this._rightHandedSystem = false;
  10713. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10714. this._slerping = false;
  10715. this._adjustRoll = 0;
  10716. this._bone2 = bone;
  10717. this._bone1 = bone.getParent();
  10718. if (!this._bone1) {
  10719. return;
  10720. }
  10721. this.mesh = mesh;
  10722. var bonePos = bone.getPosition();
  10723. if (bone.getAbsoluteTransform().determinant() > 0) {
  10724. this._rightHandedSystem = true;
  10725. this._bendAxis.x = 0;
  10726. this._bendAxis.y = 0;
  10727. this._bendAxis.z = -1;
  10728. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10729. this._adjustRoll = Math.PI * .5;
  10730. this._bendAxis.z = 1;
  10731. }
  10732. }
  10733. if (this._bone1.length) {
  10734. var boneScale1 = this._bone1.getScale();
  10735. var boneScale2 = this._bone2.getScale();
  10736. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10737. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10738. }
  10739. else if (this._bone1.children[0]) {
  10740. mesh.computeWorldMatrix(true);
  10741. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10742. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10743. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10744. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10745. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10746. }
  10747. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10748. this.maxAngle = Math.PI;
  10749. if (options) {
  10750. if (options.targetMesh) {
  10751. this.targetMesh = options.targetMesh;
  10752. this.targetMesh.computeWorldMatrix(true);
  10753. }
  10754. if (options.poleTargetMesh) {
  10755. this.poleTargetMesh = options.poleTargetMesh;
  10756. this.poleTargetMesh.computeWorldMatrix(true);
  10757. }
  10758. else if (options.poleTargetBone) {
  10759. this.poleTargetBone = options.poleTargetBone;
  10760. }
  10761. else if (this._bone1.getParent()) {
  10762. this.poleTargetBone = this._bone1.getParent();
  10763. }
  10764. if (options.poleTargetLocalOffset) {
  10765. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10766. }
  10767. if (options.poleAngle) {
  10768. this.poleAngle = options.poleAngle;
  10769. }
  10770. if (options.bendAxis) {
  10771. this._bendAxis.copyFrom(options.bendAxis);
  10772. }
  10773. if (options.maxAngle) {
  10774. this.maxAngle = options.maxAngle;
  10775. }
  10776. if (options.slerpAmount) {
  10777. this.slerpAmount = options.slerpAmount;
  10778. }
  10779. }
  10780. }
  10781. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10782. /**
  10783. * Gets or sets maximum allowed angle
  10784. */
  10785. get: function () {
  10786. return this._maxAngle;
  10787. },
  10788. set: function (value) {
  10789. this._setMaxAngle(value);
  10790. },
  10791. enumerable: true,
  10792. configurable: true
  10793. });
  10794. BoneIKController.prototype._setMaxAngle = function (ang) {
  10795. if (ang < 0) {
  10796. ang = 0;
  10797. }
  10798. if (ang > Math.PI || ang == undefined) {
  10799. ang = Math.PI;
  10800. }
  10801. this._maxAngle = ang;
  10802. var a = this._bone1Length;
  10803. var b = this._bone2Length;
  10804. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10805. };
  10806. /**
  10807. * Force the controller to update the bones
  10808. */
  10809. BoneIKController.prototype.update = function () {
  10810. var bone1 = this._bone1;
  10811. if (!bone1) {
  10812. return;
  10813. }
  10814. var target = this.targetPosition;
  10815. var poleTarget = this.poleTargetPosition;
  10816. var mat1 = BoneIKController._tmpMats[0];
  10817. var mat2 = BoneIKController._tmpMats[1];
  10818. if (this.targetMesh) {
  10819. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10820. }
  10821. if (this.poleTargetBone) {
  10822. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10823. }
  10824. else if (this.poleTargetMesh) {
  10825. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10826. }
  10827. var bonePos = BoneIKController._tmpVecs[0];
  10828. var zaxis = BoneIKController._tmpVecs[1];
  10829. var xaxis = BoneIKController._tmpVecs[2];
  10830. var yaxis = BoneIKController._tmpVecs[3];
  10831. var upAxis = BoneIKController._tmpVecs[4];
  10832. var _tmpQuat = BoneIKController._tmpQuat;
  10833. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10834. poleTarget.subtractToRef(bonePos, upAxis);
  10835. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10836. upAxis.y = 1;
  10837. }
  10838. else {
  10839. upAxis.normalize();
  10840. }
  10841. target.subtractToRef(bonePos, yaxis);
  10842. yaxis.normalize();
  10843. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10844. zaxis.normalize();
  10845. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10846. xaxis.normalize();
  10847. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10848. var a = this._bone1Length;
  10849. var b = this._bone2Length;
  10850. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10851. if (this._maxReach > 0) {
  10852. c = Math.min(this._maxReach, c);
  10853. }
  10854. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10855. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10856. if (acosa > 1) {
  10857. acosa = 1;
  10858. }
  10859. if (acosb > 1) {
  10860. acosb = 1;
  10861. }
  10862. if (acosa < -1) {
  10863. acosa = -1;
  10864. }
  10865. if (acosb < -1) {
  10866. acosb = -1;
  10867. }
  10868. var angA = Math.acos(acosa);
  10869. var angB = Math.acos(acosb);
  10870. var angC = -angA - angB;
  10871. if (this._rightHandedSystem) {
  10872. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10873. mat2.multiplyToRef(mat1, mat1);
  10874. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10875. mat2.multiplyToRef(mat1, mat1);
  10876. }
  10877. else {
  10878. var _tmpVec = BoneIKController._tmpVecs[5];
  10879. _tmpVec.copyFrom(this._bendAxis);
  10880. _tmpVec.x *= -1;
  10881. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10882. mat2.multiplyToRef(mat1, mat1);
  10883. }
  10884. if (this.poleAngle) {
  10885. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10886. mat1.multiplyToRef(mat2, mat1);
  10887. }
  10888. if (this._bone1) {
  10889. if (this.slerpAmount < 1) {
  10890. if (!this._slerping) {
  10891. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10892. }
  10893. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10894. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10895. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10896. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10897. this._slerping = true;
  10898. }
  10899. else {
  10900. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10901. this._bone1Mat.copyFrom(mat1);
  10902. this._slerping = false;
  10903. }
  10904. }
  10905. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10906. this._bone2Ang = angC;
  10907. };
  10908. 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()];
  10909. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10910. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10911. return BoneIKController;
  10912. }());
  10913. /***/ }),
  10914. /***/ "./Bones/boneLookController.ts":
  10915. /*!*************************************!*\
  10916. !*** ./Bones/boneLookController.ts ***!
  10917. \*************************************/
  10918. /*! exports provided: BoneLookController */
  10919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10920. "use strict";
  10921. __webpack_require__.r(__webpack_exports__);
  10922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10923. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10924. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10925. /**
  10926. * Class used to make a bone look toward a point in space
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10928. */
  10929. var BoneLookController = /** @class */ (function () {
  10930. /**
  10931. * Create a BoneLookController
  10932. * @param mesh the mesh that the bone belongs to
  10933. * @param bone the bone that will be looking to the target
  10934. * @param target the target Vector3 to look at
  10935. * @param options optional settings:
  10936. * * maxYaw: the maximum angle the bone will yaw to
  10937. * * minYaw: the minimum angle the bone will yaw to
  10938. * * maxPitch: the maximum angle the bone will pitch to
  10939. * * minPitch: the minimum angle the bone will yaw to
  10940. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10941. * * upAxis: the up axis of the coordinate system
  10942. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10943. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10944. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10945. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10946. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10947. * * adjustRoll: used to make an adjustment to the roll of the bone
  10948. **/
  10949. function BoneLookController(mesh, bone, target, options) {
  10950. /**
  10951. * The up axis of the coordinate system that is used when the bone is rotated
  10952. */
  10953. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10954. /**
  10955. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10956. */
  10957. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10958. /**
  10959. * Used to make an adjustment to the yaw of the bone
  10960. */
  10961. this.adjustYaw = 0;
  10962. /**
  10963. * Used to make an adjustment to the pitch of the bone
  10964. */
  10965. this.adjustPitch = 0;
  10966. /**
  10967. * Used to make an adjustment to the roll of the bone
  10968. */
  10969. this.adjustRoll = 0;
  10970. /**
  10971. * 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)
  10972. */
  10973. this.slerpAmount = 1;
  10974. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10975. this._slerping = false;
  10976. this._firstFrameSkipped = false;
  10977. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10978. this.mesh = mesh;
  10979. this.bone = bone;
  10980. this.target = target;
  10981. if (options) {
  10982. if (options.adjustYaw) {
  10983. this.adjustYaw = options.adjustYaw;
  10984. }
  10985. if (options.adjustPitch) {
  10986. this.adjustPitch = options.adjustPitch;
  10987. }
  10988. if (options.adjustRoll) {
  10989. this.adjustRoll = options.adjustRoll;
  10990. }
  10991. if (options.maxYaw != null) {
  10992. this.maxYaw = options.maxYaw;
  10993. }
  10994. else {
  10995. this.maxYaw = Math.PI;
  10996. }
  10997. if (options.minYaw != null) {
  10998. this.minYaw = options.minYaw;
  10999. }
  11000. else {
  11001. this.minYaw = -Math.PI;
  11002. }
  11003. if (options.maxPitch != null) {
  11004. this.maxPitch = options.maxPitch;
  11005. }
  11006. else {
  11007. this.maxPitch = Math.PI;
  11008. }
  11009. if (options.minPitch != null) {
  11010. this.minPitch = options.minPitch;
  11011. }
  11012. else {
  11013. this.minPitch = -Math.PI;
  11014. }
  11015. if (options.slerpAmount != null) {
  11016. this.slerpAmount = options.slerpAmount;
  11017. }
  11018. if (options.upAxis != null) {
  11019. this.upAxis = options.upAxis;
  11020. }
  11021. if (options.upAxisSpace != null) {
  11022. this.upAxisSpace = options.upAxisSpace;
  11023. }
  11024. if (options.yawAxis != null || options.pitchAxis != null) {
  11025. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11026. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11027. if (options.yawAxis != null) {
  11028. newYawAxis = options.yawAxis.clone();
  11029. newYawAxis.normalize();
  11030. }
  11031. if (options.pitchAxis != null) {
  11032. newPitchAxis = options.pitchAxis.clone();
  11033. newPitchAxis.normalize();
  11034. }
  11035. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11036. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11037. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11038. this._transformYawPitchInv = this._transformYawPitch.clone();
  11039. this._transformYawPitch.invert();
  11040. }
  11041. }
  11042. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11043. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11044. }
  11045. }
  11046. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11047. /**
  11048. * Gets or sets the minimum yaw angle that the bone can look to
  11049. */
  11050. get: function () {
  11051. return this._minYaw;
  11052. },
  11053. set: function (value) {
  11054. this._minYaw = value;
  11055. this._minYawSin = Math.sin(value);
  11056. this._minYawCos = Math.cos(value);
  11057. if (this._maxYaw != null) {
  11058. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11059. this._yawRange = this._maxYaw - this._minYaw;
  11060. }
  11061. },
  11062. enumerable: true,
  11063. configurable: true
  11064. });
  11065. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11066. /**
  11067. * Gets or sets the maximum yaw angle that the bone can look to
  11068. */
  11069. get: function () {
  11070. return this._maxYaw;
  11071. },
  11072. set: function (value) {
  11073. this._maxYaw = value;
  11074. this._maxYawSin = Math.sin(value);
  11075. this._maxYawCos = Math.cos(value);
  11076. if (this._minYaw != null) {
  11077. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11078. this._yawRange = this._maxYaw - this._minYaw;
  11079. }
  11080. },
  11081. enumerable: true,
  11082. configurable: true
  11083. });
  11084. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11085. /**
  11086. * Gets or sets the minimum pitch angle that the bone can look to
  11087. */
  11088. get: function () {
  11089. return this._minPitch;
  11090. },
  11091. set: function (value) {
  11092. this._minPitch = value;
  11093. this._minPitchTan = Math.tan(value);
  11094. },
  11095. enumerable: true,
  11096. configurable: true
  11097. });
  11098. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11099. /**
  11100. * Gets or sets the maximum pitch angle that the bone can look to
  11101. */
  11102. get: function () {
  11103. return this._maxPitch;
  11104. },
  11105. set: function (value) {
  11106. this._maxPitch = value;
  11107. this._maxPitchTan = Math.tan(value);
  11108. },
  11109. enumerable: true,
  11110. configurable: true
  11111. });
  11112. /**
  11113. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11114. */
  11115. BoneLookController.prototype.update = function () {
  11116. //skip the first frame when slerping so that the mesh rotation is correct
  11117. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11118. this._firstFrameSkipped = true;
  11119. return;
  11120. }
  11121. var bone = this.bone;
  11122. var bonePos = BoneLookController._tmpVecs[0];
  11123. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11124. var target = this.target;
  11125. var _tmpMat1 = BoneLookController._tmpMats[0];
  11126. var _tmpMat2 = BoneLookController._tmpMats[1];
  11127. var mesh = this.mesh;
  11128. var parentBone = bone.getParent();
  11129. var upAxis = BoneLookController._tmpVecs[1];
  11130. upAxis.copyFrom(this.upAxis);
  11131. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11132. if (this._transformYawPitch) {
  11133. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11134. }
  11135. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11136. }
  11137. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11138. mesh.getDirectionToRef(upAxis, upAxis);
  11139. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11140. upAxis.normalize();
  11141. }
  11142. }
  11143. var checkYaw = false;
  11144. var checkPitch = false;
  11145. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11146. checkYaw = true;
  11147. }
  11148. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11149. checkPitch = true;
  11150. }
  11151. if (checkYaw || checkPitch) {
  11152. var spaceMat = BoneLookController._tmpMats[2];
  11153. var spaceMatInv = BoneLookController._tmpMats[3];
  11154. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11155. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11156. }
  11157. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11158. spaceMat.copyFrom(mesh.getWorldMatrix());
  11159. }
  11160. else {
  11161. var forwardAxis = BoneLookController._tmpVecs[2];
  11162. forwardAxis.copyFrom(this._fowardAxis);
  11163. if (this._transformYawPitch) {
  11164. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11165. }
  11166. if (parentBone) {
  11167. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11168. }
  11169. else {
  11170. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11171. }
  11172. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11173. rightAxis.normalize();
  11174. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11175. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11176. }
  11177. spaceMat.invertToRef(spaceMatInv);
  11178. var xzlen = null;
  11179. if (checkPitch) {
  11180. var localTarget = BoneLookController._tmpVecs[3];
  11181. target.subtractToRef(bonePos, localTarget);
  11182. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11183. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11184. var pitch = Math.atan2(localTarget.y, xzlen);
  11185. var newPitch = pitch;
  11186. if (pitch > this._maxPitch) {
  11187. localTarget.y = this._maxPitchTan * xzlen;
  11188. newPitch = this._maxPitch;
  11189. }
  11190. else if (pitch < this._minPitch) {
  11191. localTarget.y = this._minPitchTan * xzlen;
  11192. newPitch = this._minPitch;
  11193. }
  11194. if (pitch != newPitch) {
  11195. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11196. localTarget.addInPlace(bonePos);
  11197. target = localTarget;
  11198. }
  11199. }
  11200. if (checkYaw) {
  11201. var localTarget = BoneLookController._tmpVecs[4];
  11202. target.subtractToRef(bonePos, localTarget);
  11203. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11204. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11205. var newYaw = yaw;
  11206. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11207. if (xzlen == null) {
  11208. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11209. }
  11210. if (this._yawRange > Math.PI) {
  11211. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11212. localTarget.z = this._maxYawCos * xzlen;
  11213. localTarget.x = this._maxYawSin * xzlen;
  11214. newYaw = this._maxYaw;
  11215. }
  11216. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11217. localTarget.z = this._minYawCos * xzlen;
  11218. localTarget.x = this._minYawSin * xzlen;
  11219. newYaw = this._minYaw;
  11220. }
  11221. }
  11222. else {
  11223. if (yaw > this._maxYaw) {
  11224. localTarget.z = this._maxYawCos * xzlen;
  11225. localTarget.x = this._maxYawSin * xzlen;
  11226. newYaw = this._maxYaw;
  11227. }
  11228. else if (yaw < this._minYaw) {
  11229. localTarget.z = this._minYawCos * xzlen;
  11230. localTarget.x = this._minYawSin * xzlen;
  11231. newYaw = this._minYaw;
  11232. }
  11233. }
  11234. }
  11235. if (this._slerping && this._yawRange > Math.PI) {
  11236. //are we going to be crossing into the min/max region?
  11237. var boneFwd = BoneLookController._tmpVecs[8];
  11238. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11239. if (this._transformYawPitch) {
  11240. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11241. }
  11242. var boneRotMat = BoneLookController._tmpMats[4];
  11243. this._boneQuat.toRotationMatrix(boneRotMat);
  11244. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11245. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11246. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11247. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11248. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11249. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11250. if (angBtwTar > angBtwMidYaw) {
  11251. if (xzlen == null) {
  11252. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11253. }
  11254. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11255. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11256. if (angBtwMin < angBtwMax) {
  11257. newYaw = boneYaw + Math.PI * .75;
  11258. localTarget.z = Math.cos(newYaw) * xzlen;
  11259. localTarget.x = Math.sin(newYaw) * xzlen;
  11260. }
  11261. else {
  11262. newYaw = boneYaw - Math.PI * .75;
  11263. localTarget.z = Math.cos(newYaw) * xzlen;
  11264. localTarget.x = Math.sin(newYaw) * xzlen;
  11265. }
  11266. }
  11267. }
  11268. if (yaw != newYaw) {
  11269. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11270. localTarget.addInPlace(bonePos);
  11271. target = localTarget;
  11272. }
  11273. }
  11274. }
  11275. var zaxis = BoneLookController._tmpVecs[5];
  11276. var xaxis = BoneLookController._tmpVecs[6];
  11277. var yaxis = BoneLookController._tmpVecs[7];
  11278. var _tmpQuat = BoneLookController._tmpQuat;
  11279. target.subtractToRef(bonePos, zaxis);
  11280. zaxis.normalize();
  11281. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11282. xaxis.normalize();
  11283. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11284. yaxis.normalize();
  11285. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11286. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11287. return;
  11288. }
  11289. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11290. return;
  11291. }
  11292. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11293. return;
  11294. }
  11295. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11296. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11297. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11298. }
  11299. if (this.slerpAmount < 1) {
  11300. if (!this._slerping) {
  11301. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11302. }
  11303. if (this._transformYawPitch) {
  11304. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11305. }
  11306. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11307. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11308. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11309. this._slerping = true;
  11310. }
  11311. else {
  11312. if (this._transformYawPitch) {
  11313. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11314. }
  11315. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11316. this._slerping = false;
  11317. }
  11318. };
  11319. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11320. var angDiff = ang2 - ang1;
  11321. angDiff %= Math.PI * 2;
  11322. if (angDiff > Math.PI) {
  11323. angDiff -= Math.PI * 2;
  11324. }
  11325. else if (angDiff < -Math.PI) {
  11326. angDiff += Math.PI * 2;
  11327. }
  11328. return angDiff;
  11329. };
  11330. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11331. ang1 %= (2 * Math.PI);
  11332. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11333. ang2 %= (2 * Math.PI);
  11334. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11335. var ab = 0;
  11336. if (ang1 < ang2) {
  11337. ab = ang2 - ang1;
  11338. }
  11339. else {
  11340. ab = ang1 - ang2;
  11341. }
  11342. if (ab > Math.PI) {
  11343. ab = Math.PI * 2 - ab;
  11344. }
  11345. return ab;
  11346. };
  11347. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11348. ang %= (2 * Math.PI);
  11349. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11350. ang1 %= (2 * Math.PI);
  11351. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11352. ang2 %= (2 * Math.PI);
  11353. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11354. if (ang1 < ang2) {
  11355. if (ang > ang1 && ang < ang2) {
  11356. return true;
  11357. }
  11358. }
  11359. else {
  11360. if (ang > ang2 && ang < ang1) {
  11361. return true;
  11362. }
  11363. }
  11364. return false;
  11365. };
  11366. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11367. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11368. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11369. return BoneLookController;
  11370. }());
  11371. /***/ }),
  11372. /***/ "./Bones/index.ts":
  11373. /*!************************!*\
  11374. !*** ./Bones/index.ts ***!
  11375. \************************/
  11376. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11378. "use strict";
  11379. __webpack_require__.r(__webpack_exports__);
  11380. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11382. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11384. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11386. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11388. /***/ }),
  11389. /***/ "./Bones/skeleton.ts":
  11390. /*!***************************!*\
  11391. !*** ./Bones/skeleton.ts ***!
  11392. \***************************/
  11393. /*! exports provided: Skeleton */
  11394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11395. "use strict";
  11396. __webpack_require__.r(__webpack_exports__);
  11397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11398. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11399. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11400. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11401. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11402. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11403. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11404. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11405. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11406. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11407. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11408. /**
  11409. * Class used to handle skinning animations
  11410. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11411. */
  11412. var Skeleton = /** @class */ (function () {
  11413. /**
  11414. * Creates a new skeleton
  11415. * @param name defines the skeleton name
  11416. * @param id defines the skeleton Id
  11417. * @param scene defines the hosting scene
  11418. */
  11419. function Skeleton(
  11420. /** defines the skeleton name */
  11421. name,
  11422. /** defines the skeleton Id */
  11423. id, scene) {
  11424. this.name = name;
  11425. this.id = id;
  11426. /**
  11427. * Defines the list of child bones
  11428. */
  11429. this.bones = new Array();
  11430. /**
  11431. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11432. */
  11433. this.needInitialSkinMatrix = false;
  11434. /**
  11435. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11436. */
  11437. this.overrideMesh = null;
  11438. this._isDirty = true;
  11439. this._meshesWithPoseMatrix = new Array();
  11440. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11441. this._ranges = {};
  11442. this._lastAbsoluteTransformsUpdateId = -1;
  11443. this._canUseTextureForBones = false;
  11444. /** @hidden */
  11445. this._numBonesWithLinkedTransformNode = 0;
  11446. /**
  11447. * Specifies if the skeleton should be serialized
  11448. */
  11449. this.doNotSerialize = false;
  11450. /**
  11451. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11452. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11453. */
  11454. this.useTextureToStoreBoneMatrices = true;
  11455. this._animationPropertiesOverride = null;
  11456. // Events
  11457. /**
  11458. * An observable triggered before computing the skeleton's matrices
  11459. */
  11460. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11461. this.bones = [];
  11462. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11463. this._scene.skeletons.push(this);
  11464. //make sure it will recalculate the matrix next time prepare is called.
  11465. this._isDirty = true;
  11466. var engineCaps = this._scene.getEngine().getCaps();
  11467. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11468. }
  11469. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11470. /**
  11471. * Gets or sets the animation properties override
  11472. */
  11473. get: function () {
  11474. if (!this._animationPropertiesOverride) {
  11475. return this._scene.animationPropertiesOverride;
  11476. }
  11477. return this._animationPropertiesOverride;
  11478. },
  11479. set: function (value) {
  11480. this._animationPropertiesOverride = value;
  11481. },
  11482. enumerable: true,
  11483. configurable: true
  11484. });
  11485. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11486. /**
  11487. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11488. */
  11489. get: function () {
  11490. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11491. },
  11492. enumerable: true,
  11493. configurable: true
  11494. });
  11495. // Members
  11496. /**
  11497. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11499. * @returns a Float32Array containing matrices data
  11500. */
  11501. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11502. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11503. return mesh._bonesTransformMatrices;
  11504. }
  11505. if (!this._transformMatrices) {
  11506. this.prepare();
  11507. }
  11508. return this._transformMatrices;
  11509. };
  11510. /**
  11511. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11512. * @returns a raw texture containing the data
  11513. */
  11514. Skeleton.prototype.getTransformMatrixTexture = function () {
  11515. return this._transformMatrixTexture;
  11516. };
  11517. /**
  11518. * Gets the current hosting scene
  11519. * @returns a scene object
  11520. */
  11521. Skeleton.prototype.getScene = function () {
  11522. return this._scene;
  11523. };
  11524. // Methods
  11525. /**
  11526. * Gets a string representing the current skeleton data
  11527. * @param fullDetails defines a boolean indicating if we want a verbose version
  11528. * @returns a string representing the current skeleton data
  11529. */
  11530. Skeleton.prototype.toString = function (fullDetails) {
  11531. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11532. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11533. if (fullDetails) {
  11534. ret += ", Ranges: {";
  11535. var first = true;
  11536. for (var name_1 in this._ranges) {
  11537. if (first) {
  11538. ret += ", ";
  11539. first = false;
  11540. }
  11541. ret += name_1;
  11542. }
  11543. ret += "}";
  11544. }
  11545. return ret;
  11546. };
  11547. /**
  11548. * Get bone's index searching by name
  11549. * @param name defines bone's name to search for
  11550. * @return the indice of the bone. Returns -1 if not found
  11551. */
  11552. Skeleton.prototype.getBoneIndexByName = function (name) {
  11553. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11554. if (this.bones[boneIndex].name === name) {
  11555. return boneIndex;
  11556. }
  11557. }
  11558. return -1;
  11559. };
  11560. /**
  11561. * Creater a new animation range
  11562. * @param name defines the name of the range
  11563. * @param from defines the start key
  11564. * @param to defines the end key
  11565. */
  11566. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11567. // check name not already in use
  11568. if (!this._ranges[name]) {
  11569. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11570. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11571. if (this.bones[i].animations[0]) {
  11572. this.bones[i].animations[0].createRange(name, from, to);
  11573. }
  11574. }
  11575. }
  11576. };
  11577. /**
  11578. * Delete a specific animation range
  11579. * @param name defines the name of the range
  11580. * @param deleteFrames defines if frames must be removed as well
  11581. */
  11582. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11583. if (deleteFrames === void 0) { deleteFrames = true; }
  11584. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11585. if (this.bones[i].animations[0]) {
  11586. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11587. }
  11588. }
  11589. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11590. };
  11591. /**
  11592. * Gets a specific animation range
  11593. * @param name defines the name of the range to look for
  11594. * @returns the requested animation range or null if not found
  11595. */
  11596. Skeleton.prototype.getAnimationRange = function (name) {
  11597. return this._ranges[name];
  11598. };
  11599. /**
  11600. * Gets the list of all animation ranges defined on this skeleton
  11601. * @returns an array
  11602. */
  11603. Skeleton.prototype.getAnimationRanges = function () {
  11604. var animationRanges = [];
  11605. var name;
  11606. var i = 0;
  11607. for (name in this._ranges) {
  11608. animationRanges[i] = this._ranges[name];
  11609. i++;
  11610. }
  11611. return animationRanges;
  11612. };
  11613. /**
  11614. * Copy animation range from a source skeleton.
  11615. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11616. * @param source defines the source skeleton
  11617. * @param name defines the name of the range to copy
  11618. * @param rescaleAsRequired defines if rescaling must be applied if required
  11619. * @returns true if operation was successful
  11620. */
  11621. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11622. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11623. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11624. return false;
  11625. }
  11626. var ret = true;
  11627. var frameOffset = this._getHighestAnimationFrame() + 1;
  11628. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11629. var boneDict = {};
  11630. var sourceBones = source.bones;
  11631. var nBones;
  11632. var i;
  11633. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11634. boneDict[sourceBones[i].name] = sourceBones[i];
  11635. }
  11636. if (this.bones.length !== sourceBones.length) {
  11637. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11638. ret = false;
  11639. }
  11640. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11641. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11642. var boneName = this.bones[i].name;
  11643. var sourceBone = boneDict[boneName];
  11644. if (sourceBone) {
  11645. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11646. }
  11647. else {
  11648. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11649. ret = false;
  11650. }
  11651. }
  11652. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11653. var range = source.getAnimationRange(name);
  11654. if (range) {
  11655. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11656. }
  11657. return ret;
  11658. };
  11659. /**
  11660. * Forces the skeleton to go to rest pose
  11661. */
  11662. Skeleton.prototype.returnToRest = function () {
  11663. for (var index = 0; index < this.bones.length; index++) {
  11664. this.bones[index].returnToRest();
  11665. }
  11666. };
  11667. Skeleton.prototype._getHighestAnimationFrame = function () {
  11668. var ret = 0;
  11669. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11670. if (this.bones[i].animations[0]) {
  11671. var highest = this.bones[i].animations[0].getHighestFrame();
  11672. if (ret < highest) {
  11673. ret = highest;
  11674. }
  11675. }
  11676. }
  11677. return ret;
  11678. };
  11679. /**
  11680. * Begin a specific animation range
  11681. * @param name defines the name of the range to start
  11682. * @param loop defines if looping must be turned on (false by default)
  11683. * @param speedRatio defines the speed ratio to apply (1 by default)
  11684. * @param onAnimationEnd defines a callback which will be called when animation will end
  11685. * @returns a new animatable
  11686. */
  11687. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11688. var range = this.getAnimationRange(name);
  11689. if (!range) {
  11690. return null;
  11691. }
  11692. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11693. };
  11694. /** @hidden */
  11695. Skeleton.prototype._markAsDirty = function () {
  11696. this._isDirty = true;
  11697. };
  11698. /** @hidden */
  11699. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11700. this._meshesWithPoseMatrix.push(mesh);
  11701. };
  11702. /** @hidden */
  11703. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11704. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11705. if (index > -1) {
  11706. this._meshesWithPoseMatrix.splice(index, 1);
  11707. }
  11708. };
  11709. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11710. this.onBeforeComputeObservable.notifyObservers(this);
  11711. for (var index = 0; index < this.bones.length; index++) {
  11712. var bone = this.bones[index];
  11713. var parentBone = bone.getParent();
  11714. if (parentBone) {
  11715. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11716. }
  11717. else {
  11718. if (initialSkinMatrix) {
  11719. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11720. }
  11721. else {
  11722. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11723. }
  11724. }
  11725. if (bone._index !== -1) {
  11726. var mappedIndex = bone._index === null ? index : bone._index;
  11727. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11728. }
  11729. }
  11730. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11731. };
  11732. /**
  11733. * Build all resources required to render a skeleton
  11734. */
  11735. Skeleton.prototype.prepare = function () {
  11736. // Update the local matrix of bones with linked transform nodes.
  11737. if (this._numBonesWithLinkedTransformNode > 0) {
  11738. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11739. var bone_1 = _a[_i];
  11740. if (bone_1._linkedTransformNode) {
  11741. // Computing the world matrix also computes the local matrix.
  11742. bone_1._linkedTransformNode.computeWorldMatrix();
  11743. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11744. bone_1.markAsDirty();
  11745. }
  11746. }
  11747. }
  11748. if (!this._isDirty) {
  11749. return;
  11750. }
  11751. if (this.needInitialSkinMatrix) {
  11752. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11753. var mesh = this._meshesWithPoseMatrix[index];
  11754. var poseMatrix = mesh.getPoseMatrix();
  11755. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11756. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11757. }
  11758. if (this._synchronizedWithMesh !== mesh) {
  11759. this._synchronizedWithMesh = mesh;
  11760. // Prepare bones
  11761. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11762. var bone = this.bones[boneIndex];
  11763. if (!bone.getParent()) {
  11764. var matrix = bone.getBaseMatrix();
  11765. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11766. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11767. }
  11768. }
  11769. }
  11770. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11771. }
  11772. }
  11773. else {
  11774. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11775. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11776. if (this.isUsingTextureForMatrices) {
  11777. if (this._transformMatrixTexture) {
  11778. this._transformMatrixTexture.dispose();
  11779. }
  11780. 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);
  11781. }
  11782. }
  11783. this._computeTransformMatrices(this._transformMatrices, null);
  11784. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11785. this._transformMatrixTexture.update(this._transformMatrices);
  11786. }
  11787. }
  11788. this._isDirty = false;
  11789. this._scene._activeBones.addCount(this.bones.length, false);
  11790. };
  11791. /**
  11792. * Gets the list of animatables currently running for this skeleton
  11793. * @returns an array of animatables
  11794. */
  11795. Skeleton.prototype.getAnimatables = function () {
  11796. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11797. this._animatables = [];
  11798. for (var index = 0; index < this.bones.length; index++) {
  11799. this._animatables.push(this.bones[index]);
  11800. }
  11801. }
  11802. return this._animatables;
  11803. };
  11804. /**
  11805. * Clone the current skeleton
  11806. * @param name defines the name of the new skeleton
  11807. * @param id defines the id of the enw skeleton
  11808. * @returns the new skeleton
  11809. */
  11810. Skeleton.prototype.clone = function (name, id) {
  11811. var result = new Skeleton(name, id || name, this._scene);
  11812. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11813. for (var index = 0; index < this.bones.length; index++) {
  11814. var source = this.bones[index];
  11815. var parentBone = null;
  11816. var parent_1 = source.getParent();
  11817. if (parent_1) {
  11818. var parentIndex = this.bones.indexOf(parent_1);
  11819. parentBone = result.bones[parentIndex];
  11820. }
  11821. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11822. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11823. }
  11824. if (this._ranges) {
  11825. result._ranges = {};
  11826. for (var rangeName in this._ranges) {
  11827. var range = this._ranges[rangeName];
  11828. if (range) {
  11829. result._ranges[rangeName] = range.clone();
  11830. }
  11831. }
  11832. }
  11833. this._isDirty = true;
  11834. return result;
  11835. };
  11836. /**
  11837. * Enable animation blending for this skeleton
  11838. * @param blendingSpeed defines the blending speed to apply
  11839. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11840. */
  11841. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11842. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11843. this.bones.forEach(function (bone) {
  11844. bone.animations.forEach(function (animation) {
  11845. animation.enableBlending = true;
  11846. animation.blendingSpeed = blendingSpeed;
  11847. });
  11848. });
  11849. };
  11850. /**
  11851. * Releases all resources associated with the current skeleton
  11852. */
  11853. Skeleton.prototype.dispose = function () {
  11854. this._meshesWithPoseMatrix = [];
  11855. // Animations
  11856. this.getScene().stopAnimation(this);
  11857. // Remove from scene
  11858. this.getScene().removeSkeleton(this);
  11859. if (this._transformMatrixTexture) {
  11860. this._transformMatrixTexture.dispose();
  11861. this._transformMatrixTexture = null;
  11862. }
  11863. };
  11864. /**
  11865. * Serialize the skeleton in a JSON object
  11866. * @returns a JSON object
  11867. */
  11868. Skeleton.prototype.serialize = function () {
  11869. var serializationObject = {};
  11870. serializationObject.name = this.name;
  11871. serializationObject.id = this.id;
  11872. if (this.dimensionsAtRest) {
  11873. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11874. }
  11875. serializationObject.bones = [];
  11876. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11877. for (var index = 0; index < this.bones.length; index++) {
  11878. var bone = this.bones[index];
  11879. var parent_2 = bone.getParent();
  11880. var serializedBone = {
  11881. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11882. name: bone.name,
  11883. matrix: bone.getBaseMatrix().toArray(),
  11884. rest: bone.getRestPose().toArray()
  11885. };
  11886. serializationObject.bones.push(serializedBone);
  11887. if (bone.length) {
  11888. serializedBone.length = bone.length;
  11889. }
  11890. if (bone.metadata) {
  11891. serializedBone.metadata = bone.metadata;
  11892. }
  11893. if (bone.animations && bone.animations.length > 0) {
  11894. serializedBone.animation = bone.animations[0].serialize();
  11895. }
  11896. serializationObject.ranges = [];
  11897. for (var name in this._ranges) {
  11898. var source = this._ranges[name];
  11899. if (!source) {
  11900. continue;
  11901. }
  11902. var range = {};
  11903. range.name = name;
  11904. range.from = source.from;
  11905. range.to = source.to;
  11906. serializationObject.ranges.push(range);
  11907. }
  11908. }
  11909. return serializationObject;
  11910. };
  11911. /**
  11912. * Creates a new skeleton from serialized data
  11913. * @param parsedSkeleton defines the serialized data
  11914. * @param scene defines the hosting scene
  11915. * @returns a new skeleton
  11916. */
  11917. Skeleton.Parse = function (parsedSkeleton, scene) {
  11918. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11919. if (parsedSkeleton.dimensionsAtRest) {
  11920. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11921. }
  11922. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11923. var index;
  11924. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11925. var parsedBone = parsedSkeleton.bones[index];
  11926. var parentBone = null;
  11927. if (parsedBone.parentBoneIndex > -1) {
  11928. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11929. }
  11930. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11931. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11932. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11933. bone.id = parsedBone.id;
  11934. }
  11935. if (parsedBone.length) {
  11936. bone.length = parsedBone.length;
  11937. }
  11938. if (parsedBone.metadata) {
  11939. bone.metadata = parsedBone.metadata;
  11940. }
  11941. if (parsedBone.animation) {
  11942. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11943. }
  11944. }
  11945. // placed after bones, so createAnimationRange can cascade down
  11946. if (parsedSkeleton.ranges) {
  11947. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11948. var data = parsedSkeleton.ranges[index];
  11949. skeleton.createAnimationRange(data.name, data.from, data.to);
  11950. }
  11951. }
  11952. return skeleton;
  11953. };
  11954. /**
  11955. * Compute all node absolute transforms
  11956. * @param forceUpdate defines if computation must be done even if cache is up to date
  11957. */
  11958. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11959. if (forceUpdate === void 0) { forceUpdate = false; }
  11960. var renderId = this._scene.getRenderId();
  11961. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11962. this.bones[0].computeAbsoluteTransforms();
  11963. this._lastAbsoluteTransformsUpdateId = renderId;
  11964. }
  11965. };
  11966. /**
  11967. * Gets the root pose matrix
  11968. * @returns a matrix
  11969. */
  11970. Skeleton.prototype.getPoseMatrix = function () {
  11971. var poseMatrix = null;
  11972. if (this._meshesWithPoseMatrix.length > 0) {
  11973. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11974. }
  11975. return poseMatrix;
  11976. };
  11977. /**
  11978. * Sorts bones per internal index
  11979. */
  11980. Skeleton.prototype.sortBones = function () {
  11981. var bones = new Array();
  11982. var visited = new Array(this.bones.length);
  11983. for (var index = 0; index < this.bones.length; index++) {
  11984. this._sortBones(index, bones, visited);
  11985. }
  11986. this.bones = bones;
  11987. };
  11988. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11989. if (visited[index]) {
  11990. return;
  11991. }
  11992. visited[index] = true;
  11993. var bone = this.bones[index];
  11994. if (bone._index === undefined) {
  11995. bone._index = index;
  11996. }
  11997. var parentBone = bone.getParent();
  11998. if (parentBone) {
  11999. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12000. }
  12001. bones.push(bone);
  12002. };
  12003. return Skeleton;
  12004. }());
  12005. /***/ }),
  12006. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12007. /*!*******************************************************!*\
  12008. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12009. \*******************************************************/
  12010. /*! exports provided: ArcRotateCameraGamepadInput */
  12011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12012. "use strict";
  12013. __webpack_require__.r(__webpack_exports__);
  12014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12017. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12018. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12019. /**
  12020. * Manage the gamepad inputs to control an arc rotate camera.
  12021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12022. */
  12023. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12024. function ArcRotateCameraGamepadInput() {
  12025. /**
  12026. * Defines the gamepad rotation sensiblity.
  12027. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12028. */
  12029. this.gamepadRotationSensibility = 80;
  12030. /**
  12031. * Defines the gamepad move sensiblity.
  12032. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12033. */
  12034. this.gamepadMoveSensibility = 40;
  12035. }
  12036. /**
  12037. * Attach the input controls to a specific dom element to get the input from.
  12038. * @param element Defines the element the controls should be listened from
  12039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12040. */
  12041. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12042. var _this = this;
  12043. var manager = this.camera.getScene().gamepadManager;
  12044. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12045. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12046. // prioritize XBOX gamepads.
  12047. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12048. _this.gamepad = gamepad;
  12049. }
  12050. }
  12051. });
  12052. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12053. if (_this.gamepad === gamepad) {
  12054. _this.gamepad = null;
  12055. }
  12056. });
  12057. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12058. };
  12059. /**
  12060. * Detach the current controls from the specified dom element.
  12061. * @param element Defines the element to stop listening the inputs from
  12062. */
  12063. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12064. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12065. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12066. this.gamepad = null;
  12067. };
  12068. /**
  12069. * Update the current camera state depending on the inputs that have been used this frame.
  12070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12071. */
  12072. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12073. if (this.gamepad) {
  12074. var camera = this.camera;
  12075. var RSValues = this.gamepad.rightStick;
  12076. if (RSValues) {
  12077. if (RSValues.x != 0) {
  12078. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12079. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12080. camera.inertialAlphaOffset += normalizedRX;
  12081. }
  12082. }
  12083. if (RSValues.y != 0) {
  12084. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12085. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12086. camera.inertialBetaOffset += normalizedRY;
  12087. }
  12088. }
  12089. }
  12090. var LSValues = this.gamepad.leftStick;
  12091. if (LSValues && LSValues.y != 0) {
  12092. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12093. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12094. this.camera.inertialRadiusOffset -= normalizedLY;
  12095. }
  12096. }
  12097. }
  12098. };
  12099. /**
  12100. * Gets the class name of the current intput.
  12101. * @returns the class name
  12102. */
  12103. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12104. return "ArcRotateCameraGamepadInput";
  12105. };
  12106. /**
  12107. * Get the friendly name associated with the input class.
  12108. * @returns the input friendly name
  12109. */
  12110. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12111. return "gamepad";
  12112. };
  12113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12115. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12118. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12119. return ArcRotateCameraGamepadInput;
  12120. }());
  12121. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12122. /***/ }),
  12123. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12124. /*!************************************************************!*\
  12125. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12126. \************************************************************/
  12127. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12129. "use strict";
  12130. __webpack_require__.r(__webpack_exports__);
  12131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12132. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12133. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12134. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12135. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12136. /**
  12137. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12139. */
  12140. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12141. function ArcRotateCameraKeyboardMoveInput() {
  12142. /**
  12143. * Defines the list of key codes associated with the up action (increase alpha)
  12144. */
  12145. this.keysUp = [38];
  12146. /**
  12147. * Defines the list of key codes associated with the down action (decrease alpha)
  12148. */
  12149. this.keysDown = [40];
  12150. /**
  12151. * Defines the list of key codes associated with the left action (increase beta)
  12152. */
  12153. this.keysLeft = [37];
  12154. /**
  12155. * Defines the list of key codes associated with the right action (decrease beta)
  12156. */
  12157. this.keysRight = [39];
  12158. /**
  12159. * Defines the list of key codes associated with the reset action.
  12160. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12161. */
  12162. this.keysReset = [220];
  12163. /**
  12164. * Defines the panning sensibility of the inputs.
  12165. * (How fast is the camera paning)
  12166. */
  12167. this.panningSensibility = 50.0;
  12168. /**
  12169. * Defines the zooming sensibility of the inputs.
  12170. * (How fast is the camera zooming)
  12171. */
  12172. this.zoomingSensibility = 25.0;
  12173. /**
  12174. * Defines wether maintaining the alt key down switch the movement mode from
  12175. * orientation to zoom.
  12176. */
  12177. this.useAltToZoom = true;
  12178. /**
  12179. * Rotation speed of the camera
  12180. */
  12181. this.angularSpeed = 0.01;
  12182. this._keys = new Array();
  12183. }
  12184. /**
  12185. * Attach the input controls to a specific dom element to get the input from.
  12186. * @param element Defines the element the controls should be listened from
  12187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12188. */
  12189. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12190. var _this = this;
  12191. if (this._onCanvasBlurObserver) {
  12192. return;
  12193. }
  12194. this._scene = this.camera.getScene();
  12195. this._engine = this._scene.getEngine();
  12196. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12197. _this._keys = [];
  12198. });
  12199. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12200. var evt = info.event;
  12201. if (!evt.metaKey) {
  12202. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12203. _this._ctrlPressed = evt.ctrlKey;
  12204. _this._altPressed = evt.altKey;
  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 === -1) {
  12212. _this._keys.push(evt.keyCode);
  12213. }
  12214. if (evt.preventDefault) {
  12215. if (!noPreventDefault) {
  12216. evt.preventDefault();
  12217. }
  12218. }
  12219. }
  12220. }
  12221. else {
  12222. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12223. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12224. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12225. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12226. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12227. var index = _this._keys.indexOf(evt.keyCode);
  12228. if (index >= 0) {
  12229. _this._keys.splice(index, 1);
  12230. }
  12231. if (evt.preventDefault) {
  12232. if (!noPreventDefault) {
  12233. evt.preventDefault();
  12234. }
  12235. }
  12236. }
  12237. }
  12238. }
  12239. });
  12240. };
  12241. /**
  12242. * Detach the current controls from the specified dom element.
  12243. * @param element Defines the element to stop listening the inputs from
  12244. */
  12245. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12246. if (this._scene) {
  12247. if (this._onKeyboardObserver) {
  12248. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12249. }
  12250. if (this._onCanvasBlurObserver) {
  12251. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12252. }
  12253. this._onKeyboardObserver = null;
  12254. this._onCanvasBlurObserver = null;
  12255. }
  12256. this._keys = [];
  12257. };
  12258. /**
  12259. * Update the current camera state depending on the inputs that have been used this frame.
  12260. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12261. */
  12262. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12263. if (this._onKeyboardObserver) {
  12264. var camera = this.camera;
  12265. for (var index = 0; index < this._keys.length; index++) {
  12266. var keyCode = this._keys[index];
  12267. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12268. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12269. camera.inertialPanningX -= 1 / this.panningSensibility;
  12270. }
  12271. else {
  12272. camera.inertialAlphaOffset -= this.angularSpeed;
  12273. }
  12274. }
  12275. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12276. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12277. camera.inertialPanningY += 1 / this.panningSensibility;
  12278. }
  12279. else if (this._altPressed && this.useAltToZoom) {
  12280. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12281. }
  12282. else {
  12283. camera.inertialBetaOffset -= this.angularSpeed;
  12284. }
  12285. }
  12286. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12287. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12288. camera.inertialPanningX += 1 / this.panningSensibility;
  12289. }
  12290. else {
  12291. camera.inertialAlphaOffset += this.angularSpeed;
  12292. }
  12293. }
  12294. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12295. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12296. camera.inertialPanningY -= 1 / this.panningSensibility;
  12297. }
  12298. else if (this._altPressed && this.useAltToZoom) {
  12299. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12300. }
  12301. else {
  12302. camera.inertialBetaOffset += this.angularSpeed;
  12303. }
  12304. }
  12305. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12306. if (camera.useInputToRestoreState) {
  12307. camera.restoreState();
  12308. }
  12309. }
  12310. }
  12311. }
  12312. };
  12313. /**
  12314. * Gets the class name of the current intput.
  12315. * @returns the class name
  12316. */
  12317. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12318. return "ArcRotateCameraKeyboardMoveInput";
  12319. };
  12320. /**
  12321. * Get the friendly name associated with the input class.
  12322. * @returns the input friendly name
  12323. */
  12324. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12325. return "keyboard";
  12326. };
  12327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12329. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12330. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12332. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12335. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12338. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12341. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12344. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12347. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12350. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12353. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12354. return ArcRotateCameraKeyboardMoveInput;
  12355. }());
  12356. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12357. /***/ }),
  12358. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12359. /*!**********************************************************!*\
  12360. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12361. \**********************************************************/
  12362. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12364. "use strict";
  12365. __webpack_require__.r(__webpack_exports__);
  12366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12367. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12368. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12369. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12370. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12371. /**
  12372. * Manage the mouse wheel inputs to control an arc rotate camera.
  12373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12374. */
  12375. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12376. function ArcRotateCameraMouseWheelInput() {
  12377. /**
  12378. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12379. */
  12380. this.wheelPrecision = 3.0;
  12381. /**
  12382. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12383. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12384. */
  12385. this.wheelDeltaPercentage = 0;
  12386. }
  12387. /**
  12388. * Attach the input controls to a specific dom element to get the input from.
  12389. * @param element Defines the element the controls should be listened from
  12390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12391. */
  12392. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12393. var _this = this;
  12394. this._wheel = function (p, s) {
  12395. //sanity check - this should be a PointerWheel event.
  12396. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12397. return;
  12398. }
  12399. var event = p.event;
  12400. var delta = 0;
  12401. var mouseWheelLegacyEvent = event;
  12402. if (mouseWheelLegacyEvent.wheelDelta) {
  12403. if (_this.wheelDeltaPercentage) {
  12404. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12405. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12406. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12407. }
  12408. else {
  12409. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12410. }
  12411. }
  12412. else {
  12413. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12414. }
  12415. }
  12416. else {
  12417. var deltaValue = event.deltaY || event.detail;
  12418. delta = -deltaValue / _this.wheelPrecision;
  12419. }
  12420. if (delta) {
  12421. _this.camera.inertialRadiusOffset += delta;
  12422. }
  12423. if (event.preventDefault) {
  12424. if (!noPreventDefault) {
  12425. event.preventDefault();
  12426. }
  12427. }
  12428. };
  12429. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12430. };
  12431. /**
  12432. * Detach the current controls from the specified dom element.
  12433. * @param element Defines the element to stop listening the inputs from
  12434. */
  12435. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12436. if (this._observer && element) {
  12437. this.camera.getScene().onPointerObservable.remove(this._observer);
  12438. this._observer = null;
  12439. this._wheel = null;
  12440. }
  12441. };
  12442. /**
  12443. * Gets the class name of the current intput.
  12444. * @returns the class name
  12445. */
  12446. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12447. return "ArcRotateCameraMouseWheelInput";
  12448. };
  12449. /**
  12450. * Get the friendly name associated with the input class.
  12451. * @returns the input friendly name
  12452. */
  12453. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12454. return "mousewheel";
  12455. };
  12456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12458. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12461. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12462. return ArcRotateCameraMouseWheelInput;
  12463. }());
  12464. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12465. /***/ }),
  12466. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12467. /*!********************************************************!*\
  12468. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12469. \********************************************************/
  12470. /*! exports provided: ArcRotateCameraPointersInput */
  12471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12472. "use strict";
  12473. __webpack_require__.r(__webpack_exports__);
  12474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12476. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12477. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12478. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12479. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12480. /**
  12481. * Manage the pointers inputs to control an arc rotate camera.
  12482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12483. */
  12484. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12485. function ArcRotateCameraPointersInput() {
  12486. /**
  12487. * Defines the buttons associated with the input to handle camera move.
  12488. */
  12489. this.buttons = [0, 1, 2];
  12490. /**
  12491. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12492. */
  12493. this.angularSensibilityX = 1000.0;
  12494. /**
  12495. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12496. */
  12497. this.angularSensibilityY = 1000.0;
  12498. /**
  12499. * Defines the pointer pinch precision or how fast is the camera zooming.
  12500. */
  12501. this.pinchPrecision = 12.0;
  12502. /**
  12503. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12504. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12505. */
  12506. this.pinchDeltaPercentage = 0;
  12507. /**
  12508. * Defines the pointer panning sensibility or how fast is the camera moving.
  12509. */
  12510. this.panningSensibility = 1000.0;
  12511. /**
  12512. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12513. */
  12514. this.multiTouchPanning = true;
  12515. /**
  12516. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12517. */
  12518. this.multiTouchPanAndZoom = true;
  12519. /**
  12520. * Revers pinch action direction.
  12521. */
  12522. this.pinchInwards = true;
  12523. this._isPanClick = false;
  12524. }
  12525. /**
  12526. * Attach the input controls to a specific dom element to get the input from.
  12527. * @param element Defines the element the controls should be listened from
  12528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12529. */
  12530. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12531. var _this = this;
  12532. var engine = this.camera.getEngine();
  12533. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12534. var pointA = null;
  12535. var pointB = null;
  12536. var previousPinchSquaredDistance = 0;
  12537. var initialDistance = 0;
  12538. var twoFingerActivityCount = 0;
  12539. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12540. this._pointerInput = function (p, s) {
  12541. var evt = p.event;
  12542. var isTouch = p.event.pointerType === "touch";
  12543. if (engine.isInVRExclusivePointerMode) {
  12544. return;
  12545. }
  12546. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12547. return;
  12548. }
  12549. var srcElement = (evt.srcElement || evt.target);
  12550. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12551. try {
  12552. srcElement.setPointerCapture(evt.pointerId);
  12553. }
  12554. catch (e) {
  12555. //Nothing to do with the error. Execution will continue.
  12556. }
  12557. // Manage panning with pan button click
  12558. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12559. // manage pointers
  12560. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12561. if (pointA === null) {
  12562. pointA = cacheSoloPointer;
  12563. }
  12564. else if (pointB === null) {
  12565. pointB = cacheSoloPointer;
  12566. }
  12567. if (!noPreventDefault) {
  12568. evt.preventDefault();
  12569. element.focus();
  12570. }
  12571. }
  12572. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12573. if (_this.camera.useInputToRestoreState) {
  12574. _this.camera.restoreState();
  12575. }
  12576. }
  12577. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12578. try {
  12579. srcElement.releasePointerCapture(evt.pointerId);
  12580. }
  12581. catch (e) {
  12582. //Nothing to do with the error.
  12583. }
  12584. cacheSoloPointer = null;
  12585. previousPinchSquaredDistance = 0;
  12586. previousMultiTouchPanPosition.isPaning = false;
  12587. previousMultiTouchPanPosition.isPinching = false;
  12588. twoFingerActivityCount = 0;
  12589. initialDistance = 0;
  12590. if (!isTouch) {
  12591. pointB = null; // Mouse and pen are mono pointer
  12592. }
  12593. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12594. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12595. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12596. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12597. if (engine._badOS) {
  12598. pointA = pointB = null;
  12599. }
  12600. else {
  12601. //only remove the impacted pointer in case of multitouch allowing on most
  12602. //platforms switching from rotate to zoom and pan seamlessly.
  12603. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12604. pointA = pointB;
  12605. pointB = null;
  12606. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12607. }
  12608. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12609. pointB = null;
  12610. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12611. }
  12612. else {
  12613. pointA = pointB = null;
  12614. }
  12615. }
  12616. if (!noPreventDefault) {
  12617. evt.preventDefault();
  12618. }
  12619. }
  12620. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12621. if (!noPreventDefault) {
  12622. evt.preventDefault();
  12623. }
  12624. // One button down
  12625. if (pointA && pointB === null && cacheSoloPointer) {
  12626. if (_this.panningSensibility !== 0 &&
  12627. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12628. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12629. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12630. }
  12631. else {
  12632. var offsetX = evt.clientX - cacheSoloPointer.x;
  12633. var offsetY = evt.clientY - cacheSoloPointer.y;
  12634. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12635. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12636. }
  12637. cacheSoloPointer.x = evt.clientX;
  12638. cacheSoloPointer.y = evt.clientY;
  12639. }
  12640. // Two buttons down: pinch/pan
  12641. else if (pointA && pointB) {
  12642. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12643. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12644. ed.x = evt.clientX;
  12645. ed.y = evt.clientY;
  12646. var direction = _this.pinchInwards ? 1 : -1;
  12647. var distX = pointA.x - pointB.x;
  12648. var distY = pointA.y - pointB.y;
  12649. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12650. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12651. if (previousPinchSquaredDistance === 0) {
  12652. initialDistance = pinchDistance;
  12653. previousPinchSquaredDistance = pinchSquaredDistance;
  12654. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12655. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12656. return;
  12657. }
  12658. if (_this.multiTouchPanAndZoom) {
  12659. if (_this.pinchDeltaPercentage) {
  12660. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12661. }
  12662. else {
  12663. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12664. (_this.pinchPrecision *
  12665. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12666. direction);
  12667. }
  12668. if (_this.panningSensibility !== 0) {
  12669. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12670. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12671. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12672. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12673. previousMultiTouchPanPosition.x = pointersCenterX;
  12674. previousMultiTouchPanPosition.y = pointersCenterY;
  12675. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12676. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12677. }
  12678. }
  12679. else {
  12680. twoFingerActivityCount++;
  12681. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12682. if (_this.pinchDeltaPercentage) {
  12683. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12684. }
  12685. else {
  12686. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12687. (_this.pinchPrecision *
  12688. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12689. direction);
  12690. }
  12691. previousMultiTouchPanPosition.isPaning = false;
  12692. previousMultiTouchPanPosition.isPinching = true;
  12693. }
  12694. else {
  12695. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12696. if (!previousMultiTouchPanPosition.isPaning) {
  12697. previousMultiTouchPanPosition.isPaning = true;
  12698. previousMultiTouchPanPosition.isPinching = false;
  12699. previousMultiTouchPanPosition.x = ed.x;
  12700. previousMultiTouchPanPosition.y = ed.y;
  12701. return;
  12702. }
  12703. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12704. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12705. }
  12706. }
  12707. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12708. previousMultiTouchPanPosition.x = ed.x;
  12709. previousMultiTouchPanPosition.y = ed.y;
  12710. }
  12711. }
  12712. previousPinchSquaredDistance = pinchSquaredDistance;
  12713. }
  12714. }
  12715. };
  12716. 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);
  12717. this._onContextMenu = function (evt) {
  12718. evt.preventDefault();
  12719. };
  12720. if (!this.camera._useCtrlForPanning) {
  12721. element.addEventListener("contextmenu", this._onContextMenu, false);
  12722. }
  12723. this._onLostFocus = function () {
  12724. //this._keys = [];
  12725. pointA = pointB = null;
  12726. previousPinchSquaredDistance = 0;
  12727. previousMultiTouchPanPosition.isPaning = false;
  12728. previousMultiTouchPanPosition.isPinching = false;
  12729. twoFingerActivityCount = 0;
  12730. cacheSoloPointer = null;
  12731. initialDistance = 0;
  12732. };
  12733. this._onMouseMove = function (evt) {
  12734. if (!engine.isPointerLock) {
  12735. return;
  12736. }
  12737. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12738. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12739. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12740. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12741. if (!noPreventDefault) {
  12742. evt.preventDefault();
  12743. }
  12744. };
  12745. this._onGestureStart = function (e) {
  12746. if (window.MSGesture === undefined) {
  12747. return;
  12748. }
  12749. if (!_this._MSGestureHandler) {
  12750. _this._MSGestureHandler = new MSGesture();
  12751. _this._MSGestureHandler.target = element;
  12752. }
  12753. _this._MSGestureHandler.addPointer(e.pointerId);
  12754. };
  12755. this._onGesture = function (e) {
  12756. _this.camera.radius *= e.scale;
  12757. if (e.preventDefault) {
  12758. if (!noPreventDefault) {
  12759. e.stopPropagation();
  12760. e.preventDefault();
  12761. }
  12762. }
  12763. };
  12764. element.addEventListener("mousemove", this._onMouseMove, false);
  12765. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12766. element.addEventListener("MSGestureChange", this._onGesture, false);
  12767. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12768. { name: "blur", handler: this._onLostFocus }
  12769. ]);
  12770. };
  12771. /**
  12772. * Detach the current controls from the specified dom element.
  12773. * @param element Defines the element to stop listening the inputs from
  12774. */
  12775. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12776. if (this._onLostFocus) {
  12777. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12778. { name: "blur", handler: this._onLostFocus }
  12779. ]);
  12780. }
  12781. if (element && this._observer) {
  12782. this.camera.getScene().onPointerObservable.remove(this._observer);
  12783. this._observer = null;
  12784. if (this._onContextMenu) {
  12785. element.removeEventListener("contextmenu", this._onContextMenu);
  12786. }
  12787. if (this._onMouseMove) {
  12788. element.removeEventListener("mousemove", this._onMouseMove);
  12789. }
  12790. if (this._onGestureStart) {
  12791. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12792. }
  12793. if (this._onGesture) {
  12794. element.removeEventListener("MSGestureChange", this._onGesture);
  12795. }
  12796. this._isPanClick = false;
  12797. this.pinchInwards = true;
  12798. this._onMouseMove = null;
  12799. this._onGestureStart = null;
  12800. this._onGesture = null;
  12801. this._MSGestureHandler = null;
  12802. this._onLostFocus = null;
  12803. this._onContextMenu = null;
  12804. }
  12805. };
  12806. /**
  12807. * Gets the class name of the current intput.
  12808. * @returns the class name
  12809. */
  12810. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12811. return "ArcRotateCameraPointersInput";
  12812. };
  12813. /**
  12814. * Get the friendly name associated with the input class.
  12815. * @returns the input friendly name
  12816. */
  12817. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12818. return "pointers";
  12819. };
  12820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12822. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12825. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12828. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12831. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12834. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12837. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12838. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12839. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12840. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12841. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12843. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12844. return ArcRotateCameraPointersInput;
  12845. }());
  12846. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12847. /***/ }),
  12848. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12849. /*!*******************************************************************!*\
  12850. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12851. \*******************************************************************/
  12852. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12853. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12854. "use strict";
  12855. __webpack_require__.r(__webpack_exports__);
  12856. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12857. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12858. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12859. /**
  12860. * Add orientation input support to the input manager.
  12861. * @returns the current input manager
  12862. */
  12863. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  12864. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  12865. return this;
  12866. };
  12867. /**
  12868. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12870. */
  12871. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12872. /**
  12873. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12874. */
  12875. function ArcRotateCameraVRDeviceOrientationInput() {
  12876. /**
  12877. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12878. */
  12879. this.alphaCorrection = 1;
  12880. /**
  12881. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12882. */
  12883. this.gammaCorrection = 1;
  12884. this._alpha = 0;
  12885. this._gamma = 0;
  12886. this._dirty = false;
  12887. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12888. }
  12889. /**
  12890. * Attach the input controls to a specific dom element to get the input from.
  12891. * @param element Defines the element the controls should be listened from
  12892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12893. */
  12894. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12895. this.camera.attachControl(element, noPreventDefault);
  12896. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12897. };
  12898. /** @hidden */
  12899. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12900. if (evt.alpha !== null) {
  12901. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12902. }
  12903. if (evt.gamma !== null) {
  12904. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12905. }
  12906. this._dirty = true;
  12907. };
  12908. /**
  12909. * Update the current camera state depending on the inputs that have been used this frame.
  12910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12911. */
  12912. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12913. if (this._dirty) {
  12914. this._dirty = false;
  12915. if (this._gamma < 0) {
  12916. this._gamma = 180 + this._gamma;
  12917. }
  12918. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12919. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12920. }
  12921. };
  12922. /**
  12923. * Detach the current controls from the specified dom element.
  12924. * @param element Defines the element to stop listening the inputs from
  12925. */
  12926. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12927. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12928. };
  12929. /**
  12930. * Gets the class name of the current intput.
  12931. * @returns the class name
  12932. */
  12933. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12934. return "ArcRotateCameraVRDeviceOrientationInput";
  12935. };
  12936. /**
  12937. * Get the friendly name associated with the input class.
  12938. * @returns the input friendly name
  12939. */
  12940. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12941. return "VRDeviceOrientation";
  12942. };
  12943. return ArcRotateCameraVRDeviceOrientationInput;
  12944. }());
  12945. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12946. /***/ }),
  12947. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12948. /*!**************************************************!*\
  12949. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12950. \**************************************************/
  12951. /*! exports provided: FlyCameraKeyboardInput */
  12952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12953. "use strict";
  12954. __webpack_require__.r(__webpack_exports__);
  12955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12956. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12957. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12958. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12959. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12960. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12961. /**
  12962. * Listen to keyboard events to control the camera.
  12963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12964. */
  12965. var FlyCameraKeyboardInput = /** @class */ (function () {
  12966. function FlyCameraKeyboardInput() {
  12967. /**
  12968. * The list of keyboard keys used to control the forward move of the camera.
  12969. */
  12970. this.keysForward = [87];
  12971. /**
  12972. * The list of keyboard keys used to control the backward move of the camera.
  12973. */
  12974. this.keysBackward = [83];
  12975. /**
  12976. * The list of keyboard keys used to control the forward move of the camera.
  12977. */
  12978. this.keysUp = [69];
  12979. /**
  12980. * The list of keyboard keys used to control the backward move of the camera.
  12981. */
  12982. this.keysDown = [81];
  12983. /**
  12984. * The list of keyboard keys used to control the right strafe move of the camera.
  12985. */
  12986. this.keysRight = [68];
  12987. /**
  12988. * The list of keyboard keys used to control the left strafe move of the camera.
  12989. */
  12990. this.keysLeft = [65];
  12991. this._keys = new Array();
  12992. }
  12993. /**
  12994. * Attach the input controls to a specific dom element to get the input from.
  12995. * @param element Defines the element the controls should be listened from
  12996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12997. */
  12998. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12999. var _this = this;
  13000. if (this._onCanvasBlurObserver) {
  13001. return;
  13002. }
  13003. this._scene = this.camera.getScene();
  13004. this._engine = this._scene.getEngine();
  13005. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13006. _this._keys = [];
  13007. });
  13008. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13009. var evt = info.event;
  13010. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13011. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13012. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13013. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13014. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13015. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13016. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13017. var index = _this._keys.indexOf(evt.keyCode);
  13018. if (index === -1) {
  13019. _this._keys.push(evt.keyCode);
  13020. }
  13021. if (!noPreventDefault) {
  13022. evt.preventDefault();
  13023. }
  13024. }
  13025. }
  13026. else {
  13027. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13028. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13029. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13030. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13031. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13032. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13033. var index = _this._keys.indexOf(evt.keyCode);
  13034. if (index >= 0) {
  13035. _this._keys.splice(index, 1);
  13036. }
  13037. if (!noPreventDefault) {
  13038. evt.preventDefault();
  13039. }
  13040. }
  13041. }
  13042. });
  13043. };
  13044. /**
  13045. * Detach the current controls from the specified dom element.
  13046. * @param element Defines the element to stop listening the inputs from
  13047. */
  13048. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13049. if (this._scene) {
  13050. if (this._onKeyboardObserver) {
  13051. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13052. }
  13053. if (this._onCanvasBlurObserver) {
  13054. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13055. }
  13056. this._onKeyboardObserver = null;
  13057. this._onCanvasBlurObserver = null;
  13058. }
  13059. this._keys = [];
  13060. };
  13061. /**
  13062. * Gets the class name of the current intput.
  13063. * @returns the class name
  13064. */
  13065. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13066. return "FlyCameraKeyboardInput";
  13067. };
  13068. /** @hidden */
  13069. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13070. this._keys = [];
  13071. };
  13072. /**
  13073. * Get the friendly name associated with the input class.
  13074. * @returns the input friendly name
  13075. */
  13076. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13077. return "keyboard";
  13078. };
  13079. /**
  13080. * Update the current camera state depending on the inputs that have been used this frame.
  13081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13082. */
  13083. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13084. if (this._onKeyboardObserver) {
  13085. var camera = this.camera;
  13086. // Keyboard
  13087. for (var index = 0; index < this._keys.length; index++) {
  13088. var keyCode = this._keys[index];
  13089. var speed = camera._computeLocalCameraSpeed();
  13090. if (this.keysForward.indexOf(keyCode) !== -1) {
  13091. camera._localDirection.copyFromFloats(0, 0, speed);
  13092. }
  13093. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13094. camera._localDirection.copyFromFloats(0, 0, -speed);
  13095. }
  13096. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13097. camera._localDirection.copyFromFloats(0, speed, 0);
  13098. }
  13099. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13100. camera._localDirection.copyFromFloats(0, -speed, 0);
  13101. }
  13102. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13103. camera._localDirection.copyFromFloats(speed, 0, 0);
  13104. }
  13105. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13106. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13107. }
  13108. if (camera.getScene().useRightHandedSystem) {
  13109. camera._localDirection.z *= -1;
  13110. }
  13111. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13112. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13113. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13114. }
  13115. }
  13116. };
  13117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13119. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13122. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13125. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13128. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13129. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13131. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13132. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13134. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13135. return FlyCameraKeyboardInput;
  13136. }());
  13137. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13138. /***/ }),
  13139. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13140. /*!***********************************************!*\
  13141. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13142. \***********************************************/
  13143. /*! exports provided: FlyCameraMouseInput */
  13144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13145. "use strict";
  13146. __webpack_require__.r(__webpack_exports__);
  13147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13148. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13149. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13150. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13151. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13152. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13153. /**
  13154. * Listen to mouse events to control the camera.
  13155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13156. */
  13157. var FlyCameraMouseInput = /** @class */ (function () {
  13158. /**
  13159. * Listen to mouse events to control the camera.
  13160. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13162. */
  13163. function FlyCameraMouseInput(touchEnabled) {
  13164. if (touchEnabled === void 0) { touchEnabled = true; }
  13165. /**
  13166. * Defines the buttons associated with the input to handle camera rotation.
  13167. */
  13168. this.buttons = [0, 1, 2];
  13169. /**
  13170. * Assign buttons for Yaw control.
  13171. */
  13172. this.buttonsYaw = [-1, 0, 1];
  13173. /**
  13174. * Assign buttons for Pitch control.
  13175. */
  13176. this.buttonsPitch = [-1, 0, 1];
  13177. /**
  13178. * Assign buttons for Roll control.
  13179. */
  13180. this.buttonsRoll = [2];
  13181. /**
  13182. * Detect if any button is being pressed while mouse is moved.
  13183. * -1 = Mouse locked.
  13184. * 0 = Left button.
  13185. * 1 = Middle Button.
  13186. * 2 = Right Button.
  13187. */
  13188. this.activeButton = -1;
  13189. /**
  13190. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13191. * Higher values reduce its sensitivity.
  13192. */
  13193. this.angularSensibility = 1000.0;
  13194. this.previousPosition = null;
  13195. }
  13196. /**
  13197. * Attach the mouse control to the HTML DOM element.
  13198. * @param element Defines the element that listens to the input events.
  13199. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13200. */
  13201. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13202. var _this = this;
  13203. this.element = element;
  13204. this.noPreventDefault = noPreventDefault;
  13205. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13206. _this._pointerInput(p, s);
  13207. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13208. // Correct Roll by rate, if enabled.
  13209. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13210. if (_this.camera.rollCorrect) {
  13211. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13212. }
  13213. });
  13214. // Helper function to keep 'this'.
  13215. this._mousemoveCallback = function (e) {
  13216. _this._onMouseMove(e);
  13217. };
  13218. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13219. };
  13220. /**
  13221. * Detach the current controls from the specified dom element.
  13222. * @param element Defines the element to stop listening the inputs from
  13223. */
  13224. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13225. if (this._observer && element) {
  13226. this.camera.getScene().onPointerObservable.remove(this._observer);
  13227. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13228. if (this._mousemoveCallback) {
  13229. element.removeEventListener("mousemove", this._mousemoveCallback);
  13230. }
  13231. this._observer = null;
  13232. this._rollObserver = null;
  13233. this.previousPosition = null;
  13234. this.noPreventDefault = undefined;
  13235. }
  13236. };
  13237. /**
  13238. * Gets the class name of the current input.
  13239. * @returns the class name.
  13240. */
  13241. FlyCameraMouseInput.prototype.getClassName = function () {
  13242. return "FlyCameraMouseInput";
  13243. };
  13244. /**
  13245. * Get the friendly name associated with the input class.
  13246. * @returns the input's friendly name.
  13247. */
  13248. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13249. return "mouse";
  13250. };
  13251. // Track mouse movement, when the pointer is not locked.
  13252. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13253. var e = p.event;
  13254. var camera = this.camera;
  13255. var engine = camera.getEngine();
  13256. if (engine.isInVRExclusivePointerMode) {
  13257. return;
  13258. }
  13259. if (!this.touchEnabled && e.pointerType === "touch") {
  13260. return;
  13261. }
  13262. // Mouse is moved but an unknown mouse button is pressed.
  13263. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13264. return;
  13265. }
  13266. var srcElement = (e.srcElement || e.target);
  13267. // Mouse down.
  13268. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13269. try {
  13270. srcElement.setPointerCapture(e.pointerId);
  13271. }
  13272. catch (e) {
  13273. // Nothing to do with the error. Execution continues.
  13274. }
  13275. this.previousPosition = {
  13276. x: e.clientX,
  13277. y: e.clientY
  13278. };
  13279. this.activeButton = e.button;
  13280. if (!this.noPreventDefault) {
  13281. e.preventDefault();
  13282. this.element.focus();
  13283. }
  13284. }
  13285. else
  13286. // Mouse up.
  13287. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13288. try {
  13289. srcElement.releasePointerCapture(e.pointerId);
  13290. }
  13291. catch (e) {
  13292. // Nothing to do with the error. Execution continues.
  13293. }
  13294. this.activeButton = -1;
  13295. this.previousPosition = null;
  13296. if (!this.noPreventDefault) {
  13297. e.preventDefault();
  13298. }
  13299. }
  13300. else
  13301. // Mouse move.
  13302. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13303. if (!this.previousPosition || engine.isPointerLock) {
  13304. return;
  13305. }
  13306. var offsetX = e.clientX - this.previousPosition.x;
  13307. var offsetY = e.clientY - this.previousPosition.y;
  13308. this.rotateCamera(offsetX, offsetY);
  13309. this.previousPosition = {
  13310. x: e.clientX,
  13311. y: e.clientY
  13312. };
  13313. if (!this.noPreventDefault) {
  13314. e.preventDefault();
  13315. }
  13316. }
  13317. };
  13318. // Track mouse movement, when pointer is locked.
  13319. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13320. var camera = this.camera;
  13321. var engine = camera.getEngine();
  13322. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13323. return;
  13324. }
  13325. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13326. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13327. this.rotateCamera(offsetX, offsetY);
  13328. this.previousPosition = null;
  13329. if (!this.noPreventDefault) {
  13330. e.preventDefault();
  13331. }
  13332. };
  13333. /**
  13334. * Rotate camera by mouse offset.
  13335. */
  13336. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13337. var _this = this;
  13338. var camera = this.camera;
  13339. var scene = this.camera.getScene();
  13340. if (scene.useRightHandedSystem) {
  13341. offsetX *= -1;
  13342. }
  13343. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13344. offsetX *= -1;
  13345. }
  13346. var x = offsetX / this.angularSensibility;
  13347. var y = offsetY / this.angularSensibility;
  13348. // Initialize to current rotation.
  13349. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13350. var rotationChange;
  13351. // Pitch.
  13352. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13353. // Apply change in Radians to vector Angle.
  13354. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13355. // Apply Pitch to quaternion.
  13356. currentRotation.multiplyInPlace(rotationChange);
  13357. }
  13358. // Yaw.
  13359. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13360. // Apply change in Radians to vector Angle.
  13361. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13362. // Apply Yaw to quaternion.
  13363. currentRotation.multiplyInPlace(rotationChange);
  13364. // Add Roll, if banked turning is enabled, within Roll limit.
  13365. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13366. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13367. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13368. // Apply change in Radians to vector Angle.
  13369. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13370. // Apply Yaw to quaternion.
  13371. currentRotation.multiplyInPlace(rotationChange);
  13372. }
  13373. }
  13374. // Roll.
  13375. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13376. // Apply change in Radians to vector Angle.
  13377. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13378. // Track Rolling.
  13379. camera._trackRoll -= x;
  13380. // Apply Pitch to quaternion.
  13381. currentRotation.multiplyInPlace(rotationChange);
  13382. }
  13383. // Apply rotationQuaternion to Euler camera.rotation.
  13384. currentRotation.toEulerAnglesToRef(camera.rotation);
  13385. };
  13386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13388. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13389. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13390. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13391. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13392. return FlyCameraMouseInput;
  13393. }());
  13394. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13395. /***/ }),
  13396. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13397. /*!*********************************************************!*\
  13398. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13399. \*********************************************************/
  13400. /*! exports provided: FollowCameraKeyboardMoveInput */
  13401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13402. "use strict";
  13403. __webpack_require__.r(__webpack_exports__);
  13404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13406. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13407. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13408. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13409. /**
  13410. * Manage the keyboard inputs to control the movement of a follow camera.
  13411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13412. */
  13413. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13414. function FollowCameraKeyboardMoveInput() {
  13415. /**
  13416. * Defines the list of key codes associated with the up action (increase heightOffset)
  13417. */
  13418. this.keysHeightOffsetIncr = [38];
  13419. /**
  13420. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13421. */
  13422. this.keysHeightOffsetDecr = [40];
  13423. /**
  13424. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13425. */
  13426. this.keysHeightOffsetModifierAlt = false;
  13427. /**
  13428. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13429. */
  13430. this.keysHeightOffsetModifierCtrl = false;
  13431. /**
  13432. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13433. */
  13434. this.keysHeightOffsetModifierShift = false;
  13435. /**
  13436. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13437. */
  13438. this.keysRotationOffsetIncr = [37];
  13439. /**
  13440. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13441. */
  13442. this.keysRotationOffsetDecr = [39];
  13443. /**
  13444. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13445. */
  13446. this.keysRotationOffsetModifierAlt = false;
  13447. /**
  13448. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13449. */
  13450. this.keysRotationOffsetModifierCtrl = false;
  13451. /**
  13452. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13453. */
  13454. this.keysRotationOffsetModifierShift = false;
  13455. /**
  13456. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13457. */
  13458. this.keysRadiusIncr = [40];
  13459. /**
  13460. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13461. */
  13462. this.keysRadiusDecr = [38];
  13463. /**
  13464. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13465. */
  13466. this.keysRadiusModifierAlt = true;
  13467. /**
  13468. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13469. */
  13470. this.keysRadiusModifierCtrl = false;
  13471. /**
  13472. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13473. */
  13474. this.keysRadiusModifierShift = false;
  13475. /**
  13476. * Defines the rate of change of heightOffset.
  13477. */
  13478. this.heightSensibility = 1;
  13479. /**
  13480. * Defines the rate of change of rotationOffset.
  13481. */
  13482. this.rotationSensibility = 1;
  13483. /**
  13484. * Defines the rate of change of radius.
  13485. */
  13486. this.radiusSensibility = 1;
  13487. this._keys = new Array();
  13488. }
  13489. /**
  13490. * Attach the input controls to a specific dom element to get the input from.
  13491. * @param element Defines the element the controls should be listened from
  13492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13493. */
  13494. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13495. var _this = this;
  13496. if (this._onCanvasBlurObserver) {
  13497. return;
  13498. }
  13499. this._scene = this.camera.getScene();
  13500. this._engine = this._scene.getEngine();
  13501. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13502. _this._keys = [];
  13503. });
  13504. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13505. var evt = info.event;
  13506. if (!evt.metaKey) {
  13507. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13508. _this._ctrlPressed = evt.ctrlKey;
  13509. _this._altPressed = evt.altKey;
  13510. _this._shiftPressed = evt.shiftKey;
  13511. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13512. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13513. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13514. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13515. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13516. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13517. var index = _this._keys.indexOf(evt.keyCode);
  13518. if (index === -1) {
  13519. _this._keys.push(evt.keyCode);
  13520. }
  13521. if (evt.preventDefault) {
  13522. if (!noPreventDefault) {
  13523. evt.preventDefault();
  13524. }
  13525. }
  13526. }
  13527. }
  13528. else {
  13529. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13530. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13531. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13532. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13533. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13534. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13535. var index = _this._keys.indexOf(evt.keyCode);
  13536. if (index >= 0) {
  13537. _this._keys.splice(index, 1);
  13538. }
  13539. if (evt.preventDefault) {
  13540. if (!noPreventDefault) {
  13541. evt.preventDefault();
  13542. }
  13543. }
  13544. }
  13545. }
  13546. }
  13547. });
  13548. };
  13549. /**
  13550. * Detach the current controls from the specified dom element.
  13551. * @param element Defines the element to stop listening the inputs from
  13552. */
  13553. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13554. if (this._scene) {
  13555. if (this._onKeyboardObserver) {
  13556. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13557. }
  13558. if (this._onCanvasBlurObserver) {
  13559. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13560. }
  13561. this._onKeyboardObserver = null;
  13562. this._onCanvasBlurObserver = null;
  13563. }
  13564. this._keys = [];
  13565. };
  13566. /**
  13567. * Update the current camera state depending on the inputs that have been used this frame.
  13568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13569. */
  13570. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13571. var _this = this;
  13572. if (this._onKeyboardObserver) {
  13573. this._keys.forEach(function (keyCode) {
  13574. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13575. _this._modifierHeightOffset()) {
  13576. _this.camera.heightOffset += _this.heightSensibility;
  13577. }
  13578. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13579. _this._modifierHeightOffset()) {
  13580. _this.camera.heightOffset -= _this.heightSensibility;
  13581. }
  13582. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13583. _this._modifierRotationOffset()) {
  13584. _this.camera.rotationOffset += _this.rotationSensibility;
  13585. _this.camera.rotationOffset %= 360;
  13586. }
  13587. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13588. _this._modifierRotationOffset()) {
  13589. _this.camera.rotationOffset -= _this.rotationSensibility;
  13590. _this.camera.rotationOffset %= 360;
  13591. }
  13592. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13593. _this._modifierRadius()) {
  13594. _this.camera.radius += _this.radiusSensibility;
  13595. }
  13596. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13597. _this._modifierRadius()) {
  13598. _this.camera.radius -= _this.radiusSensibility;
  13599. }
  13600. });
  13601. }
  13602. };
  13603. /**
  13604. * Gets the class name of the current input.
  13605. * @returns the class name
  13606. */
  13607. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13608. return "FollowCameraKeyboardMoveInput";
  13609. };
  13610. /**
  13611. * Get the friendly name associated with the input class.
  13612. * @returns the input friendly name
  13613. */
  13614. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13615. return "keyboard";
  13616. };
  13617. /**
  13618. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13619. * allow modification of the heightOffset value.
  13620. */
  13621. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13622. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13623. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13624. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13625. };
  13626. /**
  13627. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13628. * allow modification of the rotationOffset value.
  13629. */
  13630. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13631. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13632. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13633. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13634. };
  13635. /**
  13636. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13637. * allow modification of the radius value.
  13638. */
  13639. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13640. return (this.keysRadiusModifierAlt === this._altPressed &&
  13641. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13642. this.keysRadiusModifierShift === this._shiftPressed);
  13643. };
  13644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13646. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13649. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13652. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13655. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13658. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13661. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13664. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13667. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13670. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13673. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13676. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13679. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13682. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13685. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13688. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13691. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13694. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13697. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13698. return FollowCameraKeyboardMoveInput;
  13699. }());
  13700. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13701. /***/ }),
  13702. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13703. /*!*******************************************************!*\
  13704. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13705. \*******************************************************/
  13706. /*! exports provided: FollowCameraMouseWheelInput */
  13707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13708. "use strict";
  13709. __webpack_require__.r(__webpack_exports__);
  13710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13711. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13712. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13713. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13714. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13715. /**
  13716. * Manage the mouse wheel inputs to control a follow camera.
  13717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13718. */
  13719. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13720. function FollowCameraMouseWheelInput() {
  13721. /**
  13722. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  13723. */
  13724. this.axisControlRadius = true;
  13725. /**
  13726. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  13727. */
  13728. this.axisControlHeight = false;
  13729. /**
  13730. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  13731. */
  13732. this.axisControlRotation = false;
  13733. /**
  13734. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13735. * relation to mouseWheel events.
  13736. */
  13737. this.wheelPrecision = 3.0;
  13738. /**
  13739. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13740. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13741. */
  13742. this.wheelDeltaPercentage = 0;
  13743. }
  13744. /**
  13745. * Attach the input controls to a specific dom element to get the input from.
  13746. * @param element Defines the element the controls should be listened from
  13747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13748. */
  13749. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13750. var _this = this;
  13751. this._wheel = function (p, s) {
  13752. // sanity check - this should be a PointerWheel event.
  13753. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13754. return;
  13755. }
  13756. var event = p.event;
  13757. var delta = 0;
  13758. // Chrome, Safari: event.deltaY
  13759. // IE: event.wheelDelta
  13760. // Firefox: event.detail (inverted)
  13761. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13762. if (_this.wheelDeltaPercentage) {
  13763. console.assert((_this.axisControlRadius +
  13764. _this.axisControlHeight +
  13765. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13766. "controlls ONE axis. " +
  13767. "Currently enabled: " +
  13768. "axisControlRadius: " + _this.axisControlRadius +
  13769. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13770. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13771. if (_this.axisControlRadius) {
  13772. delta =
  13773. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13774. _this.camera.radius;
  13775. }
  13776. else if (_this.axisControlHeight) {
  13777. delta =
  13778. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13779. _this.camera.heightOffset;
  13780. }
  13781. else if (_this.axisControlRotation) {
  13782. delta =
  13783. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13784. _this.camera.rotationOffset;
  13785. }
  13786. }
  13787. else {
  13788. delta = wheelDelta * _this.wheelPrecision;
  13789. }
  13790. if (delta) {
  13791. if (_this.axisControlRadius) {
  13792. _this.camera.radius += delta;
  13793. }
  13794. else if (_this.axisControlHeight) {
  13795. _this.camera.heightOffset -= delta;
  13796. }
  13797. else if (_this.axisControlRotation) {
  13798. _this.camera.rotationOffset -= delta;
  13799. }
  13800. }
  13801. if (event.preventDefault) {
  13802. if (!noPreventDefault) {
  13803. event.preventDefault();
  13804. }
  13805. }
  13806. };
  13807. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13808. };
  13809. /**
  13810. * Detach the current controls from the specified dom element.
  13811. * @param element Defines the element to stop listening the inputs from
  13812. */
  13813. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13814. if (this._observer && element) {
  13815. this.camera.getScene().onPointerObservable.remove(this._observer);
  13816. this._observer = null;
  13817. this._wheel = null;
  13818. }
  13819. };
  13820. /**
  13821. * Gets the class name of the current intput.
  13822. * @returns the class name
  13823. */
  13824. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13825. return "ArcRotateCameraMouseWheelInput";
  13826. };
  13827. /**
  13828. * Get the friendly name associated with the input class.
  13829. * @returns the input friendly name
  13830. */
  13831. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13832. return "mousewheel";
  13833. };
  13834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13836. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13839. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13842. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13845. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13848. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13849. return FollowCameraMouseWheelInput;
  13850. }());
  13851. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13852. /***/ }),
  13853. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13854. /*!************************************************************!*\
  13855. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13856. \************************************************************/
  13857. /*! exports provided: FreeCameraDeviceOrientationInput */
  13858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13859. "use strict";
  13860. __webpack_require__.r(__webpack_exports__);
  13861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13862. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13863. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13864. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13865. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  13866. /**
  13867. * Add orientation input support to the input manager.
  13868. * @returns the current input manager
  13869. */
  13870. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  13871. this.add(new FreeCameraDeviceOrientationInput());
  13872. return this;
  13873. };
  13874. /**
  13875. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13876. * Screen rotation is taken into account.
  13877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13878. */
  13879. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13880. /**
  13881. * Instantiates a new input
  13882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13883. */
  13884. function FreeCameraDeviceOrientationInput() {
  13885. var _this = this;
  13886. this._screenOrientationAngle = 0;
  13887. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13888. this._alpha = 0;
  13889. this._beta = 0;
  13890. this._gamma = 0;
  13891. this._orientationChanged = function () {
  13892. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13893. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13894. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13895. };
  13896. this._deviceOrientation = function (evt) {
  13897. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13898. _this._beta = evt.beta !== null ? evt.beta : 0;
  13899. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13900. };
  13901. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13902. this._orientationChanged();
  13903. }
  13904. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13905. /**
  13906. * Define the camera controlled by the input.
  13907. */
  13908. get: function () {
  13909. return this._camera;
  13910. },
  13911. set: function (camera) {
  13912. this._camera = camera;
  13913. if (this._camera != null && !this._camera.rotationQuaternion) {
  13914. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13915. }
  13916. },
  13917. enumerable: true,
  13918. configurable: true
  13919. });
  13920. /**
  13921. * Attach the input controls to a specific dom element to get the input from.
  13922. * @param element Defines the element the controls should be listened from
  13923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13924. */
  13925. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13926. window.addEventListener("orientationchange", this._orientationChanged);
  13927. window.addEventListener("deviceorientation", this._deviceOrientation);
  13928. //In certain cases, the attach control is called AFTER orientation was changed,
  13929. //So this is needed.
  13930. this._orientationChanged();
  13931. };
  13932. /**
  13933. * Detach the current controls from the specified dom element.
  13934. * @param element Defines the element to stop listening the inputs from
  13935. */
  13936. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13937. window.removeEventListener("orientationchange", this._orientationChanged);
  13938. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13939. };
  13940. /**
  13941. * Update the current camera state depending on the inputs that have been used this frame.
  13942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13943. */
  13944. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13945. //if no device orientation provided, don't update the rotation.
  13946. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13947. if (!this._alpha) {
  13948. return;
  13949. }
  13950. _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);
  13951. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13952. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13953. //Mirror on XY Plane
  13954. this._camera.rotationQuaternion.z *= -1;
  13955. this._camera.rotationQuaternion.w *= -1;
  13956. };
  13957. /**
  13958. * Gets the class name of the current intput.
  13959. * @returns the class name
  13960. */
  13961. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13962. return "FreeCameraDeviceOrientationInput";
  13963. };
  13964. /**
  13965. * Get the friendly name associated with the input class.
  13966. * @returns the input friendly name
  13967. */
  13968. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13969. return "deviceOrientation";
  13970. };
  13971. return FreeCameraDeviceOrientationInput;
  13972. }());
  13973. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13974. /***/ }),
  13975. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13976. /*!**************************************************!*\
  13977. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13978. \**************************************************/
  13979. /*! exports provided: FreeCameraGamepadInput */
  13980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13981. "use strict";
  13982. __webpack_require__.r(__webpack_exports__);
  13983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13984. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13985. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13986. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13987. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13988. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13989. /**
  13990. * Manage the gamepad inputs to control a free camera.
  13991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13992. */
  13993. var FreeCameraGamepadInput = /** @class */ (function () {
  13994. function FreeCameraGamepadInput() {
  13995. /**
  13996. * Defines the gamepad rotation sensiblity.
  13997. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13998. */
  13999. this.gamepadAngularSensibility = 200;
  14000. /**
  14001. * Defines the gamepad move sensiblity.
  14002. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14003. */
  14004. this.gamepadMoveSensibility = 40;
  14005. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14006. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14007. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14008. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14009. }
  14010. /**
  14011. * Attach the input controls to a specific dom element to get the input from.
  14012. * @param element Defines the element the controls should be listened from
  14013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14014. */
  14015. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14016. var _this = this;
  14017. var manager = this.camera.getScene().gamepadManager;
  14018. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14019. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14020. // prioritize XBOX gamepads.
  14021. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14022. _this.gamepad = gamepad;
  14023. }
  14024. }
  14025. });
  14026. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14027. if (_this.gamepad === gamepad) {
  14028. _this.gamepad = null;
  14029. }
  14030. });
  14031. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14032. };
  14033. /**
  14034. * Detach the current controls from the specified dom element.
  14035. * @param element Defines the element to stop listening the inputs from
  14036. */
  14037. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14038. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14039. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14040. this.gamepad = null;
  14041. };
  14042. /**
  14043. * Update the current camera state depending on the inputs that have been used this frame.
  14044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14045. */
  14046. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14047. if (this.gamepad && this.gamepad.leftStick) {
  14048. var camera = this.camera;
  14049. var LSValues = this.gamepad.leftStick;
  14050. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14051. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14052. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14053. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14054. var RSValues = this.gamepad.rightStick;
  14055. if (RSValues) {
  14056. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14057. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14058. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14059. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14060. }
  14061. else {
  14062. RSValues = { x: 0, y: 0 };
  14063. }
  14064. if (!camera.rotationQuaternion) {
  14065. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14066. }
  14067. else {
  14068. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14069. }
  14070. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14071. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14072. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14073. camera.cameraDirection.addInPlace(this._deltaTransform);
  14074. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14075. camera.cameraRotation.addInPlace(this._vector2);
  14076. }
  14077. };
  14078. /**
  14079. * Gets the class name of the current intput.
  14080. * @returns the class name
  14081. */
  14082. FreeCameraGamepadInput.prototype.getClassName = function () {
  14083. return "FreeCameraGamepadInput";
  14084. };
  14085. /**
  14086. * Get the friendly name associated with the input class.
  14087. * @returns the input friendly name
  14088. */
  14089. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14090. return "gamepad";
  14091. };
  14092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14094. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14097. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14098. return FreeCameraGamepadInput;
  14099. }());
  14100. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14101. /***/ }),
  14102. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14103. /*!*******************************************************!*\
  14104. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14105. \*******************************************************/
  14106. /*! exports provided: FreeCameraKeyboardMoveInput */
  14107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14108. "use strict";
  14109. __webpack_require__.r(__webpack_exports__);
  14110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14111. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14112. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14113. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14114. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14115. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14116. /**
  14117. * Manage the keyboard inputs to control the movement of a free camera.
  14118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14119. */
  14120. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14121. function FreeCameraKeyboardMoveInput() {
  14122. /**
  14123. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14124. */
  14125. this.keysUp = [38];
  14126. /**
  14127. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14128. */
  14129. this.keysDown = [40];
  14130. /**
  14131. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14132. */
  14133. this.keysLeft = [37];
  14134. /**
  14135. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14136. */
  14137. this.keysRight = [39];
  14138. this._keys = new Array();
  14139. }
  14140. /**
  14141. * Attach the input controls to a specific dom element to get the input from.
  14142. * @param element Defines the element the controls should be listened from
  14143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14144. */
  14145. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14146. var _this = this;
  14147. if (this._onCanvasBlurObserver) {
  14148. return;
  14149. }
  14150. this._scene = this.camera.getScene();
  14151. this._engine = this._scene.getEngine();
  14152. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14153. _this._keys = [];
  14154. });
  14155. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14156. var evt = info.event;
  14157. if (!evt.metaKey) {
  14158. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14159. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14160. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14161. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14162. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14163. var index = _this._keys.indexOf(evt.keyCode);
  14164. if (index === -1) {
  14165. _this._keys.push(evt.keyCode);
  14166. }
  14167. if (!noPreventDefault) {
  14168. evt.preventDefault();
  14169. }
  14170. }
  14171. }
  14172. else {
  14173. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14174. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14175. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14176. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14177. var index = _this._keys.indexOf(evt.keyCode);
  14178. if (index >= 0) {
  14179. _this._keys.splice(index, 1);
  14180. }
  14181. if (!noPreventDefault) {
  14182. evt.preventDefault();
  14183. }
  14184. }
  14185. }
  14186. }
  14187. });
  14188. };
  14189. /**
  14190. * Detach the current controls from the specified dom element.
  14191. * @param element Defines the element to stop listening the inputs from
  14192. */
  14193. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14194. if (this._scene) {
  14195. if (this._onKeyboardObserver) {
  14196. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14197. }
  14198. if (this._onCanvasBlurObserver) {
  14199. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14200. }
  14201. this._onKeyboardObserver = null;
  14202. this._onCanvasBlurObserver = null;
  14203. }
  14204. this._keys = [];
  14205. };
  14206. /**
  14207. * Update the current camera state depending on the inputs that have been used this frame.
  14208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14209. */
  14210. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14211. if (this._onKeyboardObserver) {
  14212. var camera = this.camera;
  14213. // Keyboard
  14214. for (var index = 0; index < this._keys.length; index++) {
  14215. var keyCode = this._keys[index];
  14216. var speed = camera._computeLocalCameraSpeed();
  14217. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14218. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14219. }
  14220. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14221. camera._localDirection.copyFromFloats(0, 0, speed);
  14222. }
  14223. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14224. camera._localDirection.copyFromFloats(speed, 0, 0);
  14225. }
  14226. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14227. camera._localDirection.copyFromFloats(0, 0, -speed);
  14228. }
  14229. if (camera.getScene().useRightHandedSystem) {
  14230. camera._localDirection.z *= -1;
  14231. }
  14232. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14233. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14234. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14235. }
  14236. }
  14237. };
  14238. /**
  14239. * Gets the class name of the current intput.
  14240. * @returns the class name
  14241. */
  14242. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14243. return "FreeCameraKeyboardMoveInput";
  14244. };
  14245. /** @hidden */
  14246. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14247. this._keys = [];
  14248. };
  14249. /**
  14250. * Get the friendly name associated with the input class.
  14251. * @returns the input friendly name
  14252. */
  14253. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14254. return "keyboard";
  14255. };
  14256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14258. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14261. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14264. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14267. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14268. return FreeCameraKeyboardMoveInput;
  14269. }());
  14270. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14271. /***/ }),
  14272. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14273. /*!************************************************!*\
  14274. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14275. \************************************************/
  14276. /*! exports provided: FreeCameraMouseInput */
  14277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14278. "use strict";
  14279. __webpack_require__.r(__webpack_exports__);
  14280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14281. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14282. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14283. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14284. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14285. /**
  14286. * Manage the mouse inputs to control the movement of a free camera.
  14287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14288. */
  14289. var FreeCameraMouseInput = /** @class */ (function () {
  14290. /**
  14291. * Manage the mouse inputs to control the movement of a free camera.
  14292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14293. * @param touchEnabled Defines if touch is enabled or not
  14294. */
  14295. function FreeCameraMouseInput(
  14296. /**
  14297. * Define if touch is enabled in the mouse input
  14298. */
  14299. touchEnabled) {
  14300. if (touchEnabled === void 0) { touchEnabled = true; }
  14301. this.touchEnabled = touchEnabled;
  14302. /**
  14303. * Defines the buttons associated with the input to handle camera move.
  14304. */
  14305. this.buttons = [0, 1, 2];
  14306. /**
  14307. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14308. */
  14309. this.angularSensibility = 2000.0;
  14310. this.previousPosition = null;
  14311. }
  14312. /**
  14313. * Attach the input controls to a specific dom element to get the input from.
  14314. * @param element Defines the element the controls should be listened from
  14315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14316. */
  14317. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14318. var _this = this;
  14319. var engine = this.camera.getEngine();
  14320. if (!this._pointerInput) {
  14321. this._pointerInput = function (p) {
  14322. var evt = p.event;
  14323. if (engine.isInVRExclusivePointerMode) {
  14324. return;
  14325. }
  14326. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14327. return;
  14328. }
  14329. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14330. return;
  14331. }
  14332. var srcElement = (evt.srcElement || evt.target);
  14333. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14334. try {
  14335. srcElement.setPointerCapture(evt.pointerId);
  14336. }
  14337. catch (e) {
  14338. //Nothing to do with the error. Execution will continue.
  14339. }
  14340. _this.previousPosition = {
  14341. x: evt.clientX,
  14342. y: evt.clientY
  14343. };
  14344. if (!noPreventDefault) {
  14345. evt.preventDefault();
  14346. element.focus();
  14347. }
  14348. }
  14349. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14350. try {
  14351. srcElement.releasePointerCapture(evt.pointerId);
  14352. }
  14353. catch (e) {
  14354. //Nothing to do with the error.
  14355. }
  14356. _this.previousPosition = null;
  14357. if (!noPreventDefault) {
  14358. evt.preventDefault();
  14359. }
  14360. }
  14361. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14362. if (!_this.previousPosition || engine.isPointerLock) {
  14363. return;
  14364. }
  14365. var offsetX = evt.clientX - _this.previousPosition.x;
  14366. if (_this.camera.getScene().useRightHandedSystem) {
  14367. offsetX *= -1;
  14368. }
  14369. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14370. offsetX *= -1;
  14371. }
  14372. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14373. var offsetY = evt.clientY - _this.previousPosition.y;
  14374. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14375. _this.previousPosition = {
  14376. x: evt.clientX,
  14377. y: evt.clientY
  14378. };
  14379. if (!noPreventDefault) {
  14380. evt.preventDefault();
  14381. }
  14382. }
  14383. };
  14384. }
  14385. this._onMouseMove = function (evt) {
  14386. if (!engine.isPointerLock) {
  14387. return;
  14388. }
  14389. if (engine.isInVRExclusivePointerMode) {
  14390. return;
  14391. }
  14392. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14393. if (_this.camera.getScene().useRightHandedSystem) {
  14394. offsetX *= -1;
  14395. }
  14396. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14397. offsetX *= -1;
  14398. }
  14399. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14400. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14401. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14402. _this.previousPosition = null;
  14403. if (!noPreventDefault) {
  14404. evt.preventDefault();
  14405. }
  14406. };
  14407. 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);
  14408. element.addEventListener("mousemove", this._onMouseMove, false);
  14409. };
  14410. /**
  14411. * Detach the current controls from the specified dom element.
  14412. * @param element Defines the element to stop listening the inputs from
  14413. */
  14414. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14415. if (this._observer && element) {
  14416. this.camera.getScene().onPointerObservable.remove(this._observer);
  14417. if (this._onMouseMove) {
  14418. element.removeEventListener("mousemove", this._onMouseMove);
  14419. }
  14420. this._observer = null;
  14421. this._onMouseMove = null;
  14422. this.previousPosition = null;
  14423. }
  14424. };
  14425. /**
  14426. * Gets the class name of the current intput.
  14427. * @returns the class name
  14428. */
  14429. FreeCameraMouseInput.prototype.getClassName = function () {
  14430. return "FreeCameraMouseInput";
  14431. };
  14432. /**
  14433. * Get the friendly name associated with the input class.
  14434. * @returns the input friendly name
  14435. */
  14436. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14437. return "mouse";
  14438. };
  14439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14441. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14444. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14445. return FreeCameraMouseInput;
  14446. }());
  14447. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14448. /***/ }),
  14449. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14450. /*!************************************************!*\
  14451. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14452. \************************************************/
  14453. /*! exports provided: FreeCameraTouchInput */
  14454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14455. "use strict";
  14456. __webpack_require__.r(__webpack_exports__);
  14457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14459. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14460. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14461. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14462. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14463. /**
  14464. * Manage the touch inputs to control the movement of a free camera.
  14465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14466. */
  14467. var FreeCameraTouchInput = /** @class */ (function () {
  14468. function FreeCameraTouchInput() {
  14469. /**
  14470. * Defines the touch sensibility for rotation.
  14471. * The higher the faster.
  14472. */
  14473. this.touchAngularSensibility = 200000.0;
  14474. /**
  14475. * Defines the touch sensibility for move.
  14476. * The higher the faster.
  14477. */
  14478. this.touchMoveSensibility = 250.0;
  14479. this._offsetX = null;
  14480. this._offsetY = null;
  14481. this._pointerPressed = new Array();
  14482. }
  14483. /**
  14484. * Attach the input controls to a specific dom element to get the input from.
  14485. * @param element Defines the element the controls should be listened from
  14486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14487. */
  14488. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14489. var _this = this;
  14490. var previousPosition = null;
  14491. if (this._pointerInput === undefined) {
  14492. this._onLostFocus = function () {
  14493. _this._offsetX = null;
  14494. _this._offsetY = null;
  14495. };
  14496. this._pointerInput = function (p) {
  14497. var evt = p.event;
  14498. if (evt.pointerType === "mouse") {
  14499. return;
  14500. }
  14501. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14502. if (!noPreventDefault) {
  14503. evt.preventDefault();
  14504. }
  14505. _this._pointerPressed.push(evt.pointerId);
  14506. if (_this._pointerPressed.length !== 1) {
  14507. return;
  14508. }
  14509. previousPosition = {
  14510. x: evt.clientX,
  14511. y: evt.clientY
  14512. };
  14513. }
  14514. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14515. if (!noPreventDefault) {
  14516. evt.preventDefault();
  14517. }
  14518. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14519. if (index === -1) {
  14520. return;
  14521. }
  14522. _this._pointerPressed.splice(index, 1);
  14523. if (index != 0) {
  14524. return;
  14525. }
  14526. previousPosition = null;
  14527. _this._offsetX = null;
  14528. _this._offsetY = null;
  14529. }
  14530. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14531. if (!noPreventDefault) {
  14532. evt.preventDefault();
  14533. }
  14534. if (!previousPosition) {
  14535. return;
  14536. }
  14537. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14538. if (index != 0) {
  14539. return;
  14540. }
  14541. _this._offsetX = evt.clientX - previousPosition.x;
  14542. _this._offsetY = -(evt.clientY - previousPosition.y);
  14543. }
  14544. };
  14545. }
  14546. 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);
  14547. if (this._onLostFocus) {
  14548. element.addEventListener("blur", this._onLostFocus);
  14549. }
  14550. };
  14551. /**
  14552. * Detach the current controls from the specified dom element.
  14553. * @param element Defines the element to stop listening the inputs from
  14554. */
  14555. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14556. if (this._pointerInput && element) {
  14557. if (this._observer) {
  14558. this.camera.getScene().onPointerObservable.remove(this._observer);
  14559. this._observer = null;
  14560. }
  14561. if (this._onLostFocus) {
  14562. element.removeEventListener("blur", this._onLostFocus);
  14563. this._onLostFocus = null;
  14564. }
  14565. this._pointerPressed = [];
  14566. this._offsetX = null;
  14567. this._offsetY = null;
  14568. }
  14569. };
  14570. /**
  14571. * Update the current camera state depending on the inputs that have been used this frame.
  14572. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14573. */
  14574. FreeCameraTouchInput.prototype.checkInputs = function () {
  14575. if (this._offsetX && this._offsetY) {
  14576. var camera = this.camera;
  14577. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14578. if (this._pointerPressed.length > 1) {
  14579. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14580. }
  14581. else {
  14582. var speed = camera._computeLocalCameraSpeed();
  14583. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14584. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14585. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14586. }
  14587. }
  14588. };
  14589. /**
  14590. * Gets the class name of the current intput.
  14591. * @returns the class name
  14592. */
  14593. FreeCameraTouchInput.prototype.getClassName = function () {
  14594. return "FreeCameraTouchInput";
  14595. };
  14596. /**
  14597. * Get the friendly name associated with the input class.
  14598. * @returns the input friendly name
  14599. */
  14600. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14601. return "touch";
  14602. };
  14603. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14604. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14605. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14606. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14608. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14609. return FreeCameraTouchInput;
  14610. }());
  14611. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14612. /***/ }),
  14613. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14614. /*!**********************************************************!*\
  14615. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14616. \**********************************************************/
  14617. /*! exports provided: FreeCameraVirtualJoystickInput */
  14618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14619. "use strict";
  14620. __webpack_require__.r(__webpack_exports__);
  14621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14622. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14623. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14624. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14625. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14626. /**
  14627. * Add virtual joystick input support to the input manager.
  14628. * @returns the current input manager
  14629. */
  14630. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14631. this.add(new FreeCameraVirtualJoystickInput());
  14632. return this;
  14633. };
  14634. /**
  14635. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14637. */
  14638. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14639. function FreeCameraVirtualJoystickInput() {
  14640. }
  14641. /**
  14642. * Gets the left stick of the virtual joystick.
  14643. * @returns The virtual Joystick
  14644. */
  14645. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14646. return this._leftjoystick;
  14647. };
  14648. /**
  14649. * Gets the right stick of the virtual joystick.
  14650. * @returns The virtual Joystick
  14651. */
  14652. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14653. return this._rightjoystick;
  14654. };
  14655. /**
  14656. * Update the current camera state depending on the inputs that have been used this frame.
  14657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14658. */
  14659. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14660. if (this._leftjoystick) {
  14661. var camera = this.camera;
  14662. var speed = camera._computeLocalCameraSpeed() * 50;
  14663. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14664. 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);
  14665. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14666. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14667. if (!this._leftjoystick.pressed) {
  14668. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14669. }
  14670. if (!this._rightjoystick.pressed) {
  14671. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14672. }
  14673. }
  14674. };
  14675. /**
  14676. * Attach the input controls to a specific dom element to get the input from.
  14677. * @param element Defines the element the controls should be listened from
  14678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14679. */
  14680. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14681. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14682. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14683. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14684. this._leftjoystick.setJoystickSensibility(0.15);
  14685. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14686. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14687. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14688. this._rightjoystick.reverseUpDown = true;
  14689. this._rightjoystick.setJoystickSensibility(0.05);
  14690. this._rightjoystick.setJoystickColor("yellow");
  14691. };
  14692. /**
  14693. * Detach the current controls from the specified dom element.
  14694. * @param element Defines the element to stop listening the inputs from
  14695. */
  14696. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14697. this._leftjoystick.releaseCanvas();
  14698. this._rightjoystick.releaseCanvas();
  14699. };
  14700. /**
  14701. * Gets the class name of the current intput.
  14702. * @returns the class name
  14703. */
  14704. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14705. return "FreeCameraVirtualJoystickInput";
  14706. };
  14707. /**
  14708. * Get the friendly name associated with the input class.
  14709. * @returns the input friendly name
  14710. */
  14711. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14712. return "virtualJoystick";
  14713. };
  14714. return FreeCameraVirtualJoystickInput;
  14715. }());
  14716. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14717. /***/ }),
  14718. /***/ "./Cameras/Inputs/index.ts":
  14719. /*!*********************************!*\
  14720. !*** ./Cameras/Inputs/index.ts ***!
  14721. \*********************************/
  14722. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14724. "use strict";
  14725. __webpack_require__.r(__webpack_exports__);
  14726. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14728. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14730. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14732. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14734. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14736. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14738. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14740. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14742. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14744. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14746. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14748. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14750. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14752. /***/ }),
  14753. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  14754. /*!*********************************************************!*\
  14755. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  14756. \*********************************************************/
  14757. /*! no exports provided */
  14758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14759. "use strict";
  14760. __webpack_require__.r(__webpack_exports__);
  14761. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14762. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14763. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  14764. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  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_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  14767. };
  14768. /***/ }),
  14769. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  14770. /*!*************************************************!*\
  14771. !*** ./Cameras/RigModes/stereoscopicRigMode.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 _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14779. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  14780. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  14781. 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;
  14782. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14783. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  14784. };
  14785. /***/ }),
  14786. /***/ "./Cameras/RigModes/vrRigMode.ts":
  14787. /*!***************************************!*\
  14788. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  14789. \***************************************/
  14790. /*! no exports provided */
  14791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14792. "use strict";
  14793. __webpack_require__.r(__webpack_exports__);
  14794. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14795. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14796. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  14797. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14798. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  14799. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  14800. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  14801. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14802. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14803. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  14804. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  14805. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  14806. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  14807. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14808. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14809. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  14810. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  14811. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  14812. if (metrics.compensateDistortion) {
  14813. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  14814. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  14815. }
  14816. };
  14817. /***/ }),
  14818. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  14819. /*!******************************************!*\
  14820. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  14821. \******************************************/
  14822. /*! no exports provided */
  14823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14824. "use strict";
  14825. __webpack_require__.r(__webpack_exports__);
  14826. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14827. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14828. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  14829. if (rigParams.vrDisplay) {
  14830. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  14831. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  14832. //Left eye
  14833. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14834. camera._rigCameras[0].setCameraRigParameter("left", true);
  14835. //leaving this for future reference
  14836. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  14837. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  14838. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  14839. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14840. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14841. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14842. camera._rigCameras[0].parent = camera;
  14843. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  14844. //Right eye
  14845. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14846. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  14847. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  14848. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  14849. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14850. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14851. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14852. camera._rigCameras[1].parent = camera;
  14853. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  14854. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  14855. camera._rigCameras[1]._skipRendering = true;
  14856. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  14857. }
  14858. }
  14859. };
  14860. /***/ }),
  14861. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14862. /*!*********************************************************!*\
  14863. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14864. \*********************************************************/
  14865. /*! exports provided: AnaglyphArcRotateCamera */
  14866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14867. "use strict";
  14868. __webpack_require__.r(__webpack_exports__);
  14869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14870. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14871. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14872. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14873. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14874. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14875. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14876. // Side effect import to define the stereoscopic mode.
  14877. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14878. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14879. });
  14880. /**
  14881. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14882. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14883. */
  14884. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14885. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14886. /**
  14887. * Creates a new AnaglyphArcRotateCamera
  14888. * @param name defines camera name
  14889. * @param alpha defines alpha angle (in radians)
  14890. * @param beta defines beta angle (in radians)
  14891. * @param radius defines radius
  14892. * @param target defines camera target
  14893. * @param interaxialDistance defines distance between each color axis
  14894. * @param scene defines the hosting scene
  14895. */
  14896. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14897. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14898. _this.interaxialDistance = interaxialDistance;
  14899. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14900. return _this;
  14901. }
  14902. /**
  14903. * Gets camera class name
  14904. * @returns AnaglyphArcRotateCamera
  14905. */
  14906. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14907. return "AnaglyphArcRotateCamera";
  14908. };
  14909. return AnaglyphArcRotateCamera;
  14910. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14911. /***/ }),
  14912. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14913. /*!****************************************************!*\
  14914. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14915. \****************************************************/
  14916. /*! exports provided: AnaglyphFreeCamera */
  14917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14918. "use strict";
  14919. __webpack_require__.r(__webpack_exports__);
  14920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14921. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14922. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14923. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14924. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14925. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14926. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14927. // Side effect import to define the stereoscopic mode.
  14928. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14929. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14930. });
  14931. /**
  14932. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14933. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14934. */
  14935. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14936. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14937. /**
  14938. * Creates a new AnaglyphFreeCamera
  14939. * @param name defines camera name
  14940. * @param position defines initial position
  14941. * @param interaxialDistance defines distance between each color axis
  14942. * @param scene defines the hosting scene
  14943. */
  14944. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14945. var _this = _super.call(this, name, position, scene) || this;
  14946. _this.interaxialDistance = interaxialDistance;
  14947. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14948. return _this;
  14949. }
  14950. /**
  14951. * Gets camera class name
  14952. * @returns AnaglyphFreeCamera
  14953. */
  14954. AnaglyphFreeCamera.prototype.getClassName = function () {
  14955. return "AnaglyphFreeCamera";
  14956. };
  14957. return AnaglyphFreeCamera;
  14958. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14959. /***/ }),
  14960. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14961. /*!*******************************************************!*\
  14962. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14963. \*******************************************************/
  14964. /*! exports provided: AnaglyphGamepadCamera */
  14965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14966. "use strict";
  14967. __webpack_require__.r(__webpack_exports__);
  14968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14969. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14970. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14971. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14972. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14973. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14974. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14975. // Side effect import to define the stereoscopic mode.
  14976. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14977. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14978. });
  14979. /**
  14980. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14981. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14982. */
  14983. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14984. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14985. /**
  14986. * Creates a new AnaglyphGamepadCamera
  14987. * @param name defines camera name
  14988. * @param position defines initial position
  14989. * @param interaxialDistance defines distance between each color axis
  14990. * @param scene defines the hosting scene
  14991. */
  14992. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14993. var _this = _super.call(this, name, position, scene) || this;
  14994. _this.interaxialDistance = interaxialDistance;
  14995. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14996. return _this;
  14997. }
  14998. /**
  14999. * Gets camera class name
  15000. * @returns AnaglyphGamepadCamera
  15001. */
  15002. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15003. return "AnaglyphGamepadCamera";
  15004. };
  15005. return AnaglyphGamepadCamera;
  15006. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15007. /***/ }),
  15008. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15009. /*!*********************************************************!*\
  15010. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15011. \*********************************************************/
  15012. /*! exports provided: AnaglyphUniversalCamera */
  15013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15014. "use strict";
  15015. __webpack_require__.r(__webpack_exports__);
  15016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15018. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15019. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15020. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15021. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15022. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15023. // Side effect import to define the stereoscopic mode.
  15024. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15025. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15026. });
  15027. /**
  15028. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15029. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15030. */
  15031. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15032. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15033. /**
  15034. * Creates a new AnaglyphUniversalCamera
  15035. * @param name defines camera name
  15036. * @param position defines initial position
  15037. * @param interaxialDistance defines distance between each color axis
  15038. * @param scene defines the hosting scene
  15039. */
  15040. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15041. var _this = _super.call(this, name, position, scene) || this;
  15042. _this.interaxialDistance = interaxialDistance;
  15043. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15044. return _this;
  15045. }
  15046. /**
  15047. * Gets camera class name
  15048. * @returns AnaglyphUniversalCamera
  15049. */
  15050. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15051. return "AnaglyphUniversalCamera";
  15052. };
  15053. return AnaglyphUniversalCamera;
  15054. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15055. /***/ }),
  15056. /***/ "./Cameras/Stereoscopic/index.ts":
  15057. /*!***************************************!*\
  15058. !*** ./Cameras/Stereoscopic/index.ts ***!
  15059. \***************************************/
  15060. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15062. "use strict";
  15063. __webpack_require__.r(__webpack_exports__);
  15064. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15066. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15068. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15070. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15072. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15074. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15076. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15078. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15080. /***/ }),
  15081. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15082. /*!*************************************************************!*\
  15083. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15084. \*************************************************************/
  15085. /*! exports provided: StereoscopicArcRotateCamera */
  15086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15087. "use strict";
  15088. __webpack_require__.r(__webpack_exports__);
  15089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15090. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15091. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15092. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15093. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15094. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15095. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15096. // Side effect import to define the stereoscopic mode.
  15097. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15098. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15099. });
  15100. /**
  15101. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15102. * @see http://doc.babylonjs.com/features/cameras
  15103. */
  15104. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15105. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15106. /**
  15107. * Creates a new StereoscopicArcRotateCamera
  15108. * @param name defines camera name
  15109. * @param alpha defines alpha angle (in radians)
  15110. * @param beta defines beta angle (in radians)
  15111. * @param radius defines radius
  15112. * @param target defines camera target
  15113. * @param interaxialDistance defines distance between each color axis
  15114. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15115. * @param scene defines the hosting scene
  15116. */
  15117. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15118. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15119. _this.interaxialDistance = interaxialDistance;
  15120. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15121. _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 });
  15122. return _this;
  15123. }
  15124. /**
  15125. * Gets camera class name
  15126. * @returns StereoscopicArcRotateCamera
  15127. */
  15128. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15129. return "StereoscopicArcRotateCamera";
  15130. };
  15131. return StereoscopicArcRotateCamera;
  15132. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15133. /***/ }),
  15134. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15135. /*!********************************************************!*\
  15136. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15137. \********************************************************/
  15138. /*! exports provided: StereoscopicFreeCamera */
  15139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15140. "use strict";
  15141. __webpack_require__.r(__webpack_exports__);
  15142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15143. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15144. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15145. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15146. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15147. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15148. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15149. // Side effect import to define the stereoscopic mode.
  15150. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15151. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15152. });
  15153. /**
  15154. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15155. * @see http://doc.babylonjs.com/features/cameras
  15156. */
  15157. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15159. /**
  15160. * Creates a new StereoscopicFreeCamera
  15161. * @param name defines camera name
  15162. * @param position defines initial position
  15163. * @param interaxialDistance defines distance between each color axis
  15164. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15165. * @param scene defines the hosting scene
  15166. */
  15167. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15168. var _this = _super.call(this, name, position, scene) || this;
  15169. _this.interaxialDistance = interaxialDistance;
  15170. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15171. _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 });
  15172. return _this;
  15173. }
  15174. /**
  15175. * Gets camera class name
  15176. * @returns StereoscopicFreeCamera
  15177. */
  15178. StereoscopicFreeCamera.prototype.getClassName = function () {
  15179. return "StereoscopicFreeCamera";
  15180. };
  15181. return StereoscopicFreeCamera;
  15182. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15183. /***/ }),
  15184. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15185. /*!***********************************************************!*\
  15186. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15187. \***********************************************************/
  15188. /*! exports provided: StereoscopicGamepadCamera */
  15189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15190. "use strict";
  15191. __webpack_require__.r(__webpack_exports__);
  15192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15193. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15194. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15195. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15196. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15197. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15198. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15199. // Side effect import to define the stereoscopic mode.
  15200. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15201. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15202. });
  15203. /**
  15204. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15205. * @see http://doc.babylonjs.com/features/cameras
  15206. */
  15207. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15208. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15209. /**
  15210. * Creates a new StereoscopicGamepadCamera
  15211. * @param name defines camera name
  15212. * @param position defines initial position
  15213. * @param interaxialDistance defines distance between each color axis
  15214. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15215. * @param scene defines the hosting scene
  15216. */
  15217. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15218. var _this = _super.call(this, name, position, scene) || this;
  15219. _this.interaxialDistance = interaxialDistance;
  15220. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15221. _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 });
  15222. return _this;
  15223. }
  15224. /**
  15225. * Gets camera class name
  15226. * @returns StereoscopicGamepadCamera
  15227. */
  15228. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15229. return "StereoscopicGamepadCamera";
  15230. };
  15231. return StereoscopicGamepadCamera;
  15232. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15233. /***/ }),
  15234. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15235. /*!*************************************************************!*\
  15236. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15237. \*************************************************************/
  15238. /*! exports provided: StereoscopicUniversalCamera */
  15239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15240. "use strict";
  15241. __webpack_require__.r(__webpack_exports__);
  15242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15243. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15244. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15245. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15246. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15247. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15248. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15249. // Side effect import to define the stereoscopic mode.
  15250. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15251. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15252. });
  15253. /**
  15254. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15255. * @see http://doc.babylonjs.com/features/cameras
  15256. */
  15257. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15258. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15259. /**
  15260. * Creates a new StereoscopicUniversalCamera
  15261. * @param name defines camera name
  15262. * @param position defines initial position
  15263. * @param interaxialDistance defines distance between each color axis
  15264. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15265. * @param scene defines the hosting scene
  15266. */
  15267. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15268. var _this = _super.call(this, name, position, scene) || this;
  15269. _this.interaxialDistance = interaxialDistance;
  15270. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15271. _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 });
  15272. return _this;
  15273. }
  15274. /**
  15275. * Gets camera class name
  15276. * @returns StereoscopicUniversalCamera
  15277. */
  15278. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15279. return "StereoscopicUniversalCamera";
  15280. };
  15281. return StereoscopicUniversalCamera;
  15282. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15283. /***/ }),
  15284. /***/ "./Cameras/VR/index.ts":
  15285. /*!*****************************!*\
  15286. !*** ./Cameras/VR/index.ts ***!
  15287. \*****************************/
  15288. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  15289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15290. "use strict";
  15291. __webpack_require__.r(__webpack_exports__);
  15292. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15294. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15296. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15298. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15300. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15302. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15304. /***/ }),
  15305. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15306. /*!***************************************!*\
  15307. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15308. \***************************************/
  15309. /*! exports provided: VRCameraMetrics */
  15310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15311. "use strict";
  15312. __webpack_require__.r(__webpack_exports__);
  15313. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15314. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15315. /**
  15316. * This represents all the required metrics to create a VR camera.
  15317. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15318. */
  15319. var VRCameraMetrics = /** @class */ (function () {
  15320. function VRCameraMetrics() {
  15321. /**
  15322. * Define if the current vr camera should compensate the distortion of the lense or not.
  15323. */
  15324. this.compensateDistortion = true;
  15325. }
  15326. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15327. /**
  15328. * Gets the rendering aspect ratio based on the provided resolutions.
  15329. */
  15330. get: function () {
  15331. return this.hResolution / (2 * this.vResolution);
  15332. },
  15333. enumerable: true,
  15334. configurable: true
  15335. });
  15336. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15337. /**
  15338. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15339. */
  15340. get: function () {
  15341. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15342. },
  15343. enumerable: true,
  15344. configurable: true
  15345. });
  15346. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15347. /**
  15348. * @hidden
  15349. */
  15350. get: function () {
  15351. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15352. var h = (4 * meters) / this.hScreenSize;
  15353. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15354. },
  15355. enumerable: true,
  15356. configurable: true
  15357. });
  15358. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15359. /**
  15360. * @hidden
  15361. */
  15362. get: function () {
  15363. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15364. var h = (4 * meters) / this.hScreenSize;
  15365. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15366. },
  15367. enumerable: true,
  15368. configurable: true
  15369. });
  15370. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15371. /**
  15372. * @hidden
  15373. */
  15374. get: function () {
  15375. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15376. },
  15377. enumerable: true,
  15378. configurable: true
  15379. });
  15380. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15381. /**
  15382. * @hidden
  15383. */
  15384. get: function () {
  15385. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15386. },
  15387. enumerable: true,
  15388. configurable: true
  15389. });
  15390. /**
  15391. * Get the default VRMetrics based on the most generic setup.
  15392. * @returns the default vr metrics
  15393. */
  15394. VRCameraMetrics.GetDefault = function () {
  15395. var result = new VRCameraMetrics();
  15396. result.hResolution = 1280;
  15397. result.vResolution = 800;
  15398. result.hScreenSize = 0.149759993;
  15399. result.vScreenSize = 0.0935999975;
  15400. result.vScreenCenter = 0.0467999987;
  15401. result.eyeToScreenDistance = 0.0410000011;
  15402. result.lensSeparationDistance = 0.0635000020;
  15403. result.interpupillaryDistance = 0.0640000030;
  15404. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15405. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15406. result.postProcessScaleFactor = 1.714605507808412;
  15407. result.lensCenterOffset = 0.151976421;
  15408. return result;
  15409. };
  15410. return VRCameraMetrics;
  15411. }());
  15412. /***/ }),
  15413. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15414. /*!**********************************************************!*\
  15415. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15416. \**********************************************************/
  15417. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15419. "use strict";
  15420. __webpack_require__.r(__webpack_exports__);
  15421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15422. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15423. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15424. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15425. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15426. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15427. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15428. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15429. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15430. // Side effect import to define the stereoscopic mode.
  15431. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15432. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15433. });
  15434. /**
  15435. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15436. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15437. */
  15438. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15439. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15440. /**
  15441. * Creates a new VRDeviceOrientationArcRotateCamera
  15442. * @param name defines camera name
  15443. * @param alpha defines the camera rotation along the logitudinal axis
  15444. * @param beta defines the camera rotation along the latitudinal axis
  15445. * @param radius defines the camera distance from its target
  15446. * @param target defines the camera target
  15447. * @param scene defines the scene the camera belongs to
  15448. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15449. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15450. */
  15451. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15452. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15453. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15454. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15455. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15456. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15457. _this.inputs.addVRDeviceOrientation();
  15458. return _this;
  15459. }
  15460. /**
  15461. * Gets camera class name
  15462. * @returns VRDeviceOrientationArcRotateCamera
  15463. */
  15464. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15465. return "VRDeviceOrientationArcRotateCamera";
  15466. };
  15467. return VRDeviceOrientationArcRotateCamera;
  15468. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15469. /***/ }),
  15470. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15471. /*!*****************************************************!*\
  15472. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15473. \*****************************************************/
  15474. /*! exports provided: VRDeviceOrientationFreeCamera */
  15475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15476. "use strict";
  15477. __webpack_require__.r(__webpack_exports__);
  15478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15479. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15480. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15481. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15482. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15483. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15484. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15485. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15486. // Side effect import to define the stereoscopic mode.
  15487. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15488. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15489. });
  15490. /**
  15491. * Camera used to simulate VR rendering (based on FreeCamera)
  15492. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15493. */
  15494. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15495. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15496. /**
  15497. * Creates a new VRDeviceOrientationFreeCamera
  15498. * @param name defines camera name
  15499. * @param position defines the start position of the camera
  15500. * @param scene defines the scene the camera belongs to
  15501. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15502. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15503. */
  15504. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15505. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15506. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15507. var _this = _super.call(this, name, position, scene) || this;
  15508. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15509. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15510. return _this;
  15511. }
  15512. /**
  15513. * Gets camera class name
  15514. * @returns VRDeviceOrientationFreeCamera
  15515. */
  15516. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15517. return "VRDeviceOrientationFreeCamera";
  15518. };
  15519. return VRDeviceOrientationFreeCamera;
  15520. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15521. /***/ }),
  15522. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15523. /*!********************************************************!*\
  15524. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15525. \********************************************************/
  15526. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15528. "use strict";
  15529. __webpack_require__.r(__webpack_exports__);
  15530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15531. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15532. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15533. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15534. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15535. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15536. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15537. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15538. });
  15539. /**
  15540. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15541. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15542. */
  15543. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15544. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15545. /**
  15546. * Creates a new VRDeviceOrientationGamepadCamera
  15547. * @param name defines camera name
  15548. * @param position defines the start position of the camera
  15549. * @param scene defines the scene the camera belongs to
  15550. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15551. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15552. */
  15553. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15554. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15555. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15556. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15557. _this.inputs.addGamepad();
  15558. return _this;
  15559. }
  15560. /**
  15561. * Gets camera class name
  15562. * @returns VRDeviceOrientationGamepadCamera
  15563. */
  15564. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15565. return "VRDeviceOrientationGamepadCamera";
  15566. };
  15567. return VRDeviceOrientationGamepadCamera;
  15568. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15569. /***/ }),
  15570. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15571. /*!******************************************!*\
  15572. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15573. \******************************************/
  15574. /*! exports provided: VRExperienceHelper */
  15575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15576. "use strict";
  15577. __webpack_require__.r(__webpack_exports__);
  15578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15580. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15581. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15582. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15583. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15584. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15585. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15586. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15587. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15588. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15589. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15590. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15591. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15592. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15593. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15594. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15595. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15596. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15597. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15598. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15599. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15600. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15601. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  15602. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  15603. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  15604. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  15605. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  15606. var VRExperienceHelperGazer = /** @class */ (function () {
  15607. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15608. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15609. this.scene = scene;
  15610. /** @hidden */
  15611. this._pointerDownOnMeshAsked = false;
  15612. /** @hidden */
  15613. this._isActionableMesh = false;
  15614. /** @hidden */
  15615. this._teleportationRequestInitiated = false;
  15616. /** @hidden */
  15617. this._teleportationBackRequestInitiated = false;
  15618. /** @hidden */
  15619. this._rotationRightAsked = false;
  15620. /** @hidden */
  15621. this._rotationLeftAsked = false;
  15622. /** @hidden */
  15623. this._dpadPressed = true;
  15624. /** @hidden */
  15625. this._activePointer = false;
  15626. this._id = VRExperienceHelperGazer._idCounter++;
  15627. // Gaze tracker
  15628. if (!gazeTrackerToClone) {
  15629. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  15630. this._gazeTracker.bakeCurrentTransformIntoVertices();
  15631. this._gazeTracker.isPickable = false;
  15632. this._gazeTracker.isVisible = false;
  15633. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  15634. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  15635. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15636. targetMat.backFaceCulling = false;
  15637. this._gazeTracker.material = targetMat;
  15638. }
  15639. else {
  15640. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  15641. }
  15642. }
  15643. /** @hidden */
  15644. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  15645. 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));
  15646. };
  15647. /** @hidden */
  15648. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  15649. this._pointerDownOnMeshAsked = true;
  15650. if (this._currentHit) {
  15651. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  15652. }
  15653. };
  15654. /** @hidden */
  15655. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  15656. if (this._currentHit) {
  15657. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  15658. }
  15659. this._pointerDownOnMeshAsked = false;
  15660. };
  15661. /** @hidden */
  15662. VRExperienceHelperGazer.prototype._activatePointer = function () {
  15663. this._activePointer = true;
  15664. };
  15665. /** @hidden */
  15666. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  15667. this._activePointer = false;
  15668. };
  15669. /** @hidden */
  15670. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  15671. if (distance === void 0) { distance = 100; }
  15672. };
  15673. VRExperienceHelperGazer.prototype.dispose = function () {
  15674. this._interactionsEnabled = false;
  15675. this._teleportationEnabled = false;
  15676. if (this._gazeTracker) {
  15677. this._gazeTracker.dispose();
  15678. }
  15679. };
  15680. VRExperienceHelperGazer._idCounter = 0;
  15681. return VRExperienceHelperGazer;
  15682. }());
  15683. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  15684. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  15685. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  15686. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  15687. _this.webVRController = webVRController;
  15688. // Laser pointer
  15689. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  15690. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  15691. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15692. laserPointerMaterial.alpha = 0.6;
  15693. _this._laserPointer.material = laserPointerMaterial;
  15694. _this._laserPointer.rotation.x = Math.PI / 2;
  15695. _this._laserPointer.position.z = -0.5;
  15696. _this._laserPointer.isVisible = false;
  15697. _this._laserPointer.isPickable = false;
  15698. if (!webVRController.mesh) {
  15699. // Create an empty mesh that is used prior to loading the high quality model
  15700. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  15701. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  15702. preloadPointerPose.rotation.x = -0.7;
  15703. preloadMesh.addChild(preloadPointerPose);
  15704. webVRController.attachToMesh(preloadMesh);
  15705. }
  15706. _this._setLaserPointerParent(webVRController.mesh);
  15707. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15708. _this._setLaserPointerParent(mesh);
  15709. });
  15710. return _this;
  15711. }
  15712. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15713. return this.webVRController.getForwardRay(length);
  15714. };
  15715. /** @hidden */
  15716. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15717. _super.prototype._activatePointer.call(this);
  15718. this._laserPointer.isVisible = true;
  15719. };
  15720. /** @hidden */
  15721. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15722. _super.prototype._deactivatePointer.call(this);
  15723. this._laserPointer.isVisible = false;
  15724. };
  15725. /** @hidden */
  15726. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15727. this._laserPointer.material.emissiveColor = color;
  15728. };
  15729. /** @hidden */
  15730. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15731. var makeNotPick = function (root) {
  15732. root.isPickable = false;
  15733. root.getChildMeshes().forEach(function (c) {
  15734. makeNotPick(c);
  15735. });
  15736. };
  15737. makeNotPick(mesh);
  15738. var meshChildren = mesh.getChildren(undefined, false);
  15739. var laserParent = mesh;
  15740. this.webVRController._pointingPoseNode = null;
  15741. for (var i = 0; i < meshChildren.length; i++) {
  15742. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15743. laserParent = meshChildren[i];
  15744. this.webVRController._pointingPoseNode = laserParent;
  15745. break;
  15746. }
  15747. }
  15748. this._laserPointer.parent = laserParent;
  15749. };
  15750. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15751. if (distance === void 0) { distance = 100; }
  15752. this._laserPointer.scaling.y = distance;
  15753. this._laserPointer.position.z = -distance / 2;
  15754. };
  15755. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15756. _super.prototype.dispose.call(this);
  15757. this._laserPointer.dispose();
  15758. if (this._meshAttachedObserver) {
  15759. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15760. }
  15761. };
  15762. return VRExperienceHelperControllerGazer;
  15763. }(VRExperienceHelperGazer));
  15764. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15765. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15766. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15767. var _this = _super.call(this, scene) || this;
  15768. _this.getCamera = getCamera;
  15769. return _this;
  15770. }
  15771. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15772. var camera = this.getCamera();
  15773. if (camera) {
  15774. return camera.getForwardRay(length);
  15775. }
  15776. else {
  15777. 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());
  15778. }
  15779. };
  15780. return VRExperienceHelperCameraGazer;
  15781. }(VRExperienceHelperGazer));
  15782. /**
  15783. * Helps to quickly add VR support to an existing scene.
  15784. * See http://doc.babylonjs.com/how_to/webvr_helper
  15785. */
  15786. var VRExperienceHelper = /** @class */ (function () {
  15787. /**
  15788. * Instantiates a VRExperienceHelper.
  15789. * Helps to quickly add VR support to an existing scene.
  15790. * @param scene The scene the VRExperienceHelper belongs to.
  15791. * @param webVROptions Options to modify the vr experience helper's behavior.
  15792. */
  15793. function VRExperienceHelper(scene,
  15794. /** Options to modify the vr experience helper's behavior. */
  15795. webVROptions) {
  15796. if (webVROptions === void 0) { webVROptions = {}; }
  15797. var _this = this;
  15798. this.webVROptions = webVROptions;
  15799. // Can the system support WebVR, even if a headset isn't plugged in?
  15800. this._webVRsupported = false;
  15801. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15802. this._webVRready = false;
  15803. // Are we waiting for the requestPresent callback to complete?
  15804. this._webVRrequesting = false;
  15805. // Are we presenting to the headset right now? (this is the vrDevice state)
  15806. this._webVRpresenting = false;
  15807. // Are we presenting in the fullscreen fallback?
  15808. this._fullscreenVRpresenting = false;
  15809. /**
  15810. * Observable raised when entering VR.
  15811. */
  15812. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15813. /**
  15814. * Observable raised when exiting VR.
  15815. */
  15816. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15817. /**
  15818. * Observable raised when controller mesh is loaded.
  15819. */
  15820. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15821. this._useCustomVRButton = false;
  15822. this._teleportationRequested = false;
  15823. this._teleportActive = false;
  15824. this._floorMeshesCollection = [];
  15825. this._rotationAllowed = true;
  15826. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15827. this._isDefaultTeleportationTarget = true;
  15828. this._teleportationFillColor = "#444444";
  15829. this._teleportationBorderColor = "#FFFFFF";
  15830. this._rotationAngle = 0;
  15831. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15832. this._padSensibilityUp = 0.65;
  15833. this._padSensibilityDown = 0.35;
  15834. this._leftController = null;
  15835. this._rightController = null;
  15836. /**
  15837. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15838. */
  15839. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15840. /**
  15841. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15842. */
  15843. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15844. /**
  15845. * Observable raised before camera teleportation
  15846. */
  15847. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15848. /**
  15849. * Observable raised after camera teleportation
  15850. */
  15851. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15852. /**
  15853. * Observable raised when current selected mesh gets unselected
  15854. */
  15855. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15856. /**
  15857. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15858. */
  15859. this.teleportationEnabled = true;
  15860. this._teleportationInitialized = false;
  15861. this._interactionsEnabled = false;
  15862. this._interactionsRequested = false;
  15863. this._displayGaze = true;
  15864. this._displayLaserPointer = true;
  15865. /**
  15866. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15867. */
  15868. this.updateGazeTrackerScale = true;
  15869. /**
  15870. * If the gaze trackers color should be updated when selecting meshes
  15871. */
  15872. this.updateGazeTrackerColor = true;
  15873. /**
  15874. * Defines wether or not Pointer lock should be requested when switching to
  15875. * full screen.
  15876. */
  15877. this.requestPointerLockOnFullScreen = true;
  15878. this._onResize = function () {
  15879. _this.moveButtonToBottomRight();
  15880. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15881. _this.exitVR();
  15882. }
  15883. };
  15884. this._onFullscreenChange = function () {
  15885. if (document.fullscreen !== undefined) {
  15886. _this._fullscreenVRpresenting = document.fullscreen;
  15887. }
  15888. else if (document.mozFullScreen !== undefined) {
  15889. _this._fullscreenVRpresenting = document.mozFullScreen;
  15890. }
  15891. else if (document.webkitIsFullScreen !== undefined) {
  15892. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15893. }
  15894. else if (document.msIsFullScreen !== undefined) {
  15895. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15896. }
  15897. else if (document.msFullscreenElement !== undefined) {
  15898. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15899. }
  15900. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15901. _this.exitVR();
  15902. if (!_this._useCustomVRButton) {
  15903. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15904. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15905. }
  15906. }
  15907. };
  15908. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15909. this.beforeRender = function () {
  15910. if (_this._leftController && _this._leftController._activePointer) {
  15911. _this._castRayAndSelectObject(_this._leftController);
  15912. }
  15913. if (_this._rightController && _this._rightController._activePointer) {
  15914. _this._castRayAndSelectObject(_this._rightController);
  15915. }
  15916. if (_this._noControllerIsActive) {
  15917. _this._castRayAndSelectObject(_this._cameraGazer);
  15918. }
  15919. else {
  15920. _this._cameraGazer._gazeTracker.isVisible = false;
  15921. }
  15922. };
  15923. this._onNewGamepadConnected = function (gamepad) {
  15924. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15925. if (gamepad.leftStick) {
  15926. gamepad.onleftstickchanged(function (stickValues) {
  15927. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15928. // Listening to classic/xbox gamepad only if no VR controller is active
  15929. if ((!_this._leftController && !_this._rightController) ||
  15930. ((_this._leftController && !_this._leftController._activePointer) &&
  15931. (_this._rightController && !_this._rightController._activePointer))) {
  15932. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15933. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15934. }
  15935. }
  15936. });
  15937. }
  15938. if (gamepad.rightStick) {
  15939. gamepad.onrightstickchanged(function (stickValues) {
  15940. if (_this._teleportationInitialized) {
  15941. _this._checkRotate(stickValues, _this._cameraGazer);
  15942. }
  15943. });
  15944. }
  15945. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15946. gamepad.onbuttondown(function (buttonPressed) {
  15947. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15948. _this._cameraGazer._selectionPointerDown();
  15949. }
  15950. });
  15951. gamepad.onbuttonup(function (buttonPressed) {
  15952. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15953. _this._cameraGazer._selectionPointerUp();
  15954. }
  15955. });
  15956. }
  15957. }
  15958. else {
  15959. var webVRController = gamepad;
  15960. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15961. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15962. _this._rightController = controller;
  15963. }
  15964. else {
  15965. _this._leftController = controller;
  15966. }
  15967. _this._tryEnableInteractionOnController(controller);
  15968. }
  15969. };
  15970. // 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
  15971. this._tryEnableInteractionOnController = function (controller) {
  15972. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15973. _this._enableInteractionOnController(controller);
  15974. }
  15975. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15976. _this._enableTeleportationOnController(controller);
  15977. }
  15978. };
  15979. this._onNewGamepadDisconnected = function (gamepad) {
  15980. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15981. if (gamepad.hand === "left" && _this._leftController != null) {
  15982. _this._leftController.dispose();
  15983. _this._leftController = null;
  15984. }
  15985. if (gamepad.hand === "right" && _this._rightController != null) {
  15986. _this._rightController.dispose();
  15987. _this._rightController = null;
  15988. }
  15989. }
  15990. };
  15991. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15992. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15993. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15994. this._scene = scene;
  15995. this._canvas = scene.getEngine().getRenderingCanvas();
  15996. // Parse options
  15997. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15998. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15999. }
  16000. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16001. webVROptions.createDeviceOrientationCamera = true;
  16002. }
  16003. if (webVROptions.laserToggle === undefined) {
  16004. webVROptions.laserToggle = true;
  16005. }
  16006. if (webVROptions.defaultHeight === undefined) {
  16007. webVROptions.defaultHeight = 1.7;
  16008. }
  16009. if (webVROptions.useCustomVRButton) {
  16010. this._useCustomVRButton = true;
  16011. if (webVROptions.customVRButton) {
  16012. this._btnVR = webVROptions.customVRButton;
  16013. }
  16014. }
  16015. if (webVROptions.rayLength) {
  16016. this._rayLength = webVROptions.rayLength;
  16017. }
  16018. this._defaultHeight = webVROptions.defaultHeight;
  16019. if (webVROptions.positionScale) {
  16020. this._rayLength *= webVROptions.positionScale;
  16021. this._defaultHeight *= webVROptions.positionScale;
  16022. }
  16023. this._hasEnteredVR = false;
  16024. // Set position
  16025. if (this._scene.activeCamera) {
  16026. this._position = this._scene.activeCamera.position.clone();
  16027. }
  16028. else {
  16029. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16030. }
  16031. // Set non-vr camera
  16032. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16033. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16034. // Copy data from existing camera
  16035. if (this._scene.activeCamera) {
  16036. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16037. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16038. // Set rotation from previous camera
  16039. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16040. var targetCamera = this._scene.activeCamera;
  16041. if (targetCamera.rotationQuaternion) {
  16042. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16043. }
  16044. else {
  16045. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16046. }
  16047. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16048. }
  16049. }
  16050. this._scene.activeCamera = this._deviceOrientationCamera;
  16051. if (this._canvas) {
  16052. this._scene.activeCamera.attachControl(this._canvas);
  16053. }
  16054. }
  16055. else {
  16056. this._existingCamera = this._scene.activeCamera;
  16057. }
  16058. // Create VR cameras
  16059. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16060. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16061. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16062. }
  16063. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16064. this._webVRCamera.useStandingMatrix();
  16065. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16066. // Create default button
  16067. if (!this._useCustomVRButton) {
  16068. this._btnVR = document.createElement("BUTTON");
  16069. this._btnVR.className = "babylonVRicon";
  16070. this._btnVR.id = "babylonVRiconbtn";
  16071. this._btnVR.title = "Click to switch to VR";
  16072. 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) }";
  16073. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16074. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16075. // css += ".babylonVRicon.vrdisplaysupported { }";
  16076. // css += ".babylonVRicon.vrdisplayready { }";
  16077. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16078. var style = document.createElement('style');
  16079. style.appendChild(document.createTextNode(css));
  16080. document.getElementsByTagName('head')[0].appendChild(style);
  16081. this.moveButtonToBottomRight();
  16082. }
  16083. // VR button click event
  16084. if (this._btnVR) {
  16085. this._btnVR.addEventListener("click", function () {
  16086. if (!_this.isInVRMode) {
  16087. _this.enterVR();
  16088. }
  16089. else {
  16090. _this.exitVR();
  16091. }
  16092. });
  16093. }
  16094. // Window events
  16095. window.addEventListener("resize", this._onResize);
  16096. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16097. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16098. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16099. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16100. document.onmsfullscreenchange = this._onFullscreenChange;
  16101. // Display vr button when headset is connected
  16102. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16103. this.displayVRButton();
  16104. }
  16105. else {
  16106. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16107. if (e.vrDisplay) {
  16108. _this.displayVRButton();
  16109. }
  16110. });
  16111. }
  16112. // Exiting VR mode using 'ESC' key on desktop
  16113. this._onKeyDown = function (event) {
  16114. if (event.keyCode === 27 && _this.isInVRMode) {
  16115. _this.exitVR();
  16116. }
  16117. };
  16118. document.addEventListener("keydown", this._onKeyDown);
  16119. // Exiting VR mode double tapping the touch screen
  16120. this._scene.onPrePointerObservable.add(function () {
  16121. if (_this.isInVRMode) {
  16122. _this.exitVR();
  16123. if (_this._fullscreenVRpresenting) {
  16124. _this._scene.getEngine().exitFullscreen();
  16125. }
  16126. }
  16127. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16128. // Listen for WebVR display changes
  16129. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16130. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16131. this._onVRRequestPresentStart = function () {
  16132. _this._webVRrequesting = true;
  16133. _this.updateButtonVisibility();
  16134. };
  16135. this._onVRRequestPresentComplete = function () {
  16136. _this._webVRrequesting = false;
  16137. _this.updateButtonVisibility();
  16138. };
  16139. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16140. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16141. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16142. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16143. scene.onDisposeObservable.add(function () {
  16144. _this.dispose();
  16145. });
  16146. // Gamepad connection events
  16147. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16148. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16149. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16150. this.updateButtonVisibility();
  16151. //create easing functions
  16152. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16153. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16154. if (this.webVROptions.floorMeshes) {
  16155. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16156. }
  16157. }
  16158. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16159. /** Return this.onEnteringVRObservable
  16160. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16161. */
  16162. get: function () {
  16163. return this.onEnteringVRObservable;
  16164. },
  16165. enumerable: true,
  16166. configurable: true
  16167. });
  16168. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16169. /** Return this.onExitingVRObservable
  16170. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16171. */
  16172. get: function () {
  16173. return this.onExitingVRObservable;
  16174. },
  16175. enumerable: true,
  16176. configurable: true
  16177. });
  16178. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16179. /** Return this.onControllerMeshLoadedObservable
  16180. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16181. */
  16182. get: function () {
  16183. return this.onControllerMeshLoadedObservable;
  16184. },
  16185. enumerable: true,
  16186. configurable: true
  16187. });
  16188. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16189. /**
  16190. * The mesh used to display where the user is going to teleport.
  16191. */
  16192. get: function () {
  16193. return this._teleportationTarget;
  16194. },
  16195. /**
  16196. * Sets the mesh to be used to display where the user is going to teleport.
  16197. */
  16198. set: function (value) {
  16199. if (value) {
  16200. value.name = "teleportationTarget";
  16201. this._isDefaultTeleportationTarget = false;
  16202. this._teleportationTarget = value;
  16203. }
  16204. },
  16205. enumerable: true,
  16206. configurable: true
  16207. });
  16208. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16209. /**
  16210. * 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
  16211. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16212. * See http://doc.babylonjs.com/resources/baking_transformations
  16213. */
  16214. get: function () {
  16215. return this._cameraGazer._gazeTracker;
  16216. },
  16217. set: function (value) {
  16218. if (value) {
  16219. // Dispose of existing meshes
  16220. if (this._cameraGazer._gazeTracker) {
  16221. this._cameraGazer._gazeTracker.dispose();
  16222. }
  16223. if (this._leftController && this._leftController._gazeTracker) {
  16224. this._leftController._gazeTracker.dispose();
  16225. }
  16226. if (this._rightController && this._rightController._gazeTracker) {
  16227. this._rightController._gazeTracker.dispose();
  16228. }
  16229. // Set and create gaze trackers on head and controllers
  16230. this._cameraGazer._gazeTracker = value;
  16231. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16232. this._cameraGazer._gazeTracker.isPickable = false;
  16233. this._cameraGazer._gazeTracker.isVisible = false;
  16234. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16235. if (this._leftController) {
  16236. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16237. }
  16238. if (this._rightController) {
  16239. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16240. }
  16241. }
  16242. },
  16243. enumerable: true,
  16244. configurable: true
  16245. });
  16246. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16247. /**
  16248. * The gaze tracking mesh corresponding to the left controller
  16249. */
  16250. get: function () {
  16251. if (this._leftController) {
  16252. return this._leftController._gazeTracker;
  16253. }
  16254. return null;
  16255. },
  16256. enumerable: true,
  16257. configurable: true
  16258. });
  16259. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16260. /**
  16261. * The gaze tracking mesh corresponding to the right controller
  16262. */
  16263. get: function () {
  16264. if (this._rightController) {
  16265. return this._rightController._gazeTracker;
  16266. }
  16267. return null;
  16268. },
  16269. enumerable: true,
  16270. configurable: true
  16271. });
  16272. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16273. /**
  16274. * If the ray of the gaze should be displayed.
  16275. */
  16276. get: function () {
  16277. return this._displayGaze;
  16278. },
  16279. /**
  16280. * Sets if the ray of the gaze should be displayed.
  16281. */
  16282. set: function (value) {
  16283. this._displayGaze = value;
  16284. if (!value) {
  16285. this._cameraGazer._gazeTracker.isVisible = false;
  16286. if (this._leftController) {
  16287. this._leftController._gazeTracker.isVisible = false;
  16288. }
  16289. if (this._rightController) {
  16290. this._rightController._gazeTracker.isVisible = false;
  16291. }
  16292. }
  16293. },
  16294. enumerable: true,
  16295. configurable: true
  16296. });
  16297. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16298. /**
  16299. * If the ray of the LaserPointer should be displayed.
  16300. */
  16301. get: function () {
  16302. return this._displayLaserPointer;
  16303. },
  16304. /**
  16305. * Sets if the ray of the LaserPointer should be displayed.
  16306. */
  16307. set: function (value) {
  16308. this._displayLaserPointer = value;
  16309. if (!value) {
  16310. if (this._rightController) {
  16311. this._rightController._deactivatePointer();
  16312. this._rightController._gazeTracker.isVisible = false;
  16313. }
  16314. if (this._leftController) {
  16315. this._leftController._deactivatePointer();
  16316. this._leftController._gazeTracker.isVisible = false;
  16317. }
  16318. }
  16319. else {
  16320. if (this._rightController) {
  16321. this._rightController._activatePointer();
  16322. }
  16323. if (this._leftController) {
  16324. this._leftController._activatePointer();
  16325. }
  16326. }
  16327. },
  16328. enumerable: true,
  16329. configurable: true
  16330. });
  16331. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16332. /**
  16333. * The deviceOrientationCamera used as the camera when not in VR.
  16334. */
  16335. get: function () {
  16336. return this._deviceOrientationCamera;
  16337. },
  16338. enumerable: true,
  16339. configurable: true
  16340. });
  16341. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16342. /**
  16343. * Based on the current WebVR support, returns the current VR camera used.
  16344. */
  16345. get: function () {
  16346. if (this._webVRready) {
  16347. return this._webVRCamera;
  16348. }
  16349. else {
  16350. return this._scene.activeCamera;
  16351. }
  16352. },
  16353. enumerable: true,
  16354. configurable: true
  16355. });
  16356. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16357. /**
  16358. * The webVRCamera which is used when in VR.
  16359. */
  16360. get: function () {
  16361. return this._webVRCamera;
  16362. },
  16363. enumerable: true,
  16364. configurable: true
  16365. });
  16366. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16367. /**
  16368. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16369. */
  16370. get: function () {
  16371. return this._vrDeviceOrientationCamera;
  16372. },
  16373. enumerable: true,
  16374. configurable: true
  16375. });
  16376. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16377. get: function () {
  16378. var result = this._cameraGazer._teleportationRequestInitiated
  16379. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16380. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16381. return result;
  16382. },
  16383. enumerable: true,
  16384. configurable: true
  16385. });
  16386. // Raised when one of the controller has loaded successfully its associated default mesh
  16387. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16388. if (this._leftController && this._leftController.webVRController == webVRController) {
  16389. if (webVRController.mesh) {
  16390. this._leftController._setLaserPointerParent(webVRController.mesh);
  16391. }
  16392. }
  16393. if (this._rightController && this._rightController.webVRController == webVRController) {
  16394. if (webVRController.mesh) {
  16395. this._rightController._setLaserPointerParent(webVRController.mesh);
  16396. }
  16397. }
  16398. try {
  16399. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16400. }
  16401. catch (err) {
  16402. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16403. }
  16404. };
  16405. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16406. /**
  16407. * Gets a value indicating if we are currently in VR mode.
  16408. */
  16409. get: function () {
  16410. return this._webVRpresenting || this._fullscreenVRpresenting;
  16411. },
  16412. enumerable: true,
  16413. configurable: true
  16414. });
  16415. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16416. var vrDisplay = this._scene.getEngine().getVRDevice();
  16417. if (vrDisplay) {
  16418. var wasPresenting = this._webVRpresenting;
  16419. this._webVRpresenting = vrDisplay.isPresenting;
  16420. if (wasPresenting && !this._webVRpresenting) {
  16421. this.exitVR();
  16422. }
  16423. }
  16424. else {
  16425. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16426. }
  16427. this.updateButtonVisibility();
  16428. };
  16429. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16430. this._webVRsupported = eventArgs.vrSupported;
  16431. this._webVRready = !!eventArgs.vrDisplay;
  16432. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16433. this.updateButtonVisibility();
  16434. };
  16435. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16436. if (this._canvas && !this._useCustomVRButton) {
  16437. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16438. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16439. }
  16440. };
  16441. VRExperienceHelper.prototype.displayVRButton = function () {
  16442. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16443. document.body.appendChild(this._btnVR);
  16444. this._btnVRDisplayed = true;
  16445. }
  16446. };
  16447. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16448. if (!this._btnVR || this._useCustomVRButton) {
  16449. return;
  16450. }
  16451. this._btnVR.className = "babylonVRicon";
  16452. if (this.isInVRMode) {
  16453. this._btnVR.className += " vrdisplaypresenting";
  16454. }
  16455. else {
  16456. if (this._webVRready) {
  16457. this._btnVR.className += " vrdisplayready";
  16458. }
  16459. if (this._webVRsupported) {
  16460. this._btnVR.className += " vrdisplaysupported";
  16461. }
  16462. if (this._webVRrequesting) {
  16463. this._btnVR.className += " vrdisplayrequesting";
  16464. }
  16465. }
  16466. };
  16467. /**
  16468. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16469. * Otherwise, will use the fullscreen API.
  16470. */
  16471. VRExperienceHelper.prototype.enterVR = function () {
  16472. if (this.onEnteringVRObservable) {
  16473. try {
  16474. this.onEnteringVRObservable.notifyObservers(this);
  16475. }
  16476. catch (err) {
  16477. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16478. }
  16479. }
  16480. if (this._scene.activeCamera) {
  16481. this._position = this._scene.activeCamera.position.clone();
  16482. if (this.vrDeviceOrientationCamera) {
  16483. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16484. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16485. }
  16486. if (this.webVRCamera) {
  16487. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16488. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16489. var delta = desiredYRotation - currentYRotation;
  16490. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16491. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16492. }
  16493. // make sure that we return to the last active camera
  16494. this._existingCamera = this._scene.activeCamera;
  16495. // Remove and cache angular sensability to avoid camera rotation when in VR
  16496. if (this._existingCamera.angularSensibilityX) {
  16497. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16498. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16499. }
  16500. if (this._existingCamera.angularSensibilityY) {
  16501. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16502. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16503. }
  16504. if (this._existingCamera.angularSensibility) {
  16505. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16506. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16507. }
  16508. }
  16509. if (this._webVRrequesting) {
  16510. return;
  16511. }
  16512. // If WebVR is supported and a headset is connected
  16513. if (this._webVRready) {
  16514. if (!this._webVRpresenting) {
  16515. this._webVRCamera.position = this._position;
  16516. this._scene.activeCamera = this._webVRCamera;
  16517. }
  16518. }
  16519. else if (this._vrDeviceOrientationCamera) {
  16520. this._vrDeviceOrientationCamera.position = this._position;
  16521. if (this._scene.activeCamera) {
  16522. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16523. }
  16524. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16525. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  16526. this.updateButtonVisibility();
  16527. }
  16528. if (this._scene.activeCamera && this._canvas) {
  16529. this._scene.activeCamera.attachControl(this._canvas);
  16530. }
  16531. if (this._interactionsEnabled) {
  16532. this._scene.registerBeforeRender(this.beforeRender);
  16533. }
  16534. if (this._displayLaserPointer) {
  16535. [this._leftController, this._rightController].forEach(function (controller) {
  16536. if (controller) {
  16537. controller._activatePointer();
  16538. }
  16539. });
  16540. }
  16541. this._hasEnteredVR = true;
  16542. };
  16543. /**
  16544. * Attempt to exit VR, or fullscreen.
  16545. */
  16546. VRExperienceHelper.prototype.exitVR = function () {
  16547. if (this._hasEnteredVR) {
  16548. if (this.onExitingVRObservable) {
  16549. try {
  16550. this.onExitingVRObservable.notifyObservers(this);
  16551. }
  16552. catch (err) {
  16553. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16554. }
  16555. }
  16556. if (this._webVRpresenting) {
  16557. this._scene.getEngine().disableVR();
  16558. }
  16559. if (this._scene.activeCamera) {
  16560. this._position = this._scene.activeCamera.position.clone();
  16561. }
  16562. if (this.vrDeviceOrientationCamera) {
  16563. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16564. }
  16565. if (this._deviceOrientationCamera) {
  16566. this._deviceOrientationCamera.position = this._position;
  16567. this._scene.activeCamera = this._deviceOrientationCamera;
  16568. if (this._canvas) {
  16569. this._scene.activeCamera.attachControl(this._canvas);
  16570. }
  16571. // Restore angular sensibility
  16572. if (this._cachedAngularSensibility.angularSensibilityX) {
  16573. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16574. this._cachedAngularSensibility.angularSensibilityX = null;
  16575. }
  16576. if (this._cachedAngularSensibility.angularSensibilityY) {
  16577. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16578. this._cachedAngularSensibility.angularSensibilityY = null;
  16579. }
  16580. if (this._cachedAngularSensibility.angularSensibility) {
  16581. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16582. this._cachedAngularSensibility.angularSensibility = null;
  16583. }
  16584. }
  16585. else if (this._existingCamera) {
  16586. this._existingCamera.position = this._position;
  16587. this._scene.activeCamera = this._existingCamera;
  16588. // Restore angular sensibility
  16589. if (this._cachedAngularSensibility.angularSensibilityX) {
  16590. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16591. this._cachedAngularSensibility.angularSensibilityX = null;
  16592. }
  16593. if (this._cachedAngularSensibility.angularSensibilityY) {
  16594. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16595. this._cachedAngularSensibility.angularSensibilityY = null;
  16596. }
  16597. if (this._cachedAngularSensibility.angularSensibility) {
  16598. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16599. this._cachedAngularSensibility.angularSensibility = null;
  16600. }
  16601. }
  16602. this.updateButtonVisibility();
  16603. if (this._interactionsEnabled) {
  16604. this._scene.unregisterBeforeRender(this.beforeRender);
  16605. this._cameraGazer._gazeTracker.isVisible = false;
  16606. if (this._leftController) {
  16607. this._leftController._gazeTracker.isVisible = false;
  16608. }
  16609. if (this._rightController) {
  16610. this._rightController._gazeTracker.isVisible = false;
  16611. }
  16612. }
  16613. // resize to update width and height when exiting vr exits fullscreen
  16614. this._scene.getEngine().resize();
  16615. [this._leftController, this._rightController].forEach(function (controller) {
  16616. if (controller) {
  16617. controller._deactivatePointer();
  16618. }
  16619. });
  16620. this._hasEnteredVR = false;
  16621. }
  16622. };
  16623. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  16624. /**
  16625. * The position of the vr experience helper.
  16626. */
  16627. get: function () {
  16628. return this._position;
  16629. },
  16630. /**
  16631. * Sets the position of the vr experience helper.
  16632. */
  16633. set: function (value) {
  16634. this._position = value;
  16635. if (this._scene.activeCamera) {
  16636. this._scene.activeCamera.position = value;
  16637. }
  16638. },
  16639. enumerable: true,
  16640. configurable: true
  16641. });
  16642. /**
  16643. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  16644. */
  16645. VRExperienceHelper.prototype.enableInteractions = function () {
  16646. var _this = this;
  16647. if (!this._interactionsEnabled) {
  16648. this._interactionsRequested = true;
  16649. if (this._leftController) {
  16650. this._enableInteractionOnController(this._leftController);
  16651. }
  16652. if (this._rightController) {
  16653. this._enableInteractionOnController(this._rightController);
  16654. }
  16655. this.raySelectionPredicate = function (mesh) {
  16656. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  16657. };
  16658. this.meshSelectionPredicate = function () {
  16659. return true;
  16660. };
  16661. this._raySelectionPredicate = function (mesh) {
  16662. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  16663. && mesh.name.indexOf("teleportationTarget") === -1
  16664. && mesh.name.indexOf("torusTeleportation") === -1)) {
  16665. return _this.raySelectionPredicate(mesh);
  16666. }
  16667. return false;
  16668. };
  16669. this._interactionsEnabled = true;
  16670. }
  16671. };
  16672. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  16673. get: function () {
  16674. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  16675. },
  16676. enumerable: true,
  16677. configurable: true
  16678. });
  16679. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  16680. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  16681. if (this._floorMeshesCollection[i].id === mesh.id) {
  16682. return true;
  16683. }
  16684. }
  16685. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  16686. return true;
  16687. }
  16688. return false;
  16689. };
  16690. /**
  16691. * Adds a floor mesh to be used for teleportation.
  16692. * @param floorMesh the mesh to be used for teleportation.
  16693. */
  16694. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  16695. if (!this._floorMeshesCollection) {
  16696. return;
  16697. }
  16698. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  16699. return;
  16700. }
  16701. this._floorMeshesCollection.push(floorMesh);
  16702. };
  16703. /**
  16704. * Removes a floor mesh from being used for teleportation.
  16705. * @param floorMesh the mesh to be removed.
  16706. */
  16707. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  16708. if (!this._floorMeshesCollection) {
  16709. return;
  16710. }
  16711. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16712. if (meshIndex !== -1) {
  16713. this._floorMeshesCollection.splice(meshIndex, 1);
  16714. }
  16715. };
  16716. /**
  16717. * Enables interactions and teleportation using the VR controllers and gaze.
  16718. * @param vrTeleportationOptions options to modify teleportation behavior.
  16719. */
  16720. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16721. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16722. if (!this._teleportationInitialized) {
  16723. this._teleportationRequested = true;
  16724. this.enableInteractions();
  16725. if (vrTeleportationOptions.floorMeshName) {
  16726. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16727. }
  16728. if (vrTeleportationOptions.floorMeshes) {
  16729. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16730. }
  16731. if (this._leftController != null) {
  16732. this._enableTeleportationOnController(this._leftController);
  16733. }
  16734. if (this._rightController != null) {
  16735. this._enableTeleportationOnController(this._rightController);
  16736. }
  16737. // Creates an image processing post process for the vignette not relying
  16738. // on the main scene configuration for image processing to reduce setup and spaces
  16739. // (gamma/linear) conflicts.
  16740. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16741. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16742. imageProcessingConfiguration.vignetteEnabled = true;
  16743. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16744. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16745. this._teleportationInitialized = true;
  16746. if (this._isDefaultTeleportationTarget) {
  16747. this._createTeleportationCircles();
  16748. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16749. }
  16750. }
  16751. };
  16752. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16753. var _this = this;
  16754. var controllerMesh = controller.webVRController.mesh;
  16755. if (controllerMesh) {
  16756. controller._interactionsEnabled = true;
  16757. if (this.isInVRMode && this._displayLaserPointer) {
  16758. controller._activatePointer();
  16759. }
  16760. if (this.webVROptions.laserToggle) {
  16761. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16762. // Enabling / disabling laserPointer
  16763. if (_this._displayLaserPointer && stateObject.value === 1) {
  16764. if (controller._activePointer) {
  16765. controller._deactivatePointer();
  16766. }
  16767. else {
  16768. controller._activatePointer();
  16769. }
  16770. if (_this.displayGaze) {
  16771. controller._gazeTracker.isVisible = controller._activePointer;
  16772. }
  16773. }
  16774. });
  16775. }
  16776. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16777. var gazer = controller;
  16778. if (_this._noControllerIsActive) {
  16779. gazer = _this._cameraGazer;
  16780. }
  16781. if (!gazer._pointerDownOnMeshAsked) {
  16782. if (stateObject.value > _this._padSensibilityUp) {
  16783. gazer._selectionPointerDown();
  16784. }
  16785. }
  16786. else if (stateObject.value < _this._padSensibilityDown) {
  16787. gazer._selectionPointerUp();
  16788. }
  16789. });
  16790. }
  16791. };
  16792. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16793. // Dont teleport if another gaze already requested teleportation
  16794. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16795. return;
  16796. }
  16797. if (!gazer._teleportationRequestInitiated) {
  16798. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16799. gazer._activatePointer();
  16800. gazer._teleportationRequestInitiated = true;
  16801. }
  16802. }
  16803. else {
  16804. // Listening to the proper controller values changes to confirm teleportation
  16805. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16806. if (this._teleportActive) {
  16807. this.teleportCamera(this._haloCenter);
  16808. }
  16809. gazer._teleportationRequestInitiated = false;
  16810. }
  16811. }
  16812. };
  16813. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16814. // Only rotate when user is not currently selecting a teleportation location
  16815. if (gazer._teleportationRequestInitiated) {
  16816. return;
  16817. }
  16818. if (!gazer._rotationLeftAsked) {
  16819. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16820. gazer._rotationLeftAsked = true;
  16821. if (this._rotationAllowed) {
  16822. this._rotateCamera(false);
  16823. }
  16824. }
  16825. }
  16826. else {
  16827. if (stateObject.x > -this._padSensibilityDown) {
  16828. gazer._rotationLeftAsked = false;
  16829. }
  16830. }
  16831. if (!gazer._rotationRightAsked) {
  16832. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16833. gazer._rotationRightAsked = true;
  16834. if (this._rotationAllowed) {
  16835. this._rotateCamera(true);
  16836. }
  16837. }
  16838. }
  16839. else {
  16840. if (stateObject.x < this._padSensibilityDown) {
  16841. gazer._rotationRightAsked = false;
  16842. }
  16843. }
  16844. };
  16845. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16846. // Only teleport backwards when user is not currently selecting a teleportation location
  16847. if (gazer._teleportationRequestInitiated) {
  16848. return;
  16849. }
  16850. // Teleport backwards
  16851. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16852. if (!gazer._teleportationBackRequestInitiated) {
  16853. if (!this.currentVRCamera) {
  16854. return;
  16855. }
  16856. // Get rotation and position of the current camera
  16857. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16858. var position = this.currentVRCamera.position;
  16859. // If the camera has device position, use that instead
  16860. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16861. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16862. position = this.currentVRCamera.devicePosition;
  16863. }
  16864. // Get matrix with only the y rotation of the device rotation
  16865. rotation.toEulerAnglesToRef(this._workingVector);
  16866. this._workingVector.z = 0;
  16867. this._workingVector.x = 0;
  16868. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16869. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16870. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16871. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16872. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16873. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16874. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16875. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16876. this.teleportCamera(hit.pickedPoint);
  16877. }
  16878. gazer._teleportationBackRequestInitiated = true;
  16879. }
  16880. }
  16881. else {
  16882. gazer._teleportationBackRequestInitiated = false;
  16883. }
  16884. };
  16885. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16886. var _this = this;
  16887. var controllerMesh = controller.webVRController.mesh;
  16888. if (controllerMesh) {
  16889. if (!controller._interactionsEnabled) {
  16890. this._enableInteractionOnController(controller);
  16891. }
  16892. controller._interactionsEnabled = true;
  16893. controller._teleportationEnabled = true;
  16894. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16895. controller._dpadPressed = false;
  16896. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16897. controller._dpadPressed = stateObject.pressed;
  16898. if (!controller._dpadPressed) {
  16899. controller._rotationLeftAsked = false;
  16900. controller._rotationRightAsked = false;
  16901. controller._teleportationBackRequestInitiated = false;
  16902. }
  16903. });
  16904. }
  16905. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16906. if (_this.teleportationEnabled) {
  16907. _this._checkTeleportBackwards(stateObject, controller);
  16908. _this._checkTeleportWithRay(stateObject, controller);
  16909. }
  16910. _this._checkRotate(stateObject, controller);
  16911. });
  16912. }
  16913. };
  16914. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16915. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16916. this._teleportationTarget.isPickable = false;
  16917. var length = 512;
  16918. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16919. dynamicTexture.hasAlpha = true;
  16920. var context = dynamicTexture.getContext();
  16921. var centerX = length / 2;
  16922. var centerY = length / 2;
  16923. var radius = 200;
  16924. context.beginPath();
  16925. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16926. context.fillStyle = this._teleportationFillColor;
  16927. context.fill();
  16928. context.lineWidth = 10;
  16929. context.strokeStyle = this._teleportationBorderColor;
  16930. context.stroke();
  16931. context.closePath();
  16932. dynamicTexture.update();
  16933. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16934. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16935. this._teleportationTarget.material = teleportationCircleMaterial;
  16936. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16937. torus.isPickable = false;
  16938. torus.parent = this._teleportationTarget;
  16939. 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);
  16940. var keys = [];
  16941. keys.push({
  16942. frame: 0,
  16943. value: 0
  16944. });
  16945. keys.push({
  16946. frame: 30,
  16947. value: 0.4
  16948. });
  16949. keys.push({
  16950. frame: 60,
  16951. value: 0
  16952. });
  16953. animationInnerCircle.setKeys(keys);
  16954. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16955. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16956. animationInnerCircle.setEasingFunction(easingFunction);
  16957. torus.animations = [];
  16958. torus.animations.push(animationInnerCircle);
  16959. this._scene.beginAnimation(torus, 0, 60, true);
  16960. this._hideTeleportationTarget();
  16961. };
  16962. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16963. this._teleportActive = true;
  16964. if (this._teleportationInitialized) {
  16965. this._teleportationTarget.isVisible = true;
  16966. if (this._isDefaultTeleportationTarget) {
  16967. this._teleportationTarget.getChildren()[0].isVisible = true;
  16968. }
  16969. }
  16970. };
  16971. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16972. this._teleportActive = false;
  16973. if (this._teleportationInitialized) {
  16974. this._teleportationTarget.isVisible = false;
  16975. if (this._isDefaultTeleportationTarget) {
  16976. this._teleportationTarget.getChildren()[0].isVisible = false;
  16977. }
  16978. }
  16979. };
  16980. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16981. var _this = this;
  16982. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16983. return;
  16984. }
  16985. if (right) {
  16986. this._rotationAngle++;
  16987. }
  16988. else {
  16989. this._rotationAngle--;
  16990. }
  16991. this.currentVRCamera.animations = [];
  16992. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16993. 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);
  16994. var animationRotationKeys = [];
  16995. animationRotationKeys.push({
  16996. frame: 0,
  16997. value: this.currentVRCamera.rotationQuaternion
  16998. });
  16999. animationRotationKeys.push({
  17000. frame: 6,
  17001. value: target
  17002. });
  17003. animationRotation.setKeys(animationRotationKeys);
  17004. animationRotation.setEasingFunction(this._circleEase);
  17005. this.currentVRCamera.animations.push(animationRotation);
  17006. this._postProcessMove.animations = [];
  17007. 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);
  17008. var vignetteWeightKeys = [];
  17009. vignetteWeightKeys.push({
  17010. frame: 0,
  17011. value: 0
  17012. });
  17013. vignetteWeightKeys.push({
  17014. frame: 3,
  17015. value: 4
  17016. });
  17017. vignetteWeightKeys.push({
  17018. frame: 6,
  17019. value: 0
  17020. });
  17021. animationPP.setKeys(vignetteWeightKeys);
  17022. animationPP.setEasingFunction(this._circleEase);
  17023. this._postProcessMove.animations.push(animationPP);
  17024. 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);
  17025. var vignetteStretchKeys = [];
  17026. vignetteStretchKeys.push({
  17027. frame: 0,
  17028. value: 0
  17029. });
  17030. vignetteStretchKeys.push({
  17031. frame: 3,
  17032. value: 10
  17033. });
  17034. vignetteStretchKeys.push({
  17035. frame: 6,
  17036. value: 0
  17037. });
  17038. animationPP2.setKeys(vignetteStretchKeys);
  17039. animationPP2.setEasingFunction(this._circleEase);
  17040. this._postProcessMove.animations.push(animationPP2);
  17041. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17042. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17043. this._postProcessMove.samples = 4;
  17044. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17045. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17046. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17047. });
  17048. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17049. };
  17050. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17051. if (hit.pickedPoint) {
  17052. if (gazer._teleportationRequestInitiated) {
  17053. this._displayTeleportationTarget();
  17054. this._haloCenter.copyFrom(hit.pickedPoint);
  17055. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17056. }
  17057. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17058. if (pickNormal) {
  17059. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17060. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17061. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17062. }
  17063. this._teleportationTarget.position.y += 0.1;
  17064. }
  17065. };
  17066. /**
  17067. * Teleports the users feet to the desired location
  17068. * @param location The location where the user's feet should be placed
  17069. */
  17070. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17071. var _this = this;
  17072. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17073. return;
  17074. }
  17075. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17076. // offset of the headset from the anchor.
  17077. if (this.webVRCamera.leftCamera) {
  17078. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17079. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17080. location.subtractToRef(this._workingVector, this._workingVector);
  17081. }
  17082. else {
  17083. this._workingVector.copyFrom(location);
  17084. }
  17085. // Add height to account for user's height offset
  17086. if (this.isInVRMode) {
  17087. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17088. }
  17089. else {
  17090. this._workingVector.y += this._defaultHeight;
  17091. }
  17092. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17093. // Create animation from the camera's position to the new location
  17094. this.currentVRCamera.animations = [];
  17095. 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);
  17096. var animationCameraTeleportationKeys = [{
  17097. frame: 0,
  17098. value: this.currentVRCamera.position
  17099. },
  17100. {
  17101. frame: 11,
  17102. value: this._workingVector
  17103. }
  17104. ];
  17105. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17106. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17107. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17108. this._postProcessMove.animations = [];
  17109. 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);
  17110. var vignetteWeightKeys = [];
  17111. vignetteWeightKeys.push({
  17112. frame: 0,
  17113. value: 0
  17114. });
  17115. vignetteWeightKeys.push({
  17116. frame: 5,
  17117. value: 8
  17118. });
  17119. vignetteWeightKeys.push({
  17120. frame: 11,
  17121. value: 0
  17122. });
  17123. animationPP.setKeys(vignetteWeightKeys);
  17124. this._postProcessMove.animations.push(animationPP);
  17125. 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);
  17126. var vignetteStretchKeys = [];
  17127. vignetteStretchKeys.push({
  17128. frame: 0,
  17129. value: 0
  17130. });
  17131. vignetteStretchKeys.push({
  17132. frame: 5,
  17133. value: 10
  17134. });
  17135. vignetteStretchKeys.push({
  17136. frame: 11,
  17137. value: 0
  17138. });
  17139. animationPP2.setKeys(vignetteStretchKeys);
  17140. this._postProcessMove.animations.push(animationPP2);
  17141. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17142. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17143. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17144. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17145. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17146. });
  17147. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17148. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17149. });
  17150. this._hideTeleportationTarget();
  17151. };
  17152. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17153. if (normal) {
  17154. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17155. if (angle < Math.PI / 2) {
  17156. normal.scaleInPlace(-1);
  17157. }
  17158. }
  17159. return normal;
  17160. };
  17161. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17162. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17163. return;
  17164. }
  17165. var ray = gazer._getForwardRay(this._rayLength);
  17166. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17167. if (hit) {
  17168. // Populate the contrllers mesh that can be used for drag/drop
  17169. if (gazer._laserPointer) {
  17170. hit.originMesh = gazer._laserPointer.parent;
  17171. }
  17172. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17173. }
  17174. gazer._currentHit = hit;
  17175. // Moving the gazeTracker on the mesh face targetted
  17176. if (hit && hit.pickedPoint) {
  17177. if (this._displayGaze) {
  17178. var multiplier = 1;
  17179. gazer._gazeTracker.isVisible = true;
  17180. if (gazer._isActionableMesh) {
  17181. multiplier = 3;
  17182. }
  17183. if (this.updateGazeTrackerScale) {
  17184. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17185. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17186. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17187. }
  17188. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17189. // To avoid z-fighting
  17190. var deltaFighting = 0.002;
  17191. if (pickNormal) {
  17192. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17193. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17194. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17195. }
  17196. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17197. if (gazer._gazeTracker.position.x < 0) {
  17198. gazer._gazeTracker.position.x += deltaFighting;
  17199. }
  17200. else {
  17201. gazer._gazeTracker.position.x -= deltaFighting;
  17202. }
  17203. if (gazer._gazeTracker.position.y < 0) {
  17204. gazer._gazeTracker.position.y += deltaFighting;
  17205. }
  17206. else {
  17207. gazer._gazeTracker.position.y -= deltaFighting;
  17208. }
  17209. if (gazer._gazeTracker.position.z < 0) {
  17210. gazer._gazeTracker.position.z += deltaFighting;
  17211. }
  17212. else {
  17213. gazer._gazeTracker.position.z -= deltaFighting;
  17214. }
  17215. }
  17216. // Changing the size of the laser pointer based on the distance from the targetted point
  17217. gazer._updatePointerDistance(hit.distance);
  17218. }
  17219. else {
  17220. gazer._updatePointerDistance();
  17221. gazer._gazeTracker.isVisible = false;
  17222. }
  17223. if (hit && hit.pickedMesh) {
  17224. // The object selected is the floor, we're in a teleportation scenario
  17225. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17226. // Moving the teleportation area to this targetted point
  17227. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17228. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17229. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17230. }
  17231. gazer._currentMeshSelected = null;
  17232. if (gazer._teleportationRequestInitiated) {
  17233. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17234. }
  17235. return;
  17236. }
  17237. // If not, we're in a selection scenario
  17238. //this._teleportationAllowed = false;
  17239. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17240. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17241. this.onNewMeshPicked.notifyObservers(hit);
  17242. gazer._currentMeshSelected = hit.pickedMesh;
  17243. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17244. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17245. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17246. gazer._isActionableMesh = true;
  17247. }
  17248. else {
  17249. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17250. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17251. gazer._isActionableMesh = false;
  17252. }
  17253. try {
  17254. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17255. }
  17256. catch (err) {
  17257. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17258. }
  17259. }
  17260. else {
  17261. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17262. gazer._currentMeshSelected = null;
  17263. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17264. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17265. }
  17266. }
  17267. }
  17268. else {
  17269. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17270. gazer._currentMeshSelected = null;
  17271. //this._teleportationAllowed = false;
  17272. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17273. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17274. }
  17275. };
  17276. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17277. if (mesh) {
  17278. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17279. }
  17280. };
  17281. /**
  17282. * Sets the color of the laser ray from the vr controllers.
  17283. * @param color new color for the ray.
  17284. */
  17285. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17286. if (this._leftController) {
  17287. this._leftController._setLaserPointerColor(color);
  17288. }
  17289. if (this._rightController) {
  17290. this._rightController._setLaserPointerColor(color);
  17291. }
  17292. };
  17293. /**
  17294. * Sets the color of the ray from the vr headsets gaze.
  17295. * @param color new color for the ray.
  17296. */
  17297. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17298. if (!this.updateGazeTrackerColor) {
  17299. return;
  17300. }
  17301. if (!this._cameraGazer._gazeTracker.material) {
  17302. return;
  17303. }
  17304. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17305. if (this._leftController) {
  17306. this._leftController._gazeTracker.material.emissiveColor = color;
  17307. }
  17308. if (this._rightController) {
  17309. this._rightController._gazeTracker.material.emissiveColor = color;
  17310. }
  17311. };
  17312. /**
  17313. * Exits VR and disposes of the vr experience helper
  17314. */
  17315. VRExperienceHelper.prototype.dispose = function () {
  17316. if (this.isInVRMode) {
  17317. this.exitVR();
  17318. }
  17319. if (this._postProcessMove) {
  17320. this._postProcessMove.dispose();
  17321. }
  17322. if (this._webVRCamera) {
  17323. this._webVRCamera.dispose();
  17324. }
  17325. if (this._vrDeviceOrientationCamera) {
  17326. this._vrDeviceOrientationCamera.dispose();
  17327. }
  17328. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17329. document.body.removeChild(this._btnVR);
  17330. }
  17331. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17332. this._deviceOrientationCamera.dispose();
  17333. }
  17334. if (this._cameraGazer) {
  17335. this._cameraGazer.dispose();
  17336. }
  17337. if (this._leftController) {
  17338. this._leftController.dispose();
  17339. }
  17340. if (this._rightController) {
  17341. this._rightController.dispose();
  17342. }
  17343. if (this._teleportationTarget) {
  17344. this._teleportationTarget.dispose();
  17345. }
  17346. this._floorMeshesCollection = [];
  17347. document.removeEventListener("keydown", this._onKeyDown);
  17348. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17349. window.removeEventListener("resize", this._onResize);
  17350. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17351. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17352. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17353. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17354. document.onmsfullscreenchange = null;
  17355. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17356. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17357. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17358. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17359. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17360. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17361. this._scene.unregisterBeforeRender(this.beforeRender);
  17362. };
  17363. /**
  17364. * Gets the name of the VRExperienceHelper class
  17365. * @returns "VRExperienceHelper"
  17366. */
  17367. VRExperienceHelper.prototype.getClassName = function () {
  17368. return "VRExperienceHelper";
  17369. };
  17370. return VRExperienceHelper;
  17371. }());
  17372. /***/ }),
  17373. /***/ "./Cameras/VR/webVRCamera.ts":
  17374. /*!***********************************!*\
  17375. !*** ./Cameras/VR/webVRCamera.ts ***!
  17376. \***********************************/
  17377. /*! exports provided: WebVRFreeCamera */
  17378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17379. "use strict";
  17380. __webpack_require__.r(__webpack_exports__);
  17381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17382. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17383. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17384. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17385. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17386. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17387. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17388. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17389. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17390. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17391. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17392. // Side effect import to define the stereoscopic mode.
  17393. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17394. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17395. });
  17396. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17397. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17398. });
  17399. /**
  17400. * This represents a WebVR camera.
  17401. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17402. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17403. */
  17404. var WebVRFreeCamera = /** @class */ (function (_super) {
  17405. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17406. /**
  17407. * Instantiates a WebVRFreeCamera.
  17408. * @param name The name of the WebVRFreeCamera
  17409. * @param position The starting anchor position for the camera
  17410. * @param scene The scene the camera belongs to
  17411. * @param webVROptions a set of customizable options for the webVRCamera
  17412. */
  17413. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17414. if (webVROptions === void 0) { webVROptions = {}; }
  17415. var _this = _super.call(this, name, position, scene) || this;
  17416. _this.webVROptions = webVROptions;
  17417. /**
  17418. * @hidden
  17419. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17420. */
  17421. _this._vrDevice = null;
  17422. /**
  17423. * The rawPose of the vrDevice.
  17424. */
  17425. _this.rawPose = null;
  17426. _this._specsVersion = "1.1";
  17427. _this._attached = false;
  17428. _this._descendants = [];
  17429. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17430. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17431. /** @hidden */
  17432. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17433. _this._standingMatrix = null;
  17434. /**
  17435. * Represents device position in babylon space.
  17436. */
  17437. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17438. /**
  17439. * Represents device rotation in babylon space.
  17440. */
  17441. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17442. /**
  17443. * The scale of the device to be used when translating from device space to babylon space.
  17444. */
  17445. _this.deviceScaleFactor = 1;
  17446. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17447. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17448. /**
  17449. * References to the webVR controllers for the vrDevice.
  17450. */
  17451. _this.controllers = [];
  17452. /**
  17453. * Emits an event when a controller is attached.
  17454. */
  17455. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17456. /**
  17457. * Emits an event when a controller's mesh has been loaded;
  17458. */
  17459. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17460. /**
  17461. * Emits an event when the HMD's pose has been updated.
  17462. */
  17463. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17464. _this._poseSet = false;
  17465. /**
  17466. * If the rig cameras be used as parent instead of this camera.
  17467. */
  17468. _this.rigParenting = true;
  17469. _this._defaultHeight = undefined;
  17470. _this._htmlElementAttached = null;
  17471. _this._detachIfAttached = function () {
  17472. var vrDisplay = _this.getEngine().getVRDevice();
  17473. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17474. _this.detachControl(_this._htmlElementAttached);
  17475. }
  17476. };
  17477. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17478. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17479. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17480. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17481. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17482. if (webVROptions.defaultHeight) {
  17483. _this._defaultHeight = webVROptions.defaultHeight;
  17484. _this.position.y = _this._defaultHeight;
  17485. }
  17486. _this.minZ = 0.1;
  17487. //legacy support - the compensation boolean was removed.
  17488. if (arguments.length === 5) {
  17489. _this.webVROptions = arguments[4];
  17490. }
  17491. // default webVR options
  17492. if (_this.webVROptions.trackPosition == undefined) {
  17493. _this.webVROptions.trackPosition = true;
  17494. }
  17495. if (_this.webVROptions.controllerMeshes == undefined) {
  17496. _this.webVROptions.controllerMeshes = true;
  17497. }
  17498. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17499. _this.webVROptions.defaultLightingOnControllers = true;
  17500. }
  17501. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17502. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17503. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17504. }
  17505. //enable VR
  17506. var engine = _this.getEngine();
  17507. _this._onVREnabled = function (success) { if (success) {
  17508. _this.initControllers();
  17509. } };
  17510. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17511. engine.initWebVR().add(function (event) {
  17512. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17513. return;
  17514. }
  17515. _this._vrDevice = event.vrDisplay;
  17516. //reset the rig parameters.
  17517. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17518. if (_this._attached) {
  17519. _this.getEngine().enableVR();
  17520. }
  17521. });
  17522. if (typeof (VRFrameData) !== "undefined") {
  17523. _this._frameData = new VRFrameData();
  17524. }
  17525. /**
  17526. * The idea behind the following lines:
  17527. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17528. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17529. * the second will not show it correctly.
  17530. *
  17531. * To solve this - each object that has the camera as parent will be added to a protected array.
  17532. * When the rig camera renders, it will take this array and set all of those to be its children.
  17533. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17534. * Amazing!
  17535. */
  17536. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17537. if (camera.parent === _this && _this.rigParenting) {
  17538. _this._descendants = _this.getDescendants(true, function (n) {
  17539. // don't take the cameras or the controllers!
  17540. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17541. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17542. return !isController && !isRigCamera;
  17543. });
  17544. _this._descendants.forEach(function (node) {
  17545. node.parent = camera;
  17546. });
  17547. }
  17548. });
  17549. scene.onAfterCameraRenderObservable.add(function (camera) {
  17550. if (camera.parent === _this && _this.rigParenting) {
  17551. _this._descendants.forEach(function (node) {
  17552. node.parent = _this;
  17553. });
  17554. }
  17555. });
  17556. return _this;
  17557. }
  17558. /**
  17559. * Gets the device distance from the ground in meters.
  17560. * @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.
  17561. */
  17562. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17563. if (this._standingMatrix) {
  17564. // Add standing matrix offset to get real offset from ground in room
  17565. this._standingMatrix.getTranslationToRef(this._workingVector);
  17566. return this._deviceRoomPosition.y + this._workingVector.y;
  17567. }
  17568. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17569. return this._defaultHeight || 0;
  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. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17574. */
  17575. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17576. var _this = this;
  17577. if (callback === void 0) { callback = function (bool) { }; }
  17578. // Use standing matrix if available
  17579. this.getEngine().initWebVRAsync().then(function (result) {
  17580. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17581. callback(false);
  17582. }
  17583. else {
  17584. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17585. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17586. if (!_this.getScene().useRightHandedSystem) {
  17587. if (_this._standingMatrix) {
  17588. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17589. }
  17590. }
  17591. callback(true);
  17592. }
  17593. });
  17594. };
  17595. /**
  17596. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17597. * @returns A promise with a boolean set to if the standing matrix is supported.
  17598. */
  17599. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17600. var _this = this;
  17601. return new Promise(function (res) {
  17602. _this.useStandingMatrix(function (supported) {
  17603. res(supported);
  17604. });
  17605. });
  17606. };
  17607. /**
  17608. * Disposes the camera
  17609. */
  17610. WebVRFreeCamera.prototype.dispose = function () {
  17611. this._detachIfAttached();
  17612. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  17613. if (this._updateCacheWhenTrackingDisabledObserver) {
  17614. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  17615. }
  17616. _super.prototype.dispose.call(this);
  17617. };
  17618. /**
  17619. * Gets a vrController by name.
  17620. * @param name The name of the controller to retreive
  17621. * @returns the controller matching the name specified or null if not found
  17622. */
  17623. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  17624. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  17625. var gp = _a[_i];
  17626. if (gp.hand === name) {
  17627. return gp;
  17628. }
  17629. }
  17630. return null;
  17631. };
  17632. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  17633. /**
  17634. * The controller corrisponding to the users left hand.
  17635. */
  17636. get: function () {
  17637. if (!this._leftController) {
  17638. this._leftController = this.getControllerByName("left");
  17639. }
  17640. return this._leftController;
  17641. },
  17642. enumerable: true,
  17643. configurable: true
  17644. });
  17645. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  17646. /**
  17647. * The controller corrisponding to the users right hand.
  17648. */
  17649. get: function () {
  17650. if (!this._rightController) {
  17651. this._rightController = this.getControllerByName("right");
  17652. }
  17653. return this._rightController;
  17654. },
  17655. enumerable: true,
  17656. configurable: true
  17657. });
  17658. /**
  17659. * Casts a ray forward from the vrCamera's gaze.
  17660. * @param length Length of the ray (default: 100)
  17661. * @returns the ray corrisponding to the gaze
  17662. */
  17663. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  17664. if (length === void 0) { length = 100; }
  17665. if (this.leftCamera) {
  17666. // Use left eye to avoid computation to compute center on every call
  17667. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  17668. }
  17669. else {
  17670. return _super.prototype.getForwardRay.call(this, length);
  17671. }
  17672. };
  17673. /**
  17674. * @hidden
  17675. * Updates the camera based on device's frame data
  17676. */
  17677. WebVRFreeCamera.prototype._checkInputs = function () {
  17678. if (this._vrDevice && this._vrDevice.isPresenting) {
  17679. this._vrDevice.getFrameData(this._frameData);
  17680. this.updateFromDevice(this._frameData.pose);
  17681. }
  17682. _super.prototype._checkInputs.call(this);
  17683. };
  17684. /**
  17685. * Updates the poseControlled values based on the input device pose.
  17686. * @param poseData Pose coming from the device
  17687. */
  17688. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  17689. if (poseData && poseData.orientation) {
  17690. this.rawPose = poseData;
  17691. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  17692. if (this.getScene().useRightHandedSystem) {
  17693. this._deviceRoomRotationQuaternion.z *= -1;
  17694. this._deviceRoomRotationQuaternion.w *= -1;
  17695. }
  17696. if (this.webVROptions.trackPosition && this.rawPose.position) {
  17697. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  17698. if (this.getScene().useRightHandedSystem) {
  17699. this._deviceRoomPosition.z *= -1;
  17700. }
  17701. }
  17702. this._poseSet = true;
  17703. }
  17704. };
  17705. /**
  17706. * WebVR's attach control will start broadcasting frames to the device.
  17707. * Note that in certain browsers (chrome for example) this function must be called
  17708. * within a user-interaction callback. Example:
  17709. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17710. *
  17711. * @param element html element to attach the vrDevice to
  17712. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17713. */
  17714. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17715. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17716. this._attached = true;
  17717. this._htmlElementAttached = element;
  17718. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17719. if (this._vrDevice) {
  17720. this.getEngine().enableVR();
  17721. }
  17722. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17723. };
  17724. /**
  17725. * Detaches the camera from the html element and disables VR
  17726. *
  17727. * @param element html element to detach from
  17728. */
  17729. WebVRFreeCamera.prototype.detachControl = function (element) {
  17730. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17731. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17732. _super.prototype.detachControl.call(this, element);
  17733. this._attached = false;
  17734. this.getEngine().disableVR();
  17735. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17736. };
  17737. /**
  17738. * @returns the name of this class
  17739. */
  17740. WebVRFreeCamera.prototype.getClassName = function () {
  17741. return "WebVRFreeCamera";
  17742. };
  17743. /**
  17744. * Calls resetPose on the vrDisplay
  17745. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17746. */
  17747. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17748. //uses the vrDisplay's "resetPose()".
  17749. //pitch and roll won't be affected.
  17750. this._vrDevice.resetPose();
  17751. };
  17752. /**
  17753. * @hidden
  17754. * Updates the rig cameras (left and right eye)
  17755. */
  17756. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17757. var camLeft = this._rigCameras[0];
  17758. var camRight = this._rigCameras[1];
  17759. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17760. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17761. camLeft.position.copyFrom(this._deviceRoomPosition);
  17762. camRight.position.copyFrom(this._deviceRoomPosition);
  17763. };
  17764. // Remove translation from 6dof headset if trackposition is set to false
  17765. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17766. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17767. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17768. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17769. if (!isViewMatrix) {
  17770. this._tmpMatrix.invert();
  17771. }
  17772. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17773. }
  17774. };
  17775. /**
  17776. * @hidden
  17777. * Updates the cached values of the camera
  17778. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17779. */
  17780. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17781. var _this = this;
  17782. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17783. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17784. if (!this.updateCacheCalled) {
  17785. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17786. this.updateCacheCalled = true;
  17787. this.update();
  17788. }
  17789. // Set working vector to the device position in room space rotated by the new rotation
  17790. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17791. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17792. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17793. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17794. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17795. // Add translation from anchor position
  17796. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17797. this._workingVector.addInPlace(this.position);
  17798. this._workingVector.subtractInPlace(this._cache.position);
  17799. this._deviceToWorld.setTranslation(this._workingVector);
  17800. // Set an inverted matrix to be used when updating the camera
  17801. this._deviceToWorld.invertToRef(this._worldToDevice);
  17802. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17803. this.controllers.forEach(function (controller) {
  17804. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17805. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17806. controller.update();
  17807. });
  17808. }
  17809. if (!ignoreParentClass) {
  17810. _super.prototype._updateCache.call(this);
  17811. }
  17812. this.updateCacheCalled = false;
  17813. };
  17814. /**
  17815. * @hidden
  17816. * Get current device position in babylon world
  17817. */
  17818. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17819. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17820. };
  17821. /**
  17822. * Updates the current device position and rotation in the babylon world
  17823. */
  17824. WebVRFreeCamera.prototype.update = function () {
  17825. this._computeDevicePosition();
  17826. // Get current device rotation in babylon world
  17827. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17828. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17829. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17830. if (this._poseSet) {
  17831. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17832. }
  17833. _super.prototype.update.call(this);
  17834. };
  17835. /**
  17836. * @hidden
  17837. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17838. * @returns an identity matrix
  17839. */
  17840. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17841. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17842. };
  17843. /**
  17844. * This function is called by the two RIG cameras.
  17845. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17846. * @hidden
  17847. */
  17848. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17849. // Update the parent camera prior to using a child camera to avoid desynchronization
  17850. var parentCamera = this._cameraRigParams["parentCamera"];
  17851. parentCamera._updateCache();
  17852. //WebVR 1.1
  17853. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17854. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17855. if (!this.getScene().useRightHandedSystem) {
  17856. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17857. }
  17858. // update the camera rotation matrix
  17859. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17860. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17861. // Computing target and final matrix
  17862. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17863. // should the view matrix be updated with scale and position offset?
  17864. if (parentCamera.deviceScaleFactor !== 1) {
  17865. this._webvrViewMatrix.invert();
  17866. // scale the position, if set
  17867. if (parentCamera.deviceScaleFactor) {
  17868. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17869. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17870. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17871. }
  17872. this._webvrViewMatrix.invert();
  17873. }
  17874. // Remove translation from 6dof headset if trackposition is set to false
  17875. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17876. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17877. // Compute global position
  17878. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17879. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17880. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17881. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17882. this._markSyncedWithParent();
  17883. return this._webvrViewMatrix;
  17884. };
  17885. /** @hidden */
  17886. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17887. var parentCamera = this.parent;
  17888. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17889. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17890. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17891. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17892. //babylon compatible matrix
  17893. if (!this.getScene().useRightHandedSystem) {
  17894. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17895. }
  17896. return this._projectionMatrix;
  17897. };
  17898. /**
  17899. * Initializes the controllers and their meshes
  17900. */
  17901. WebVRFreeCamera.prototype.initControllers = function () {
  17902. var _this = this;
  17903. this.controllers = [];
  17904. var manager = this.getScene().gamepadManager;
  17905. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17906. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17907. var webVrController = gamepad;
  17908. if (webVrController.defaultModel) {
  17909. webVrController.defaultModel.setEnabled(false);
  17910. }
  17911. if (webVrController.hand === "right") {
  17912. _this._rightController = null;
  17913. }
  17914. if (webVrController.hand === "left") {
  17915. _this._leftController = null;
  17916. }
  17917. var controllerIndex = _this.controllers.indexOf(webVrController);
  17918. if (controllerIndex !== -1) {
  17919. _this.controllers.splice(controllerIndex, 1);
  17920. }
  17921. }
  17922. });
  17923. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17924. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17925. var webVrController_1 = gamepad;
  17926. if (!_this.webVROptions.trackPosition) {
  17927. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17928. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17929. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17930. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17931. _this._updateCache();
  17932. });
  17933. }
  17934. }
  17935. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17936. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17937. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17938. if (_this.webVROptions.controllerMeshes) {
  17939. if (webVrController_1.defaultModel) {
  17940. webVrController_1.defaultModel.setEnabled(true);
  17941. }
  17942. else {
  17943. // Load the meshes
  17944. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17945. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17946. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17947. if (_this.webVROptions.defaultLightingOnControllers) {
  17948. if (!_this._lightOnControllers) {
  17949. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17950. }
  17951. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17952. var children = mesh.getChildren();
  17953. if (children && children.length !== 0) {
  17954. children.forEach(function (mesh) {
  17955. light.includedOnlyMeshes.push(mesh);
  17956. activateLightOnSubMeshes_1(mesh, light);
  17957. });
  17958. }
  17959. };
  17960. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17961. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17962. }
  17963. });
  17964. }
  17965. }
  17966. webVrController_1.attachToPoseControlledCamera(_this);
  17967. // since this is async - sanity check. Is the controller already stored?
  17968. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17969. //add to the controllers array
  17970. _this.controllers.push(webVrController_1);
  17971. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17972. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17973. // So we're overriding setting left & right manually to be sure
  17974. var firstViveWandDetected = false;
  17975. for (var i = 0; i < _this.controllers.length; i++) {
  17976. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17977. if (!firstViveWandDetected) {
  17978. firstViveWandDetected = true;
  17979. _this.controllers[i].hand = "left";
  17980. }
  17981. else {
  17982. _this.controllers[i].hand = "right";
  17983. }
  17984. }
  17985. }
  17986. //did we find enough controllers? Great! let the developer know.
  17987. if (_this.controllers.length >= 2) {
  17988. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17989. }
  17990. }
  17991. }
  17992. });
  17993. };
  17994. return WebVRFreeCamera;
  17995. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17996. /***/ }),
  17997. /***/ "./Cameras/XR/index.ts":
  17998. /*!*****************************!*\
  17999. !*** ./Cameras/XR/index.ts ***!
  18000. \*****************************/
  18001. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18003. "use strict";
  18004. __webpack_require__.r(__webpack_exports__);
  18005. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18007. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18011. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18014. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18017. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18019. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18021. /***/ }),
  18022. /***/ "./Cameras/XR/webXRCamera.ts":
  18023. /*!***********************************!*\
  18024. !*** ./Cameras/XR/webXRCamera.ts ***!
  18025. \***********************************/
  18026. /*! exports provided: WebXRCamera */
  18027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18028. "use strict";
  18029. __webpack_require__.r(__webpack_exports__);
  18030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18031. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18032. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18033. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18034. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18035. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18036. /**
  18037. * WebXR Camera which holds the views for the xrSession
  18038. * @see https://doc.babylonjs.com/how_to/webxr
  18039. */
  18040. var WebXRCamera = /** @class */ (function (_super) {
  18041. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18042. /**
  18043. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18044. * @param name the name of the camera
  18045. * @param scene the scene to add the camera to
  18046. */
  18047. function WebXRCamera(name, scene) {
  18048. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18049. // Initial camera configuration
  18050. _this.minZ = 0;
  18051. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18052. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18053. _this.updateUpVectorFromRotation = true;
  18054. _this._updateNumberOfRigCameras(1);
  18055. return _this;
  18056. }
  18057. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18058. if (viewCount === void 0) { viewCount = 1; }
  18059. while (this.rigCameras.length < viewCount) {
  18060. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18061. newCamera.minZ = 0;
  18062. newCamera.parent = this;
  18063. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18064. newCamera.updateUpVectorFromRotation = true;
  18065. this.rigCameras.push(newCamera);
  18066. }
  18067. while (this.rigCameras.length > viewCount) {
  18068. var removedCamera = this.rigCameras.pop();
  18069. if (removedCamera) {
  18070. removedCamera.dispose();
  18071. }
  18072. }
  18073. };
  18074. /** @hidden */
  18075. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18076. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18077. // Create initial camera rigs
  18078. this._updateNumberOfRigCameras(2);
  18079. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18080. this.rigCameras[0].position.x = -pupilDistance / 2;
  18081. this.rigCameras[0].outputRenderTarget = null;
  18082. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18083. this.rigCameras[1].position.x = pupilDistance / 2;
  18084. this.rigCameras[1].outputRenderTarget = null;
  18085. };
  18086. /**
  18087. * Updates the cameras position from the current pose information of the XR session
  18088. * @param xrSessionManager the session containing pose information
  18089. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18090. */
  18091. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18092. var _this = this;
  18093. // Ensure all frame data is available
  18094. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18095. return false;
  18096. }
  18097. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18098. if (!pose || !pose.poseModelMatrix) {
  18099. return false;
  18100. }
  18101. // Update the parent cameras matrix
  18102. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18103. if (!this._scene.useRightHandedSystem) {
  18104. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18105. }
  18106. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18107. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18108. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18109. this.computeWorldMatrix();
  18110. // Update camera rigs
  18111. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18112. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18113. // Update view/projection matrix
  18114. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18115. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18116. if (!_this._scene.useRightHandedSystem) {
  18117. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18118. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18119. }
  18120. // Update viewport
  18121. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18122. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18123. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18124. _this.rigCameras[i].viewport.width = viewport.width / width;
  18125. _this.rigCameras[i].viewport.height = viewport.height / height;
  18126. _this.rigCameras[i].viewport.x = viewport.x / width;
  18127. _this.rigCameras[i].viewport.y = viewport.y / height;
  18128. // Set cameras to render to the session's render target
  18129. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18130. });
  18131. return true;
  18132. };
  18133. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18134. return WebXRCamera;
  18135. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18136. /***/ }),
  18137. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18138. /*!****************************************!*\
  18139. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18140. \****************************************/
  18141. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18143. "use strict";
  18144. __webpack_require__.r(__webpack_exports__);
  18145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18148. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18149. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18150. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18151. /**
  18152. * Button which can be used to enter a different mode of XR
  18153. */
  18154. var WebXREnterExitUIButton = /** @class */ (function () {
  18155. /**
  18156. * Creates a WebXREnterExitUIButton
  18157. * @param element button element
  18158. * @param initializationOptions XR initialization options for the button
  18159. */
  18160. function WebXREnterExitUIButton(
  18161. /** button element */
  18162. element,
  18163. /** XR initialization options for the button */
  18164. initializationOptions) {
  18165. this.element = element;
  18166. this.initializationOptions = initializationOptions;
  18167. }
  18168. /**
  18169. * Overwritable function which can be used to update the button's visuals when the state changes
  18170. * @param activeButton the current active button in the UI
  18171. */
  18172. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18173. };
  18174. return WebXREnterExitUIButton;
  18175. }());
  18176. /**
  18177. * Options to create the webXR UI
  18178. */
  18179. var WebXREnterExitUIOptions = /** @class */ (function () {
  18180. function WebXREnterExitUIOptions() {
  18181. }
  18182. return WebXREnterExitUIOptions;
  18183. }());
  18184. /**
  18185. * UI to allow the user to enter/exit XR mode
  18186. */
  18187. var WebXREnterExitUI = /** @class */ (function () {
  18188. function WebXREnterExitUI(scene, options) {
  18189. var _this = this;
  18190. this.scene = scene;
  18191. this._buttons = [];
  18192. this._activeButton = null;
  18193. /**
  18194. * Fired every time the active button is changed.
  18195. *
  18196. * When xr is entered via a button that launches xr that button will be the callback parameter
  18197. *
  18198. * When exiting xr the callback parameter will be null)
  18199. */
  18200. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18201. this._overlay = document.createElement("div");
  18202. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18203. if (options.customButtons) {
  18204. this._buttons = options.customButtons;
  18205. }
  18206. else {
  18207. var hmdBtn = document.createElement("button");
  18208. 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;";
  18209. hmdBtn.innerText = "HMD";
  18210. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18211. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18212. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18213. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18214. };
  18215. var windowBtn = document.createElement("button");
  18216. windowBtn.style.cssText = hmdBtn.style.cssText;
  18217. windowBtn.innerText = "Window";
  18218. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18219. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18220. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18221. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18222. };
  18223. this._updateButtons(null);
  18224. }
  18225. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18226. if (renderCanvas && renderCanvas.parentNode) {
  18227. renderCanvas.parentNode.appendChild(this._overlay);
  18228. scene.onDisposeObservable.addOnce(function () {
  18229. _this.dispose();
  18230. });
  18231. }
  18232. }
  18233. /**
  18234. * Creates UI to allow the user to enter/exit XR mode
  18235. * @param scene the scene to add the ui to
  18236. * @param helper the xr experience helper to enter/exit xr with
  18237. * @param options options to configure the UI
  18238. * @returns the created ui
  18239. */
  18240. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18241. var _this = this;
  18242. var ui = new WebXREnterExitUI(scene, options);
  18243. var supportedPromises = ui._buttons.map(function (btn) {
  18244. return helper.supportsSessionAsync(btn.initializationOptions);
  18245. });
  18246. helper.onStateChangedObservable.add(function (state) {
  18247. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18248. ui._updateButtons(null);
  18249. }
  18250. });
  18251. return Promise.all(supportedPromises).then(function (results) {
  18252. results.forEach(function (supported, i) {
  18253. if (supported) {
  18254. ui._overlay.appendChild(ui._buttons[i].element);
  18255. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18256. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18257. switch (_a.label) {
  18258. case 0:
  18259. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18260. ui._updateButtons(null);
  18261. return [4 /*yield*/, helper.exitXRAsync()];
  18262. case 1:
  18263. _a.sent();
  18264. return [2 /*return*/];
  18265. case 2:
  18266. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18267. ui._updateButtons(ui._buttons[i]);
  18268. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18269. case 3:
  18270. _a.sent();
  18271. _a.label = 4;
  18272. case 4: return [2 /*return*/];
  18273. }
  18274. });
  18275. }); };
  18276. }
  18277. });
  18278. return ui;
  18279. });
  18280. };
  18281. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18282. var _this = this;
  18283. this._activeButton = activeButton;
  18284. this._buttons.forEach(function (b) {
  18285. b.update(_this._activeButton);
  18286. });
  18287. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18288. };
  18289. /**
  18290. * Disposes of the object
  18291. */
  18292. WebXREnterExitUI.prototype.dispose = function () {
  18293. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18294. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18295. renderCanvas.parentNode.removeChild(this._overlay);
  18296. }
  18297. this.activeButtonChangedObservable.clear();
  18298. };
  18299. return WebXREnterExitUI;
  18300. }());
  18301. /***/ }),
  18302. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18303. /*!*********************************************!*\
  18304. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18305. \*********************************************/
  18306. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18308. "use strict";
  18309. __webpack_require__.r(__webpack_exports__);
  18310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18312. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18313. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18314. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18315. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18316. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18317. /**
  18318. * States of the webXR experience
  18319. */
  18320. var WebXRState;
  18321. (function (WebXRState) {
  18322. /**
  18323. * Transitioning to being in XR mode
  18324. */
  18325. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18326. /**
  18327. * Transitioning to non XR mode
  18328. */
  18329. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18330. /**
  18331. * In XR mode and presenting
  18332. */
  18333. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18334. /**
  18335. * Not entered XR mode
  18336. */
  18337. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18338. })(WebXRState || (WebXRState = {}));
  18339. /**
  18340. * Helper class used to enable XR
  18341. * @see https://doc.babylonjs.com/how_to/webxr
  18342. */
  18343. var WebXRExperienceHelper = /** @class */ (function () {
  18344. /**
  18345. * Creates a WebXRExperienceHelper
  18346. * @param scene The scene the helper should be created in
  18347. */
  18348. function WebXRExperienceHelper(scene) {
  18349. this.scene = scene;
  18350. /**
  18351. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18352. */
  18353. this.state = WebXRState.NOT_IN_XR;
  18354. /**
  18355. * Fires when the state of the experience helper has changed
  18356. */
  18357. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18358. this._nonVRCamera = null;
  18359. this._originalSceneAutoClear = true;
  18360. this._supported = false;
  18361. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18362. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18363. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18364. this.camera.parent = this.container;
  18365. }
  18366. WebXRExperienceHelper.prototype._setState = function (val) {
  18367. this.state = val;
  18368. this.onStateChangedObservable.notifyObservers(this.state);
  18369. };
  18370. /**
  18371. * Creates the experience helper
  18372. * @param scene the scene to attach the experience helper to
  18373. * @returns a promise for the experience helper
  18374. */
  18375. WebXRExperienceHelper.CreateAsync = function (scene) {
  18376. var helper = new WebXRExperienceHelper(scene);
  18377. return helper._sessionManager.initializeAsync().then(function () {
  18378. helper._supported = true;
  18379. return helper;
  18380. }).catch(function () {
  18381. return helper;
  18382. });
  18383. };
  18384. /**
  18385. * Exits XR mode and returns the scene to its original state
  18386. * @returns promise that resolves after xr mode has exited
  18387. */
  18388. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18389. this._setState(WebXRState.EXITING_XR);
  18390. return this._sessionManager.exitXRAsync();
  18391. };
  18392. /**
  18393. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18394. * @param sessionCreationOptions options for the XR session
  18395. * @param frameOfReference frame of reference of the XR session
  18396. * @returns promise that resolves after xr mode has entered
  18397. */
  18398. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18399. var _this = this;
  18400. if (!this._supported) {
  18401. throw "XR session not supported by this browser";
  18402. }
  18403. this._setState(WebXRState.ENTERING_XR);
  18404. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18405. // Cache pre xr scene settings
  18406. _this._originalSceneAutoClear = _this.scene.autoClear;
  18407. _this._nonVRCamera = _this.scene.activeCamera;
  18408. // Overwrite current scene settings
  18409. _this.scene.autoClear = false;
  18410. _this.scene.activeCamera = _this.camera;
  18411. _this._sessionManager.onXRFrameObservable.add(function () {
  18412. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18413. });
  18414. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18415. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18416. _this.camera.rigCameras.forEach(function (c) {
  18417. c.outputRenderTarget = null;
  18418. });
  18419. // Restore scene settings
  18420. _this.scene.autoClear = _this._originalSceneAutoClear;
  18421. _this.scene.activeCamera = _this._nonVRCamera;
  18422. _this._sessionManager.onXRFrameObservable.clear();
  18423. _this._setState(WebXRState.NOT_IN_XR);
  18424. });
  18425. _this._setState(WebXRState.IN_XR);
  18426. });
  18427. };
  18428. /**
  18429. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18430. * @param ray ray to cast into the environment
  18431. * @returns Promise which resolves with a collision point in the environment if it exists
  18432. */
  18433. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18434. return this._sessionManager.environmentPointHitTestAsync(ray);
  18435. };
  18436. /**
  18437. * Updates the global position of the camera by moving the camera's container
  18438. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18439. * @param position The desired global position of the camera
  18440. */
  18441. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18442. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18443. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18444. };
  18445. /**
  18446. * Rotates the xr camera by rotating the camera's container around the camera's position
  18447. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18448. * @param rotation the desired quaternion rotation to apply to the camera
  18449. */
  18450. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18451. if (!this.container.rotationQuaternion) {
  18452. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18453. }
  18454. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18455. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18456. };
  18457. /**
  18458. * Checks if the creation options are supported by the xr session
  18459. * @param options creation options
  18460. * @returns true if supported
  18461. */
  18462. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18463. if (!this._supported) {
  18464. return Promise.resolve(false);
  18465. }
  18466. return this._sessionManager.supportsSessionAsync(options);
  18467. };
  18468. /**
  18469. * Disposes of the experience helper
  18470. */
  18471. WebXRExperienceHelper.prototype.dispose = function () {
  18472. this.camera.dispose();
  18473. this.container.dispose();
  18474. this.onStateChangedObservable.clear();
  18475. this._sessionManager.dispose();
  18476. };
  18477. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18478. return WebXRExperienceHelper;
  18479. }());
  18480. /***/ }),
  18481. /***/ "./Cameras/XR/webXRInput.ts":
  18482. /*!**********************************!*\
  18483. !*** ./Cameras/XR/webXRInput.ts ***!
  18484. \**********************************/
  18485. /*! exports provided: WebXRController, WebXRInput */
  18486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18487. "use strict";
  18488. __webpack_require__.r(__webpack_exports__);
  18489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18491. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18492. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18493. /**
  18494. * Represents an XR input
  18495. */
  18496. var WebXRController = /** @class */ (function () {
  18497. /**
  18498. * Creates the controller
  18499. * @see https://doc.babylonjs.com/how_to/webxr
  18500. * @param scene the scene which the controller should be associated to
  18501. */
  18502. function WebXRController(scene) {
  18503. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18504. }
  18505. /**
  18506. * Disposes of the object
  18507. */
  18508. WebXRController.prototype.dispose = function () {
  18509. if (this.grip) {
  18510. this.grip.dispose();
  18511. }
  18512. this.pointer.dispose();
  18513. };
  18514. return WebXRController;
  18515. }());
  18516. /**
  18517. * XR input used to track XR inputs such as controllers/rays
  18518. */
  18519. var WebXRInput = /** @class */ (function () {
  18520. /**
  18521. * Initializes the WebXRInput
  18522. * @param helper experience helper which the input should be created for
  18523. */
  18524. function WebXRInput(helper) {
  18525. var _this = this;
  18526. this.helper = helper;
  18527. /**
  18528. * XR controllers being tracked
  18529. */
  18530. this.controllers = [];
  18531. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18532. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18533. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18534. return;
  18535. }
  18536. var xrFrame = helper._sessionManager._currentXRFrame;
  18537. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18538. inputSources.forEach(function (input, i) {
  18539. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18540. if (inputPose) {
  18541. if (_this.controllers.length <= i) {
  18542. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18543. }
  18544. var controller = _this.controllers[i];
  18545. // Manage the grip if it exists
  18546. if (inputPose.gripMatrix) {
  18547. if (!controller.grip) {
  18548. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18549. }
  18550. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18551. if (!controller.grip.getScene().useRightHandedSystem) {
  18552. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18553. }
  18554. if (!controller.grip.rotationQuaternion) {
  18555. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18556. }
  18557. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18558. }
  18559. // Manager pointer of controller
  18560. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18561. if (!controller.pointer.getScene().useRightHandedSystem) {
  18562. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18563. }
  18564. if (!controller.pointer.rotationQuaternion) {
  18565. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18566. }
  18567. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18568. }
  18569. });
  18570. });
  18571. }
  18572. /**
  18573. * Disposes of the object
  18574. */
  18575. WebXRInput.prototype.dispose = function () {
  18576. this.controllers.forEach(function (c) {
  18577. c.dispose();
  18578. });
  18579. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18580. };
  18581. return WebXRInput;
  18582. }());
  18583. /***/ }),
  18584. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18585. /*!************************************************!*\
  18586. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18587. \************************************************/
  18588. /*! exports provided: WebXRManagedOutputCanvas */
  18589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18590. "use strict";
  18591. __webpack_require__.r(__webpack_exports__);
  18592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18593. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18594. /**
  18595. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18596. */
  18597. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18598. /**
  18599. * Initializes the canvas to be added/removed upon entering/exiting xr
  18600. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18601. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18602. */
  18603. function WebXRManagedOutputCanvas(helper, canvas) {
  18604. var _this = this;
  18605. this._canvas = null;
  18606. /**
  18607. * xrpresent context of the canvas which can be used to display/mirror xr content
  18608. */
  18609. this.canvasContext = null;
  18610. if (!canvas) {
  18611. canvas = document.createElement('canvas');
  18612. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  18613. }
  18614. this._setManagedOutputCanvas(canvas);
  18615. helper.onStateChangedObservable.add(function (stateInfo) {
  18616. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  18617. // 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
  18618. _this._addCanvas();
  18619. }
  18620. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  18621. _this._removeCanvas();
  18622. }
  18623. });
  18624. }
  18625. /**
  18626. * Disposes of the object
  18627. */
  18628. WebXRManagedOutputCanvas.prototype.dispose = function () {
  18629. this._removeCanvas();
  18630. this._setManagedOutputCanvas(null);
  18631. };
  18632. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  18633. this._removeCanvas();
  18634. if (!canvas) {
  18635. this._canvas = null;
  18636. this.canvasContext = null;
  18637. }
  18638. else {
  18639. this._canvas = canvas;
  18640. this.canvasContext = this._canvas.getContext('xrpresent');
  18641. }
  18642. };
  18643. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  18644. if (this._canvas) {
  18645. document.body.appendChild(this._canvas);
  18646. }
  18647. };
  18648. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  18649. if (this._canvas && document.body.contains(this._canvas)) {
  18650. document.body.removeChild(this._canvas);
  18651. }
  18652. };
  18653. return WebXRManagedOutputCanvas;
  18654. }());
  18655. /***/ }),
  18656. /***/ "./Cameras/XR/webXRSessionManager.ts":
  18657. /*!*******************************************!*\
  18658. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  18659. \*******************************************/
  18660. /*! exports provided: WebXRSessionManager */
  18661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18662. "use strict";
  18663. __webpack_require__.r(__webpack_exports__);
  18664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  18665. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18666. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18667. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18668. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  18669. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  18670. /**
  18671. * Manages an XRSession
  18672. * @see https://doc.babylonjs.com/how_to/webxr
  18673. */
  18674. var WebXRSessionManager = /** @class */ (function () {
  18675. /**
  18676. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  18677. * @param scene The scene which the session should be created for
  18678. */
  18679. function WebXRSessionManager(scene) {
  18680. this.scene = scene;
  18681. /**
  18682. * Fires every time a new xrFrame arrives which can be used to update the camera
  18683. */
  18684. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18685. /**
  18686. * Fires when the xr session is ended either by the device or manually done
  18687. */
  18688. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18689. /** @hidden */
  18690. this._sessionRenderTargetTexture = null;
  18691. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18692. }
  18693. /**
  18694. * Initializes the manager
  18695. * After initialization enterXR can be called to start an XR session
  18696. * @returns Promise which resolves after it is initialized
  18697. */
  18698. WebXRSessionManager.prototype.initializeAsync = function () {
  18699. var _this = this;
  18700. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  18701. // Check if the browser supports webXR
  18702. this._xrNavigator = navigator;
  18703. if (!this._xrNavigator.xr) {
  18704. return Promise.reject("webXR not supported by this browser");
  18705. }
  18706. // Request the webXR device
  18707. return this._xrNavigator.xr.requestDevice().then(function (device) {
  18708. _this._xrDevice = device;
  18709. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  18710. });
  18711. };
  18712. /**
  18713. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18714. * @param sessionCreationOptions xr options to create the session with
  18715. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18716. * @returns Promise which resolves after it enters XR
  18717. */
  18718. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18719. var _this = this;
  18720. // initialize session
  18721. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18722. _this._xrSession = session;
  18723. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18724. _this._xrSession.addEventListener("end", function () {
  18725. // Remove render target texture and notify frame obervers
  18726. _this._sessionRenderTargetTexture = null;
  18727. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18728. _this.scene.getEngine().restoreDefaultFramebuffer();
  18729. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18730. _this.scene.getEngine().customAnimationFrameRequester = null;
  18731. _this.onXRSessionEnded.notifyObservers(null);
  18732. _this.scene.getEngine()._renderLoop();
  18733. }, { once: true });
  18734. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18735. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18736. }).then(function (frameOfRef) {
  18737. _this._frameOfReference = frameOfRef;
  18738. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18739. _this.scene.getEngine().customAnimationFrameRequester = {
  18740. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18741. renderFunction: function (timestamp, xrFrame) {
  18742. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18743. _this._currentXRFrame = xrFrame;
  18744. _this.onXRFrameObservable.notifyObservers(null);
  18745. _this.scene.getEngine()._renderLoop();
  18746. }
  18747. };
  18748. // Create render target texture from xr's webgl render target
  18749. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18750. // Stop window's animation frame and trigger sessions animation frame
  18751. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18752. _this.scene.getEngine()._renderLoop();
  18753. });
  18754. };
  18755. /**
  18756. * Stops the xrSession and restores the renderloop
  18757. * @returns Promise which resolves after it exits XR
  18758. */
  18759. WebXRSessionManager.prototype.exitXRAsync = function () {
  18760. return this._xrSession.end();
  18761. };
  18762. /**
  18763. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18764. * @param ray ray to cast into the environment
  18765. * @returns Promise which resolves with a collision point in the environment if it exists
  18766. */
  18767. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18768. var _this = this;
  18769. return new Promise(function (res) {
  18770. // Compute left handed inputs to request hit test
  18771. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18772. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18773. if (!_this.scene.useRightHandedSystem) {
  18774. origin[2] *= -1;
  18775. direction[2] *= -1;
  18776. }
  18777. // Fire hittest
  18778. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18779. .then(function (hits) {
  18780. if (hits.length > 0) {
  18781. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18782. var hitPoint = _this._tmpMatrix.getTranslation();
  18783. if (!_this.scene.useRightHandedSystem) {
  18784. hitPoint.z *= -1;
  18785. }
  18786. res(hitPoint);
  18787. }
  18788. else {
  18789. res(null);
  18790. }
  18791. }).catch(function () {
  18792. res(null);
  18793. });
  18794. });
  18795. };
  18796. /**
  18797. * Checks if a session would be supported for the creation options specified
  18798. * @param options creation options to check if they are supported
  18799. * @returns true if supported
  18800. */
  18801. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18802. return this._xrDevice.supportsSession(options).then(function () {
  18803. return true;
  18804. }).catch(function () {
  18805. return false;
  18806. });
  18807. };
  18808. /**
  18809. * @hidden
  18810. * Converts the render layer of xrSession to a render target
  18811. * @param session session to create render target for
  18812. * @param scene scene the new render target should be created for
  18813. */
  18814. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18815. // Create internal texture
  18816. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18817. internalTexture.width = session.baseLayer.framebufferWidth;
  18818. internalTexture.height = session.baseLayer.framebufferHeight;
  18819. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18820. // Create render target texture from the internal texture
  18821. 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);
  18822. renderTargetTexture._texture = internalTexture;
  18823. return renderTargetTexture;
  18824. };
  18825. /**
  18826. * Disposes of the session manager
  18827. */
  18828. WebXRSessionManager.prototype.dispose = function () {
  18829. this.onXRFrameObservable.clear();
  18830. this.onXRSessionEnded.clear();
  18831. };
  18832. return WebXRSessionManager;
  18833. }());
  18834. /***/ }),
  18835. /***/ "./Cameras/arcRotateCamera.ts":
  18836. /*!************************************!*\
  18837. !*** ./Cameras/arcRotateCamera.ts ***!
  18838. \************************************/
  18839. /*! exports provided: ArcRotateCamera */
  18840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18841. "use strict";
  18842. __webpack_require__.r(__webpack_exports__);
  18843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18844. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18845. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18846. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18847. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18848. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18849. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18850. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18851. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18852. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18853. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18854. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18855. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18856. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18857. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18858. });
  18859. /**
  18860. * This represents an orbital type of camera.
  18861. *
  18862. * 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.
  18863. * 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.
  18864. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18865. */
  18866. var ArcRotateCamera = /** @class */ (function (_super) {
  18867. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18868. /**
  18869. * Instantiates a new ArcRotateCamera in a given scene
  18870. * @param name Defines the name of the camera
  18871. * @param alpha Defines the camera rotation along the logitudinal axis
  18872. * @param beta Defines the camera rotation along the latitudinal axis
  18873. * @param radius Defines the camera distance from its target
  18874. * @param target Defines the camera target
  18875. * @param scene Defines the scene the camera belongs to
  18876. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18877. */
  18878. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18879. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18880. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18881. /**
  18882. * Current inertia value on the longitudinal axis.
  18883. * The bigger this number the longer it will take for the camera to stop.
  18884. */
  18885. _this.inertialAlphaOffset = 0;
  18886. /**
  18887. * Current inertia value on the latitudinal axis.
  18888. * The bigger this number the longer it will take for the camera to stop.
  18889. */
  18890. _this.inertialBetaOffset = 0;
  18891. /**
  18892. * Current inertia value on the radius axis.
  18893. * The bigger this number the longer it will take for the camera to stop.
  18894. */
  18895. _this.inertialRadiusOffset = 0;
  18896. /**
  18897. * Minimum allowed angle on the longitudinal axis.
  18898. * This can help limiting how the Camera is able to move in the scene.
  18899. */
  18900. _this.lowerAlphaLimit = null;
  18901. /**
  18902. * Maximum allowed angle on the longitudinal axis.
  18903. * This can help limiting how the Camera is able to move in the scene.
  18904. */
  18905. _this.upperAlphaLimit = null;
  18906. /**
  18907. * Minimum allowed angle on the latitudinal axis.
  18908. * This can help limiting how the Camera is able to move in the scene.
  18909. */
  18910. _this.lowerBetaLimit = 0.01;
  18911. /**
  18912. * Maximum allowed angle on the latitudinal axis.
  18913. * This can help limiting how the Camera is able to move in the scene.
  18914. */
  18915. _this.upperBetaLimit = Math.PI - 0.01;
  18916. /**
  18917. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18918. * This can help limiting how the Camera is able to move in the scene.
  18919. */
  18920. _this.lowerRadiusLimit = null;
  18921. /**
  18922. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18923. * This can help limiting how the Camera is able to move in the scene.
  18924. */
  18925. _this.upperRadiusLimit = null;
  18926. /**
  18927. * Defines the current inertia value used during panning of the camera along the X axis.
  18928. */
  18929. _this.inertialPanningX = 0;
  18930. /**
  18931. * Defines the current inertia value used during panning of the camera along the Y axis.
  18932. */
  18933. _this.inertialPanningY = 0;
  18934. /**
  18935. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18936. * Basically if your fingers moves away from more than this distance you will be considered
  18937. * in pinch mode.
  18938. */
  18939. _this.pinchToPanMaxDistance = 20;
  18940. /**
  18941. * Defines the maximum distance the camera can pan.
  18942. * This could help keeping the cammera always in your scene.
  18943. */
  18944. _this.panningDistanceLimit = null;
  18945. /**
  18946. * Defines the target of the camera before paning.
  18947. */
  18948. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18949. /**
  18950. * Defines the value of the inertia used during panning.
  18951. * 0 would mean stop inertia and one would mean no decelleration at all.
  18952. */
  18953. _this.panningInertia = 0.9;
  18954. //-- end properties for backward compatibility for inputs
  18955. /**
  18956. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18957. */
  18958. _this.zoomOnFactor = 1;
  18959. /**
  18960. * Defines a screen offset for the camera position.
  18961. */
  18962. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18963. /**
  18964. * Allows the camera to be completely reversed.
  18965. * If false the camera can not arrive upside down.
  18966. */
  18967. _this.allowUpsideDown = true;
  18968. /**
  18969. * Define if double tap/click is used to restore the previously saved state of the camera.
  18970. */
  18971. _this.useInputToRestoreState = true;
  18972. /** @hidden */
  18973. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18974. /**
  18975. * Defines the allowed panning axis.
  18976. */
  18977. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18978. /**
  18979. * Observable triggered when the mesh target has been changed on the camera.
  18980. */
  18981. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18982. /**
  18983. * Defines whether the camera should check collision with the objects oh the scene.
  18984. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18985. */
  18986. _this.checkCollisions = false;
  18987. /**
  18988. * Defines the collision radius of the camera.
  18989. * This simulates a sphere around the camera.
  18990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18991. */
  18992. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18993. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18994. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18995. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18996. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18997. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18998. if (collidedMesh === void 0) { collidedMesh = null; }
  18999. if (!collidedMesh) {
  19000. _this._previousPosition.copyFrom(_this.position);
  19001. }
  19002. else {
  19003. _this.setPosition(newPosition);
  19004. if (_this.onCollide) {
  19005. _this.onCollide(collidedMesh);
  19006. }
  19007. }
  19008. // Recompute because of constraints
  19009. var cosa = Math.cos(_this.alpha);
  19010. var sina = Math.sin(_this.alpha);
  19011. var cosb = Math.cos(_this.beta);
  19012. var sinb = Math.sin(_this.beta);
  19013. if (sinb === 0) {
  19014. sinb = 0.0001;
  19015. }
  19016. var target = _this._getTargetPosition();
  19017. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19018. target.addToRef(_this._computationVector, _this._newPosition);
  19019. _this.position.copyFrom(_this._newPosition);
  19020. var up = _this.upVector;
  19021. if (_this.allowUpsideDown && _this.beta < 0) {
  19022. up = up.clone();
  19023. up = up.negate();
  19024. }
  19025. _this._computeViewMatrix(_this.position, target, up);
  19026. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19027. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19028. _this._collisionTriggered = false;
  19029. };
  19030. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19031. if (target) {
  19032. _this.setTarget(target);
  19033. }
  19034. _this.alpha = alpha;
  19035. _this.beta = beta;
  19036. _this.radius = radius;
  19037. _this.getViewMatrix();
  19038. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19039. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19040. return _this;
  19041. }
  19042. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19043. /**
  19044. * Defines the target point of the camera.
  19045. * The camera looks towards it form the radius distance.
  19046. */
  19047. get: function () {
  19048. return this._target;
  19049. },
  19050. set: function (value) {
  19051. this.setTarget(value);
  19052. },
  19053. enumerable: true,
  19054. configurable: true
  19055. });
  19056. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19057. //-- begin properties for backward compatibility for inputs
  19058. /**
  19059. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19060. */
  19061. get: function () {
  19062. var pointers = this.inputs.attached["pointers"];
  19063. if (pointers) {
  19064. return pointers.angularSensibilityX;
  19065. }
  19066. return 0;
  19067. },
  19068. set: function (value) {
  19069. var pointers = this.inputs.attached["pointers"];
  19070. if (pointers) {
  19071. pointers.angularSensibilityX = value;
  19072. }
  19073. },
  19074. enumerable: true,
  19075. configurable: true
  19076. });
  19077. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19078. /**
  19079. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19080. */
  19081. get: function () {
  19082. var pointers = this.inputs.attached["pointers"];
  19083. if (pointers) {
  19084. return pointers.angularSensibilityY;
  19085. }
  19086. return 0;
  19087. },
  19088. set: function (value) {
  19089. var pointers = this.inputs.attached["pointers"];
  19090. if (pointers) {
  19091. pointers.angularSensibilityY = value;
  19092. }
  19093. },
  19094. enumerable: true,
  19095. configurable: true
  19096. });
  19097. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19098. /**
  19099. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19100. */
  19101. get: function () {
  19102. var pointers = this.inputs.attached["pointers"];
  19103. if (pointers) {
  19104. return pointers.pinchPrecision;
  19105. }
  19106. return 0;
  19107. },
  19108. set: function (value) {
  19109. var pointers = this.inputs.attached["pointers"];
  19110. if (pointers) {
  19111. pointers.pinchPrecision = value;
  19112. }
  19113. },
  19114. enumerable: true,
  19115. configurable: true
  19116. });
  19117. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19118. /**
  19119. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19120. * It will be used instead of pinchDeltaPrecision if different from 0.
  19121. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19122. */
  19123. get: function () {
  19124. var pointers = this.inputs.attached["pointers"];
  19125. if (pointers) {
  19126. return pointers.pinchDeltaPercentage;
  19127. }
  19128. return 0;
  19129. },
  19130. set: function (value) {
  19131. var pointers = this.inputs.attached["pointers"];
  19132. if (pointers) {
  19133. pointers.pinchDeltaPercentage = value;
  19134. }
  19135. },
  19136. enumerable: true,
  19137. configurable: true
  19138. });
  19139. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19140. /**
  19141. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19142. */
  19143. get: function () {
  19144. var pointers = this.inputs.attached["pointers"];
  19145. if (pointers) {
  19146. return pointers.panningSensibility;
  19147. }
  19148. return 0;
  19149. },
  19150. set: function (value) {
  19151. var pointers = this.inputs.attached["pointers"];
  19152. if (pointers) {
  19153. pointers.panningSensibility = value;
  19154. }
  19155. },
  19156. enumerable: true,
  19157. configurable: true
  19158. });
  19159. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19160. /**
  19161. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19162. */
  19163. get: function () {
  19164. var keyboard = this.inputs.attached["keyboard"];
  19165. if (keyboard) {
  19166. return keyboard.keysUp;
  19167. }
  19168. return [];
  19169. },
  19170. set: function (value) {
  19171. var keyboard = this.inputs.attached["keyboard"];
  19172. if (keyboard) {
  19173. keyboard.keysUp = value;
  19174. }
  19175. },
  19176. enumerable: true,
  19177. configurable: true
  19178. });
  19179. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19180. /**
  19181. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19182. */
  19183. get: function () {
  19184. var keyboard = this.inputs.attached["keyboard"];
  19185. if (keyboard) {
  19186. return keyboard.keysDown;
  19187. }
  19188. return [];
  19189. },
  19190. set: function (value) {
  19191. var keyboard = this.inputs.attached["keyboard"];
  19192. if (keyboard) {
  19193. keyboard.keysDown = value;
  19194. }
  19195. },
  19196. enumerable: true,
  19197. configurable: true
  19198. });
  19199. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19200. /**
  19201. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19202. */
  19203. get: function () {
  19204. var keyboard = this.inputs.attached["keyboard"];
  19205. if (keyboard) {
  19206. return keyboard.keysLeft;
  19207. }
  19208. return [];
  19209. },
  19210. set: function (value) {
  19211. var keyboard = this.inputs.attached["keyboard"];
  19212. if (keyboard) {
  19213. keyboard.keysLeft = value;
  19214. }
  19215. },
  19216. enumerable: true,
  19217. configurable: true
  19218. });
  19219. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19220. /**
  19221. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19222. */
  19223. get: function () {
  19224. var keyboard = this.inputs.attached["keyboard"];
  19225. if (keyboard) {
  19226. return keyboard.keysRight;
  19227. }
  19228. return [];
  19229. },
  19230. set: function (value) {
  19231. var keyboard = this.inputs.attached["keyboard"];
  19232. if (keyboard) {
  19233. keyboard.keysRight = value;
  19234. }
  19235. },
  19236. enumerable: true,
  19237. configurable: true
  19238. });
  19239. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19240. /**
  19241. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19242. */
  19243. get: function () {
  19244. var mousewheel = this.inputs.attached["mousewheel"];
  19245. if (mousewheel) {
  19246. return mousewheel.wheelPrecision;
  19247. }
  19248. return 0;
  19249. },
  19250. set: function (value) {
  19251. var mousewheel = this.inputs.attached["mousewheel"];
  19252. if (mousewheel) {
  19253. mousewheel.wheelPrecision = value;
  19254. }
  19255. },
  19256. enumerable: true,
  19257. configurable: true
  19258. });
  19259. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19260. /**
  19261. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19262. * It will be used instead of pinchDeltaPrecision if different from 0.
  19263. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19264. */
  19265. get: function () {
  19266. var mousewheel = this.inputs.attached["mousewheel"];
  19267. if (mousewheel) {
  19268. return mousewheel.wheelDeltaPercentage;
  19269. }
  19270. return 0;
  19271. },
  19272. set: function (value) {
  19273. var mousewheel = this.inputs.attached["mousewheel"];
  19274. if (mousewheel) {
  19275. mousewheel.wheelDeltaPercentage = value;
  19276. }
  19277. },
  19278. enumerable: true,
  19279. configurable: true
  19280. });
  19281. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19282. /**
  19283. * Gets the bouncing behavior of the camera if it has been enabled.
  19284. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19285. */
  19286. get: function () {
  19287. return this._bouncingBehavior;
  19288. },
  19289. enumerable: true,
  19290. configurable: true
  19291. });
  19292. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19293. /**
  19294. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19296. */
  19297. get: function () {
  19298. return this._bouncingBehavior != null;
  19299. },
  19300. set: function (value) {
  19301. if (value === this.useBouncingBehavior) {
  19302. return;
  19303. }
  19304. if (value) {
  19305. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19306. this.addBehavior(this._bouncingBehavior);
  19307. }
  19308. else if (this._bouncingBehavior) {
  19309. this.removeBehavior(this._bouncingBehavior);
  19310. this._bouncingBehavior = null;
  19311. }
  19312. },
  19313. enumerable: true,
  19314. configurable: true
  19315. });
  19316. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19317. /**
  19318. * Gets the framing behavior of the camera if it has been enabled.
  19319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19320. */
  19321. get: function () {
  19322. return this._framingBehavior;
  19323. },
  19324. enumerable: true,
  19325. configurable: true
  19326. });
  19327. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19328. /**
  19329. * Defines if the framing behavior of the camera is enabled on the camera.
  19330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19331. */
  19332. get: function () {
  19333. return this._framingBehavior != null;
  19334. },
  19335. set: function (value) {
  19336. if (value === this.useFramingBehavior) {
  19337. return;
  19338. }
  19339. if (value) {
  19340. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19341. this.addBehavior(this._framingBehavior);
  19342. }
  19343. else if (this._framingBehavior) {
  19344. this.removeBehavior(this._framingBehavior);
  19345. this._framingBehavior = null;
  19346. }
  19347. },
  19348. enumerable: true,
  19349. configurable: true
  19350. });
  19351. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19352. /**
  19353. * Gets the auto rotation behavior of the camera if it has been enabled.
  19354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19355. */
  19356. get: function () {
  19357. return this._autoRotationBehavior;
  19358. },
  19359. enumerable: true,
  19360. configurable: true
  19361. });
  19362. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19363. /**
  19364. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19365. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19366. */
  19367. get: function () {
  19368. return this._autoRotationBehavior != null;
  19369. },
  19370. set: function (value) {
  19371. if (value === this.useAutoRotationBehavior) {
  19372. return;
  19373. }
  19374. if (value) {
  19375. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19376. this.addBehavior(this._autoRotationBehavior);
  19377. }
  19378. else if (this._autoRotationBehavior) {
  19379. this.removeBehavior(this._autoRotationBehavior);
  19380. this._autoRotationBehavior = null;
  19381. }
  19382. },
  19383. enumerable: true,
  19384. configurable: true
  19385. });
  19386. // Cache
  19387. /** @hidden */
  19388. ArcRotateCamera.prototype._initCache = function () {
  19389. _super.prototype._initCache.call(this);
  19390. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19391. this._cache.alpha = undefined;
  19392. this._cache.beta = undefined;
  19393. this._cache.radius = undefined;
  19394. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19395. };
  19396. /** @hidden */
  19397. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19398. if (!ignoreParentClass) {
  19399. _super.prototype._updateCache.call(this);
  19400. }
  19401. this._cache._target.copyFrom(this._getTargetPosition());
  19402. this._cache.alpha = this.alpha;
  19403. this._cache.beta = this.beta;
  19404. this._cache.radius = this.radius;
  19405. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19406. };
  19407. ArcRotateCamera.prototype._getTargetPosition = function () {
  19408. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19409. var pos = this._targetHost.absolutePosition;
  19410. if (this._targetBoundingCenter) {
  19411. pos.addToRef(this._targetBoundingCenter, this._target);
  19412. }
  19413. else {
  19414. this._target.copyFrom(pos);
  19415. }
  19416. }
  19417. var lockedTargetPosition = this._getLockedTargetPosition();
  19418. if (lockedTargetPosition) {
  19419. return lockedTargetPosition;
  19420. }
  19421. return this._target;
  19422. };
  19423. /**
  19424. * Stores the current state of the camera (alpha, beta, radius and target)
  19425. * @returns the camera itself
  19426. */
  19427. ArcRotateCamera.prototype.storeState = function () {
  19428. this._storedAlpha = this.alpha;
  19429. this._storedBeta = this.beta;
  19430. this._storedRadius = this.radius;
  19431. this._storedTarget = this._getTargetPosition().clone();
  19432. return _super.prototype.storeState.call(this);
  19433. };
  19434. /**
  19435. * @hidden
  19436. * Restored camera state. You must call storeState() first
  19437. */
  19438. ArcRotateCamera.prototype._restoreStateValues = function () {
  19439. if (!_super.prototype._restoreStateValues.call(this)) {
  19440. return false;
  19441. }
  19442. this.alpha = this._storedAlpha;
  19443. this.beta = this._storedBeta;
  19444. this.radius = this._storedRadius;
  19445. this.setTarget(this._storedTarget.clone());
  19446. this.inertialAlphaOffset = 0;
  19447. this.inertialBetaOffset = 0;
  19448. this.inertialRadiusOffset = 0;
  19449. this.inertialPanningX = 0;
  19450. this.inertialPanningY = 0;
  19451. return true;
  19452. };
  19453. // Synchronized
  19454. /** @hidden */
  19455. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19456. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19457. return false;
  19458. }
  19459. return this._cache._target.equals(this._getTargetPosition())
  19460. && this._cache.alpha === this.alpha
  19461. && this._cache.beta === this.beta
  19462. && this._cache.radius === this.radius
  19463. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19464. };
  19465. /**
  19466. * Attached controls to the current camera.
  19467. * @param element Defines the element the controls should be listened from
  19468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19469. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19470. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19471. */
  19472. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19473. var _this = this;
  19474. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19475. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19476. this._useCtrlForPanning = useCtrlForPanning;
  19477. this._panningMouseButton = panningMouseButton;
  19478. this.inputs.attachElement(element, noPreventDefault);
  19479. this._reset = function () {
  19480. _this.inertialAlphaOffset = 0;
  19481. _this.inertialBetaOffset = 0;
  19482. _this.inertialRadiusOffset = 0;
  19483. _this.inertialPanningX = 0;
  19484. _this.inertialPanningY = 0;
  19485. };
  19486. };
  19487. /**
  19488. * Detach the current controls from the camera.
  19489. * The camera will stop reacting to inputs.
  19490. * @param element Defines the element to stop listening the inputs from
  19491. */
  19492. ArcRotateCamera.prototype.detachControl = function (element) {
  19493. this.inputs.detachElement(element);
  19494. if (this._reset) {
  19495. this._reset();
  19496. }
  19497. };
  19498. /** @hidden */
  19499. ArcRotateCamera.prototype._checkInputs = function () {
  19500. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19501. if (this._collisionTriggered) {
  19502. return;
  19503. }
  19504. this.inputs.checkInputs();
  19505. // Inertia
  19506. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19507. var inertialAlphaOffset = this.inertialAlphaOffset;
  19508. if (this.beta <= 0) {
  19509. inertialAlphaOffset *= -1;
  19510. }
  19511. if (this.getScene().useRightHandedSystem) {
  19512. inertialAlphaOffset *= -1;
  19513. }
  19514. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19515. inertialAlphaOffset *= -1;
  19516. }
  19517. this.alpha += inertialAlphaOffset;
  19518. this.beta += this.inertialBetaOffset;
  19519. this.radius -= this.inertialRadiusOffset;
  19520. this.inertialAlphaOffset *= this.inertia;
  19521. this.inertialBetaOffset *= this.inertia;
  19522. this.inertialRadiusOffset *= this.inertia;
  19523. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19524. this.inertialAlphaOffset = 0;
  19525. }
  19526. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19527. this.inertialBetaOffset = 0;
  19528. }
  19529. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19530. this.inertialRadiusOffset = 0;
  19531. }
  19532. }
  19533. // Panning inertia
  19534. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19535. if (!this._localDirection) {
  19536. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19537. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19538. }
  19539. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19540. this._localDirection.multiplyInPlace(this.panningAxis);
  19541. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19542. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19543. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19544. if (!this.panningAxis.y) {
  19545. this._transformedDirection.y = 0;
  19546. }
  19547. if (!this._targetHost) {
  19548. if (this.panningDistanceLimit) {
  19549. this._transformedDirection.addInPlace(this._target);
  19550. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19551. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19552. this._target.copyFrom(this._transformedDirection);
  19553. }
  19554. }
  19555. else {
  19556. this._target.addInPlace(this._transformedDirection);
  19557. }
  19558. }
  19559. this.inertialPanningX *= this.panningInertia;
  19560. this.inertialPanningY *= this.panningInertia;
  19561. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19562. this.inertialPanningX = 0;
  19563. }
  19564. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19565. this.inertialPanningY = 0;
  19566. }
  19567. }
  19568. // Limits
  19569. this._checkLimits();
  19570. _super.prototype._checkInputs.call(this);
  19571. };
  19572. ArcRotateCamera.prototype._checkLimits = function () {
  19573. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19574. if (this.allowUpsideDown && this.beta > Math.PI) {
  19575. this.beta = this.beta - (2 * Math.PI);
  19576. }
  19577. }
  19578. else {
  19579. if (this.beta < this.lowerBetaLimit) {
  19580. this.beta = this.lowerBetaLimit;
  19581. }
  19582. }
  19583. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19584. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19585. this.beta = this.beta + (2 * Math.PI);
  19586. }
  19587. }
  19588. else {
  19589. if (this.beta > this.upperBetaLimit) {
  19590. this.beta = this.upperBetaLimit;
  19591. }
  19592. }
  19593. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19594. this.alpha = this.lowerAlphaLimit;
  19595. }
  19596. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19597. this.alpha = this.upperAlphaLimit;
  19598. }
  19599. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  19600. this.radius = this.lowerRadiusLimit;
  19601. this.inertialRadiusOffset = 0;
  19602. }
  19603. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  19604. this.radius = this.upperRadiusLimit;
  19605. this.inertialRadiusOffset = 0;
  19606. }
  19607. };
  19608. /**
  19609. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  19610. */
  19611. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  19612. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  19613. this.radius = this._computationVector.length();
  19614. if (this.radius === 0) {
  19615. this.radius = 0.0001; // Just to avoid division by zero
  19616. }
  19617. // Alpha
  19618. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  19619. if (this._computationVector.z < 0) {
  19620. this.alpha = 2 * Math.PI - this.alpha;
  19621. }
  19622. // Beta
  19623. this.beta = Math.acos(this._computationVector.y / this.radius);
  19624. this._checkLimits();
  19625. };
  19626. /**
  19627. * Use a position to define the current camera related information like aplha, beta and radius
  19628. * @param position Defines the position to set the camera at
  19629. */
  19630. ArcRotateCamera.prototype.setPosition = function (position) {
  19631. if (this.position.equals(position)) {
  19632. return;
  19633. }
  19634. this.position.copyFrom(position);
  19635. this.rebuildAnglesAndRadius();
  19636. };
  19637. /**
  19638. * Defines the target the camera should look at.
  19639. * This will automatically adapt alpha beta and radius to fit within the new target.
  19640. * @param target Defines the new target as a Vector or a mesh
  19641. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  19642. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  19643. */
  19644. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  19645. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  19646. if (allowSamePosition === void 0) { allowSamePosition = false; }
  19647. if (target.getBoundingInfo) {
  19648. if (toBoundingCenter) {
  19649. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  19650. }
  19651. else {
  19652. this._targetBoundingCenter = null;
  19653. }
  19654. this._targetHost = target;
  19655. this._target = this._getTargetPosition();
  19656. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  19657. }
  19658. else {
  19659. var newTarget = target;
  19660. var currentTarget = this._getTargetPosition();
  19661. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  19662. return;
  19663. }
  19664. this._targetHost = null;
  19665. this._target = newTarget;
  19666. this._targetBoundingCenter = null;
  19667. this.onMeshTargetChangedObservable.notifyObservers(null);
  19668. }
  19669. this.rebuildAnglesAndRadius();
  19670. };
  19671. /** @hidden */
  19672. ArcRotateCamera.prototype._getViewMatrix = function () {
  19673. // Compute
  19674. var cosa = Math.cos(this.alpha);
  19675. var sina = Math.sin(this.alpha);
  19676. var cosb = Math.cos(this.beta);
  19677. var sinb = Math.sin(this.beta);
  19678. if (sinb === 0) {
  19679. sinb = 0.0001;
  19680. }
  19681. var target = this._getTargetPosition();
  19682. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  19683. // Rotate according to up vector
  19684. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  19685. if (!this._tempAxisVector) {
  19686. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  19687. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19688. }
  19689. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  19690. this._tempAxisVector.normalize();
  19691. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  19692. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  19693. this._tempAxisVector.copyFrom(this._computationVector);
  19694. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  19695. }
  19696. target.addToRef(this._computationVector, this._newPosition);
  19697. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  19698. var coordinator = this.getScene().collisionCoordinator;
  19699. if (!this._collider) {
  19700. this._collider = coordinator.createCollider();
  19701. }
  19702. this._collider._radius = this.collisionRadius;
  19703. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  19704. this._collisionTriggered = true;
  19705. coordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  19706. }
  19707. else {
  19708. this.position.copyFrom(this._newPosition);
  19709. var up = this.upVector;
  19710. if (this.allowUpsideDown && sinb < 0) {
  19711. up = up.clone();
  19712. up = up.negate();
  19713. }
  19714. this._computeViewMatrix(this.position, target, up);
  19715. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19716. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19717. }
  19718. this._currentTarget = target;
  19719. return this._viewMatrix;
  19720. };
  19721. /**
  19722. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19723. * @param meshes Defines the mesh to zoom on
  19724. * @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)
  19725. */
  19726. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19727. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19728. meshes = meshes || this.getScene().meshes;
  19729. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19730. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19731. this.radius = distance * this.zoomOnFactor;
  19732. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19733. };
  19734. /**
  19735. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19736. * The target will be changed but the radius
  19737. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19738. * @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)
  19739. */
  19740. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19741. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19742. var meshesOrMinMaxVector;
  19743. var distance;
  19744. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19745. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19746. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19747. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19748. }
  19749. else { //minMaxVector and distance
  19750. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19751. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19752. distance = minMaxVectorAndDistance.distance;
  19753. }
  19754. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19755. if (!doNotUpdateMaxZ) {
  19756. this.maxZ = distance * 2;
  19757. }
  19758. };
  19759. /**
  19760. * @override
  19761. * Override Camera.createRigCamera
  19762. */
  19763. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19764. var alphaShift = 0;
  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. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19771. break;
  19772. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19773. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19774. break;
  19775. }
  19776. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19777. rigCam._cameraRigParams = {};
  19778. return rigCam;
  19779. };
  19780. /**
  19781. * @hidden
  19782. * @override
  19783. * Override Camera._updateRigCameras
  19784. */
  19785. ArcRotateCamera.prototype._updateRigCameras = function () {
  19786. var camLeft = this._rigCameras[0];
  19787. var camRight = this._rigCameras[1];
  19788. camLeft.beta = camRight.beta = this.beta;
  19789. switch (this.cameraRigMode) {
  19790. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19791. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19792. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19793. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19794. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19795. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19796. break;
  19797. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19798. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19799. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19800. break;
  19801. }
  19802. _super.prototype._updateRigCameras.call(this);
  19803. };
  19804. /**
  19805. * Destroy the camera and release the current resources hold by it.
  19806. */
  19807. ArcRotateCamera.prototype.dispose = function () {
  19808. this.inputs.clear();
  19809. _super.prototype.dispose.call(this);
  19810. };
  19811. /**
  19812. * Gets the current object class name.
  19813. * @return the class name
  19814. */
  19815. ArcRotateCamera.prototype.getClassName = function () {
  19816. return "ArcRotateCamera";
  19817. };
  19818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19820. ], ArcRotateCamera.prototype, "alpha", void 0);
  19821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19823. ], ArcRotateCamera.prototype, "beta", void 0);
  19824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19826. ], ArcRotateCamera.prototype, "radius", void 0);
  19827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19829. ], ArcRotateCamera.prototype, "_target", void 0);
  19830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19832. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19835. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19838. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19841. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19844. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19847. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19850. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19853. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19856. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19859. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19862. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19865. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19868. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19871. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19874. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19877. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19880. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19883. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19886. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19887. return ArcRotateCamera;
  19888. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  19889. /***/ }),
  19890. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19891. /*!*************************************************!*\
  19892. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19893. \*************************************************/
  19894. /*! exports provided: ArcRotateCameraInputsManager */
  19895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19896. "use strict";
  19897. __webpack_require__.r(__webpack_exports__);
  19898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19899. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19900. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19901. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19902. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19903. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19904. /**
  19905. * Default Inputs manager for the ArcRotateCamera.
  19906. * It groups all the default supported inputs for ease of use.
  19907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19908. */
  19909. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19910. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19911. /**
  19912. * Instantiates a new ArcRotateCameraInputsManager.
  19913. * @param camera Defines the camera the inputs belong to
  19914. */
  19915. function ArcRotateCameraInputsManager(camera) {
  19916. return _super.call(this, camera) || this;
  19917. }
  19918. /**
  19919. * Add mouse wheel input support to the input manager.
  19920. * @returns the current input manager
  19921. */
  19922. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19923. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  19924. return this;
  19925. };
  19926. /**
  19927. * Add pointers input support to the input manager.
  19928. * @returns the current input manager
  19929. */
  19930. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19931. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  19932. return this;
  19933. };
  19934. /**
  19935. * Add keyboard input support to the input manager.
  19936. * @returns the current input manager
  19937. */
  19938. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19939. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  19940. return this;
  19941. };
  19942. return ArcRotateCameraInputsManager;
  19943. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  19944. /***/ }),
  19945. /***/ "./Cameras/camera.ts":
  19946. /*!***************************!*\
  19947. !*** ./Cameras/camera.ts ***!
  19948. \***************************/
  19949. /*! exports provided: Camera */
  19950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19951. "use strict";
  19952. __webpack_require__.r(__webpack_exports__);
  19953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19954. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19955. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19956. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19957. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19958. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19959. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19960. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19961. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19962. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  19963. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  19964. /**
  19965. * This is the base class of all the camera used in the application.
  19966. * @see http://doc.babylonjs.com/features/cameras
  19967. */
  19968. var Camera = /** @class */ (function (_super) {
  19969. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19970. /**
  19971. * Instantiates a new camera object.
  19972. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19973. * @see http://doc.babylonjs.com/features/cameras
  19974. * @param name Defines the name of the camera in the scene
  19975. * @param position Defines the position of the camera
  19976. * @param scene Defines the scene the camera belongs too
  19977. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19978. */
  19979. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19980. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19981. var _this = _super.call(this, name, scene) || this;
  19982. /**
  19983. * The vector the camera should consider as up.
  19984. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19985. */
  19986. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19987. /**
  19988. * Define the current limit on the left side for an orthographic camera
  19989. * In scene unit
  19990. */
  19991. _this.orthoLeft = null;
  19992. /**
  19993. * Define the current limit on the right side for an orthographic camera
  19994. * In scene unit
  19995. */
  19996. _this.orthoRight = null;
  19997. /**
  19998. * Define the current limit on the bottom side for an orthographic camera
  19999. * In scene unit
  20000. */
  20001. _this.orthoBottom = null;
  20002. /**
  20003. * Define the current limit on the top side for an orthographic camera
  20004. * In scene unit
  20005. */
  20006. _this.orthoTop = null;
  20007. /**
  20008. * Field Of View is set in Radians. (default is 0.8)
  20009. */
  20010. _this.fov = 0.8;
  20011. /**
  20012. * Define the minimum distance the camera can see from.
  20013. * This is important to note that the depth buffer are not infinite and the closer it starts
  20014. * the more your scene might encounter depth fighting issue.
  20015. */
  20016. _this.minZ = 1;
  20017. /**
  20018. * Define the maximum distance the camera can see to.
  20019. * This is important to note that the depth buffer are not infinite and the further it end
  20020. * the more your scene might encounter depth fighting issue.
  20021. */
  20022. _this.maxZ = 10000.0;
  20023. /**
  20024. * Define the default inertia of the camera.
  20025. * This helps giving a smooth feeling to the camera movement.
  20026. */
  20027. _this.inertia = 0.9;
  20028. /**
  20029. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20030. */
  20031. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20032. /**
  20033. * Define wether the camera is intermediate.
  20034. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20035. */
  20036. _this.isIntermediate = false;
  20037. /**
  20038. * Define the viewport of the camera.
  20039. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20040. */
  20041. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20042. /**
  20043. * Restricts the camera to viewing objects with the same layerMask.
  20044. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20045. */
  20046. _this.layerMask = 0x0FFFFFFF;
  20047. /**
  20048. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20049. */
  20050. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20051. /**
  20052. * Rig mode of the camera.
  20053. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20054. * This is normally controlled byt the camera themselves as internal use.
  20055. */
  20056. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20057. /**
  20058. * 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
  20059. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20060. * else in the scene.
  20061. */
  20062. _this.customRenderTargets = new Array();
  20063. /**
  20064. * When set, the camera will render to this render target instead of the default canvas
  20065. */
  20066. _this.outputRenderTarget = null;
  20067. /**
  20068. * Observable triggered when the camera view matrix has changed.
  20069. */
  20070. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20071. /**
  20072. * Observable triggered when the camera Projection matrix has changed.
  20073. */
  20074. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20075. /**
  20076. * Observable triggered when the inputs have been processed.
  20077. */
  20078. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20079. /**
  20080. * Observable triggered when reset has been called and applied to the camera.
  20081. */
  20082. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20083. /** @hidden */
  20084. _this._rigCameras = new Array();
  20085. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20086. /** @hidden */
  20087. _this._skipRendering = false;
  20088. /** @hidden */
  20089. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20090. /** @hidden */
  20091. _this._postProcesses = new Array();
  20092. /** @hidden */
  20093. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20094. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20095. /** hidden */
  20096. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20097. _this._doNotComputeProjectionMatrix = false;
  20098. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20099. _this._refreshFrustumPlanes = true;
  20100. /** @hidden */
  20101. _this._isCamera = true;
  20102. _this.getScene().addCamera(_this);
  20103. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20104. _this.getScene().activeCamera = _this;
  20105. }
  20106. _this.position = position;
  20107. return _this;
  20108. }
  20109. /**
  20110. * Store current camera state (fov, position, etc..)
  20111. * @returns the camera
  20112. */
  20113. Camera.prototype.storeState = function () {
  20114. this._stateStored = true;
  20115. this._storedFov = this.fov;
  20116. return this;
  20117. };
  20118. /**
  20119. * Restores the camera state values if it has been stored. You must call storeState() first
  20120. */
  20121. Camera.prototype._restoreStateValues = function () {
  20122. if (!this._stateStored) {
  20123. return false;
  20124. }
  20125. this.fov = this._storedFov;
  20126. return true;
  20127. };
  20128. /**
  20129. * Restored camera state. You must call storeState() first.
  20130. * @returns true if restored and false otherwise
  20131. */
  20132. Camera.prototype.restoreState = function () {
  20133. if (this._restoreStateValues()) {
  20134. this.onRestoreStateObservable.notifyObservers(this);
  20135. return true;
  20136. }
  20137. return false;
  20138. };
  20139. /**
  20140. * Gets the class name of the camera.
  20141. * @returns the class name
  20142. */
  20143. Camera.prototype.getClassName = function () {
  20144. return "Camera";
  20145. };
  20146. /**
  20147. * Gets a string representation of the camera useful for debug purpose.
  20148. * @param fullDetails Defines that a more verboe level of logging is required
  20149. * @returns the string representation
  20150. */
  20151. Camera.prototype.toString = function (fullDetails) {
  20152. var ret = "Name: " + this.name;
  20153. ret += ", type: " + this.getClassName();
  20154. if (this.animations) {
  20155. for (var i = 0; i < this.animations.length; i++) {
  20156. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20157. }
  20158. }
  20159. if (fullDetails) {
  20160. }
  20161. return ret;
  20162. };
  20163. Object.defineProperty(Camera.prototype, "globalPosition", {
  20164. /**
  20165. * Gets the current world space position of the camera.
  20166. */
  20167. get: function () {
  20168. return this._globalPosition;
  20169. },
  20170. enumerable: true,
  20171. configurable: true
  20172. });
  20173. /**
  20174. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20175. * @returns the active meshe list
  20176. */
  20177. Camera.prototype.getActiveMeshes = function () {
  20178. return this._activeMeshes;
  20179. };
  20180. /**
  20181. * Check wether a mesh is part of the current active mesh list of the camera
  20182. * @param mesh Defines the mesh to check
  20183. * @returns true if active, false otherwise
  20184. */
  20185. Camera.prototype.isActiveMesh = function (mesh) {
  20186. return (this._activeMeshes.indexOf(mesh) !== -1);
  20187. };
  20188. /**
  20189. * Is this camera ready to be used/rendered
  20190. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20191. * @return true if the camera is ready
  20192. */
  20193. Camera.prototype.isReady = function (completeCheck) {
  20194. if (completeCheck === void 0) { completeCheck = false; }
  20195. if (completeCheck) {
  20196. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20197. var pp = _a[_i];
  20198. if (pp && !pp.isReady()) {
  20199. return false;
  20200. }
  20201. }
  20202. }
  20203. return _super.prototype.isReady.call(this, completeCheck);
  20204. };
  20205. /** @hidden */
  20206. Camera.prototype._initCache = function () {
  20207. _super.prototype._initCache.call(this);
  20208. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20209. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20210. this._cache.mode = undefined;
  20211. this._cache.minZ = undefined;
  20212. this._cache.maxZ = undefined;
  20213. this._cache.fov = undefined;
  20214. this._cache.fovMode = undefined;
  20215. this._cache.aspectRatio = undefined;
  20216. this._cache.orthoLeft = undefined;
  20217. this._cache.orthoRight = undefined;
  20218. this._cache.orthoBottom = undefined;
  20219. this._cache.orthoTop = undefined;
  20220. this._cache.renderWidth = undefined;
  20221. this._cache.renderHeight = undefined;
  20222. };
  20223. /** @hidden */
  20224. Camera.prototype._updateCache = function (ignoreParentClass) {
  20225. if (!ignoreParentClass) {
  20226. _super.prototype._updateCache.call(this);
  20227. }
  20228. this._cache.position.copyFrom(this.position);
  20229. this._cache.upVector.copyFrom(this.upVector);
  20230. };
  20231. /** @hidden */
  20232. Camera.prototype._isSynchronized = function () {
  20233. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20234. };
  20235. /** @hidden */
  20236. Camera.prototype._isSynchronizedViewMatrix = function () {
  20237. if (!_super.prototype._isSynchronized.call(this)) {
  20238. return false;
  20239. }
  20240. return this._cache.position.equals(this.position)
  20241. && this._cache.upVector.equals(this.upVector)
  20242. && this.isSynchronizedWithParent();
  20243. };
  20244. /** @hidden */
  20245. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20246. var check = this._cache.mode === this.mode
  20247. && this._cache.minZ === this.minZ
  20248. && this._cache.maxZ === this.maxZ;
  20249. if (!check) {
  20250. return false;
  20251. }
  20252. var engine = this.getEngine();
  20253. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20254. check = this._cache.fov === this.fov
  20255. && this._cache.fovMode === this.fovMode
  20256. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20257. }
  20258. else {
  20259. check = this._cache.orthoLeft === this.orthoLeft
  20260. && this._cache.orthoRight === this.orthoRight
  20261. && this._cache.orthoBottom === this.orthoBottom
  20262. && this._cache.orthoTop === this.orthoTop
  20263. && this._cache.renderWidth === engine.getRenderWidth()
  20264. && this._cache.renderHeight === engine.getRenderHeight();
  20265. }
  20266. return check;
  20267. };
  20268. /**
  20269. * Attach the input controls to a specific dom element to get the input from.
  20270. * @param element Defines the element the controls should be listened from
  20271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20272. */
  20273. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20274. };
  20275. /**
  20276. * Detach the current controls from the specified dom element.
  20277. * @param element Defines the element to stop listening the inputs from
  20278. */
  20279. Camera.prototype.detachControl = function (element) {
  20280. };
  20281. /**
  20282. * Update the camera state according to the different inputs gathered during the frame.
  20283. */
  20284. Camera.prototype.update = function () {
  20285. this._checkInputs();
  20286. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20287. this._updateRigCameras();
  20288. }
  20289. };
  20290. /** @hidden */
  20291. Camera.prototype._checkInputs = function () {
  20292. this.onAfterCheckInputsObservable.notifyObservers(this);
  20293. };
  20294. Object.defineProperty(Camera.prototype, "rigCameras", {
  20295. /** @hidden */
  20296. get: function () {
  20297. return this._rigCameras;
  20298. },
  20299. enumerable: true,
  20300. configurable: true
  20301. });
  20302. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20303. /**
  20304. * Gets the post process used by the rig cameras
  20305. */
  20306. get: function () {
  20307. return this._rigPostProcess;
  20308. },
  20309. enumerable: true,
  20310. configurable: true
  20311. });
  20312. /**
  20313. * Internal, gets the first post proces.
  20314. * @returns the first post process to be run on this camera.
  20315. */
  20316. Camera.prototype._getFirstPostProcess = function () {
  20317. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20318. if (this._postProcesses[ppIndex] !== null) {
  20319. return this._postProcesses[ppIndex];
  20320. }
  20321. }
  20322. return null;
  20323. };
  20324. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20325. // invalidate framebuffer
  20326. var firstPostProcess = this._getFirstPostProcess();
  20327. if (firstPostProcess) {
  20328. firstPostProcess.markTextureDirty();
  20329. }
  20330. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20331. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20332. var cam = this._rigCameras[i];
  20333. var rigPostProcess = cam._rigPostProcess;
  20334. // for VR rig, there does not have to be a post process
  20335. if (rigPostProcess) {
  20336. var isPass = rigPostProcess.getEffectName() === "pass";
  20337. if (isPass) {
  20338. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20339. cam.isIntermediate = this._postProcesses.length === 0;
  20340. }
  20341. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20342. rigPostProcess.markTextureDirty();
  20343. }
  20344. else {
  20345. cam._postProcesses = this._postProcesses.slice(0);
  20346. }
  20347. }
  20348. };
  20349. /**
  20350. * Attach a post process to the camera.
  20351. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20352. * @param postProcess The post process to attach to the camera
  20353. * @param insertAt The position of the post process in case several of them are in use in the scene
  20354. * @returns the position the post process has been inserted at
  20355. */
  20356. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20357. if (insertAt === void 0) { insertAt = null; }
  20358. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20359. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20360. return 0;
  20361. }
  20362. if (insertAt == null || insertAt < 0) {
  20363. this._postProcesses.push(postProcess);
  20364. }
  20365. else if (this._postProcesses[insertAt] === null) {
  20366. this._postProcesses[insertAt] = postProcess;
  20367. }
  20368. else {
  20369. this._postProcesses.splice(insertAt, 0, postProcess);
  20370. }
  20371. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20372. return this._postProcesses.indexOf(postProcess);
  20373. };
  20374. /**
  20375. * Detach a post process to the camera.
  20376. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20377. * @param postProcess The post process to detach from the camera
  20378. */
  20379. Camera.prototype.detachPostProcess = function (postProcess) {
  20380. var idx = this._postProcesses.indexOf(postProcess);
  20381. if (idx !== -1) {
  20382. this._postProcesses[idx] = null;
  20383. }
  20384. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20385. };
  20386. /**
  20387. * Gets the current world matrix of the camera
  20388. */
  20389. Camera.prototype.getWorldMatrix = function () {
  20390. if (this._isSynchronizedViewMatrix()) {
  20391. return this._worldMatrix;
  20392. }
  20393. // Getting the the view matrix will also compute the world matrix.
  20394. this.getViewMatrix();
  20395. return this._worldMatrix;
  20396. };
  20397. /** @hidden */
  20398. Camera.prototype._getViewMatrix = function () {
  20399. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20400. };
  20401. /**
  20402. * Gets the current view matrix of the camera.
  20403. * @param force forces the camera to recompute the matrix without looking at the cached state
  20404. * @returns the view matrix
  20405. */
  20406. Camera.prototype.getViewMatrix = function (force) {
  20407. if (!force && this._isSynchronizedViewMatrix()) {
  20408. return this._computedViewMatrix;
  20409. }
  20410. this.updateCache();
  20411. this._computedViewMatrix = this._getViewMatrix();
  20412. this._currentRenderId = this.getScene().getRenderId();
  20413. this._childRenderId = this._currentRenderId;
  20414. this._refreshFrustumPlanes = true;
  20415. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20416. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20417. }
  20418. this.onViewMatrixChangedObservable.notifyObservers(this);
  20419. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20420. return this._computedViewMatrix;
  20421. };
  20422. /**
  20423. * Freeze the projection matrix.
  20424. * It will prevent the cache check of the camera projection compute and can speed up perf
  20425. * if no parameter of the camera are meant to change
  20426. * @param projection Defines manually a projection if necessary
  20427. */
  20428. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20429. this._doNotComputeProjectionMatrix = true;
  20430. if (projection !== undefined) {
  20431. this._projectionMatrix = projection;
  20432. }
  20433. };
  20434. /**
  20435. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20436. */
  20437. Camera.prototype.unfreezeProjectionMatrix = function () {
  20438. this._doNotComputeProjectionMatrix = false;
  20439. };
  20440. /**
  20441. * Gets the current projection matrix of the camera.
  20442. * @param force forces the camera to recompute the matrix without looking at the cached state
  20443. * @returns the projection matrix
  20444. */
  20445. Camera.prototype.getProjectionMatrix = function (force) {
  20446. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20447. return this._projectionMatrix;
  20448. }
  20449. // Cache
  20450. this._cache.mode = this.mode;
  20451. this._cache.minZ = this.minZ;
  20452. this._cache.maxZ = this.maxZ;
  20453. // Matrix
  20454. this._refreshFrustumPlanes = true;
  20455. var engine = this.getEngine();
  20456. var scene = this.getScene();
  20457. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20458. this._cache.fov = this.fov;
  20459. this._cache.fovMode = this.fovMode;
  20460. this._cache.aspectRatio = engine.getAspectRatio(this);
  20461. if (this.minZ <= 0) {
  20462. this.minZ = 0.1;
  20463. }
  20464. if (scene.useRightHandedSystem) {
  20465. _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);
  20466. }
  20467. else {
  20468. _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);
  20469. }
  20470. }
  20471. else {
  20472. var halfWidth = engine.getRenderWidth() / 2.0;
  20473. var halfHeight = engine.getRenderHeight() / 2.0;
  20474. if (scene.useRightHandedSystem) {
  20475. _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);
  20476. }
  20477. else {
  20478. _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);
  20479. }
  20480. this._cache.orthoLeft = this.orthoLeft;
  20481. this._cache.orthoRight = this.orthoRight;
  20482. this._cache.orthoBottom = this.orthoBottom;
  20483. this._cache.orthoTop = this.orthoTop;
  20484. this._cache.renderWidth = engine.getRenderWidth();
  20485. this._cache.renderHeight = engine.getRenderHeight();
  20486. }
  20487. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20488. return this._projectionMatrix;
  20489. };
  20490. /**
  20491. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20492. * @returns a Matrix
  20493. */
  20494. Camera.prototype.getTransformationMatrix = function () {
  20495. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20496. return this._transformMatrix;
  20497. };
  20498. Camera.prototype._updateFrustumPlanes = function () {
  20499. if (!this._refreshFrustumPlanes) {
  20500. return;
  20501. }
  20502. this.getTransformationMatrix();
  20503. if (!this._frustumPlanes) {
  20504. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20505. }
  20506. else {
  20507. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20508. }
  20509. this._refreshFrustumPlanes = false;
  20510. };
  20511. /**
  20512. * Checks if a cullable object (mesh...) is in the camera frustum
  20513. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20514. * @param target The object to check
  20515. * @returns true if the object is in frustum otherwise false
  20516. */
  20517. Camera.prototype.isInFrustum = function (target) {
  20518. this._updateFrustumPlanes();
  20519. return target.isInFrustum(this._frustumPlanes);
  20520. };
  20521. /**
  20522. * Checks if a cullable object (mesh...) is in the camera frustum
  20523. * Unlike isInFrustum this cheks the full bounding box
  20524. * @param target The object to check
  20525. * @returns true if the object is in frustum otherwise false
  20526. */
  20527. Camera.prototype.isCompletelyInFrustum = function (target) {
  20528. this._updateFrustumPlanes();
  20529. return target.isCompletelyInFrustum(this._frustumPlanes);
  20530. };
  20531. /**
  20532. * Gets a ray in the forward direction from the camera.
  20533. * @param length Defines the length of the ray to create
  20534. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20535. * @param origin Defines the start point of the ray which defaults to the camera position
  20536. * @returns the forward ray
  20537. */
  20538. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20539. if (length === void 0) { length = 100; }
  20540. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  20541. };
  20542. /**
  20543. * Releases resources associated with this node.
  20544. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20545. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20546. */
  20547. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20548. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20549. // Observables
  20550. this.onViewMatrixChangedObservable.clear();
  20551. this.onProjectionMatrixChangedObservable.clear();
  20552. this.onAfterCheckInputsObservable.clear();
  20553. this.onRestoreStateObservable.clear();
  20554. // Inputs
  20555. if (this.inputs) {
  20556. this.inputs.clear();
  20557. }
  20558. // Animations
  20559. this.getScene().stopAnimation(this);
  20560. // Remove from scene
  20561. this.getScene().removeCamera(this);
  20562. while (this._rigCameras.length > 0) {
  20563. var camera = this._rigCameras.pop();
  20564. if (camera) {
  20565. camera.dispose();
  20566. }
  20567. }
  20568. // Postprocesses
  20569. if (this._rigPostProcess) {
  20570. this._rigPostProcess.dispose(this);
  20571. this._rigPostProcess = null;
  20572. this._postProcesses = [];
  20573. }
  20574. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20575. this._rigPostProcess = null;
  20576. this._postProcesses = [];
  20577. }
  20578. else {
  20579. var i = this._postProcesses.length;
  20580. while (--i >= 0) {
  20581. var postProcess = this._postProcesses[i];
  20582. if (postProcess) {
  20583. postProcess.dispose(this);
  20584. }
  20585. }
  20586. }
  20587. // Render targets
  20588. var i = this.customRenderTargets.length;
  20589. while (--i >= 0) {
  20590. this.customRenderTargets[i].dispose();
  20591. }
  20592. this.customRenderTargets = [];
  20593. // Active Meshes
  20594. this._activeMeshes.dispose();
  20595. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  20596. };
  20597. Object.defineProperty(Camera.prototype, "leftCamera", {
  20598. /**
  20599. * Gets the left camera of a rig setup in case of Rigged Camera
  20600. */
  20601. get: function () {
  20602. if (this._rigCameras.length < 1) {
  20603. return null;
  20604. }
  20605. return this._rigCameras[0];
  20606. },
  20607. enumerable: true,
  20608. configurable: true
  20609. });
  20610. Object.defineProperty(Camera.prototype, "rightCamera", {
  20611. /**
  20612. * Gets the right camera of a rig setup in case of Rigged Camera
  20613. */
  20614. get: function () {
  20615. if (this._rigCameras.length < 2) {
  20616. return null;
  20617. }
  20618. return this._rigCameras[1];
  20619. },
  20620. enumerable: true,
  20621. configurable: true
  20622. });
  20623. /**
  20624. * Gets the left camera target of a rig setup in case of Rigged Camera
  20625. * @returns the target position
  20626. */
  20627. Camera.prototype.getLeftTarget = function () {
  20628. if (this._rigCameras.length < 1) {
  20629. return null;
  20630. }
  20631. return this._rigCameras[0].getTarget();
  20632. };
  20633. /**
  20634. * Gets the right camera target of a rig setup in case of Rigged Camera
  20635. * @returns the target position
  20636. */
  20637. Camera.prototype.getRightTarget = function () {
  20638. if (this._rigCameras.length < 2) {
  20639. return null;
  20640. }
  20641. return this._rigCameras[1].getTarget();
  20642. };
  20643. /**
  20644. * @hidden
  20645. */
  20646. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  20647. if (this.cameraRigMode === mode) {
  20648. return;
  20649. }
  20650. while (this._rigCameras.length > 0) {
  20651. var camera = this._rigCameras.pop();
  20652. if (camera) {
  20653. camera.dispose();
  20654. }
  20655. }
  20656. this.cameraRigMode = mode;
  20657. this._cameraRigParams = {};
  20658. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  20659. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  20660. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  20661. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  20662. // create the rig cameras, unless none
  20663. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20664. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  20665. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  20666. if (leftCamera && rightCamera) {
  20667. this._rigCameras.push(leftCamera);
  20668. this._rigCameras.push(rightCamera);
  20669. }
  20670. }
  20671. switch (this.cameraRigMode) {
  20672. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20673. Camera._setStereoscopicAnaglyphRigMode(this);
  20674. break;
  20675. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20676. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20677. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20678. Camera._setStereoscopicRigMode(this);
  20679. break;
  20680. case Camera.RIG_MODE_VR:
  20681. Camera._setVRRigMode(this, rigParams);
  20682. break;
  20683. case Camera.RIG_MODE_WEBVR:
  20684. Camera._setWebVRRigMode(this, rigParams);
  20685. break;
  20686. }
  20687. this._cascadePostProcessesToRigCams();
  20688. this.update();
  20689. };
  20690. /** @hidden */
  20691. Camera._setStereoscopicRigMode = function (camera) {
  20692. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  20693. };
  20694. /** @hidden */
  20695. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  20696. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  20697. };
  20698. /** @hidden */
  20699. Camera._setVRRigMode = function (camera, rigParams) {
  20700. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  20701. };
  20702. /** @hidden */
  20703. Camera._setWebVRRigMode = function (camera, rigParams) {
  20704. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  20705. };
  20706. /** @hidden */
  20707. Camera.prototype._getVRProjectionMatrix = function () {
  20708. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20709. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20710. return this._projectionMatrix;
  20711. };
  20712. Camera.prototype._updateCameraRotationMatrix = function () {
  20713. //Here for WebVR
  20714. };
  20715. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20716. //Here for WebVR
  20717. };
  20718. /**
  20719. * This function MUST be overwritten by the different WebVR cameras available.
  20720. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20721. * @hidden
  20722. */
  20723. Camera.prototype._getWebVRProjectionMatrix = function () {
  20724. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20725. };
  20726. /**
  20727. * This function MUST be overwritten by the different WebVR cameras available.
  20728. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20729. * @hidden
  20730. */
  20731. Camera.prototype._getWebVRViewMatrix = function () {
  20732. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20733. };
  20734. /** @hidden */
  20735. Camera.prototype.setCameraRigParameter = function (name, value) {
  20736. if (!this._cameraRigParams) {
  20737. this._cameraRigParams = {};
  20738. }
  20739. this._cameraRigParams[name] = value;
  20740. //provisionnally:
  20741. if (name === "interaxialDistance") {
  20742. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20743. }
  20744. };
  20745. /**
  20746. * needs to be overridden by children so sub has required properties to be copied
  20747. * @hidden
  20748. */
  20749. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20750. return null;
  20751. };
  20752. /**
  20753. * May need to be overridden by children
  20754. * @hidden
  20755. */
  20756. Camera.prototype._updateRigCameras = function () {
  20757. for (var i = 0; i < this._rigCameras.length; i++) {
  20758. this._rigCameras[i].minZ = this.minZ;
  20759. this._rigCameras[i].maxZ = this.maxZ;
  20760. this._rigCameras[i].fov = this.fov;
  20761. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20762. }
  20763. // only update viewport when ANAGLYPH
  20764. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20765. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20766. }
  20767. };
  20768. /** @hidden */
  20769. Camera.prototype._setupInputs = function () {
  20770. };
  20771. /**
  20772. * Serialiaze the camera setup to a json represention
  20773. * @returns the JSON representation
  20774. */
  20775. Camera.prototype.serialize = function () {
  20776. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20777. // Type
  20778. serializationObject.type = this.getClassName();
  20779. // Parent
  20780. if (this.parent) {
  20781. serializationObject.parentId = this.parent.id;
  20782. }
  20783. if (this.inputs) {
  20784. this.inputs.serialize(serializationObject);
  20785. }
  20786. // Animations
  20787. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20788. serializationObject.ranges = this.serializeAnimationRanges();
  20789. return serializationObject;
  20790. };
  20791. /**
  20792. * Clones the current camera.
  20793. * @param name The cloned camera name
  20794. * @returns the cloned camera
  20795. */
  20796. Camera.prototype.clone = function (name) {
  20797. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20798. };
  20799. /**
  20800. * Gets the direction of the camera relative to a given local axis.
  20801. * @param localAxis Defines the reference axis to provide a relative direction.
  20802. * @return the direction
  20803. */
  20804. Camera.prototype.getDirection = function (localAxis) {
  20805. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20806. this.getDirectionToRef(localAxis, result);
  20807. return result;
  20808. };
  20809. /**
  20810. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20811. * @param localAxis Defines the reference axis to provide a relative direction.
  20812. * @param result Defines the vector to store the result in
  20813. */
  20814. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20815. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20816. };
  20817. /**
  20818. * Gets a camera constructor for a given camera type
  20819. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20820. * @param name The name of the camera the result will be able to instantiate
  20821. * @param scene The scene the result will construct the camera in
  20822. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20823. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20824. * @returns a factory method to construc the camera
  20825. */
  20826. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20827. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20828. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20829. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20830. interaxial_distance: interaxial_distance,
  20831. isStereoscopicSideBySide: isStereoscopicSideBySide
  20832. });
  20833. if (constructorFunc) {
  20834. return constructorFunc;
  20835. }
  20836. // Default to universal camera
  20837. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20838. };
  20839. /**
  20840. * Compute the world matrix of the camera.
  20841. * @returns the camera workd matrix
  20842. */
  20843. Camera.prototype.computeWorldMatrix = function () {
  20844. return this.getWorldMatrix();
  20845. };
  20846. /**
  20847. * Parse a JSON and creates the camera from the parsed information
  20848. * @param parsedCamera The JSON to parse
  20849. * @param scene The scene to instantiate the camera in
  20850. * @returns the newly constructed camera
  20851. */
  20852. Camera.Parse = function (parsedCamera, scene) {
  20853. var type = parsedCamera.type;
  20854. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20855. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20856. // Parent
  20857. if (parsedCamera.parentId) {
  20858. camera._waitingParentId = parsedCamera.parentId;
  20859. }
  20860. //If camera has an input manager, let it parse inputs settings
  20861. if (camera.inputs) {
  20862. camera.inputs.parse(parsedCamera);
  20863. camera._setupInputs();
  20864. }
  20865. if (camera.setPosition) { // need to force position
  20866. camera.position.copyFromFloats(0, 0, 0);
  20867. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20868. }
  20869. // Target
  20870. if (parsedCamera.target) {
  20871. if (camera.setTarget) {
  20872. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20873. }
  20874. }
  20875. // Apply 3d rig, when found
  20876. if (parsedCamera.cameraRigMode) {
  20877. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20878. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20879. }
  20880. // Animations
  20881. if (parsedCamera.animations) {
  20882. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20883. var parsedAnimation = parsedCamera.animations[animationIndex];
  20884. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  20885. if (internalClass) {
  20886. camera.animations.push(internalClass.Parse(parsedAnimation));
  20887. }
  20888. }
  20889. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20890. }
  20891. if (parsedCamera.autoAnimate) {
  20892. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20893. }
  20894. return camera;
  20895. };
  20896. /** @hidden */
  20897. Camera._createDefaultParsedCamera = function (name, scene) {
  20898. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  20899. };
  20900. /**
  20901. * This is the default projection mode used by the cameras.
  20902. * It helps recreating a feeling of perspective and better appreciate depth.
  20903. * This is the best way to simulate real life cameras.
  20904. */
  20905. Camera.PERSPECTIVE_CAMERA = 0;
  20906. /**
  20907. * This helps creating camera with an orthographic mode.
  20908. * 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.
  20909. */
  20910. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20911. /**
  20912. * This is the default FOV mode for perspective cameras.
  20913. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20914. */
  20915. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20916. /**
  20917. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20918. */
  20919. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20920. /**
  20921. * This specifies ther is no need for a camera rig.
  20922. * Basically only one eye is rendered corresponding to the camera.
  20923. */
  20924. Camera.RIG_MODE_NONE = 0;
  20925. /**
  20926. * Simulates a camera Rig with one blue eye and one red eye.
  20927. * This can be use with 3d blue and red glasses.
  20928. */
  20929. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20930. /**
  20931. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20932. */
  20933. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20934. /**
  20935. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20936. */
  20937. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20938. /**
  20939. * Defines that both eyes of the camera will be rendered over under each other.
  20940. */
  20941. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20942. /**
  20943. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20944. */
  20945. Camera.RIG_MODE_VR = 20;
  20946. /**
  20947. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20948. */
  20949. Camera.RIG_MODE_WEBVR = 21;
  20950. /**
  20951. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20952. */
  20953. Camera.RIG_MODE_CUSTOM = 22;
  20954. /**
  20955. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20956. */
  20957. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20958. /**
  20959. * @hidden
  20960. * Might be removed once multiview will be a thing
  20961. */
  20962. Camera.UseAlternateWebVRRendering = false;
  20963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20965. ], Camera.prototype, "position", void 0);
  20966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20968. ], Camera.prototype, "upVector", void 0);
  20969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20971. ], Camera.prototype, "orthoLeft", void 0);
  20972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20974. ], Camera.prototype, "orthoRight", void 0);
  20975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20977. ], Camera.prototype, "orthoBottom", void 0);
  20978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20980. ], Camera.prototype, "orthoTop", void 0);
  20981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20983. ], Camera.prototype, "fov", void 0);
  20984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20986. ], Camera.prototype, "minZ", void 0);
  20987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20989. ], Camera.prototype, "maxZ", void 0);
  20990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20992. ], Camera.prototype, "inertia", void 0);
  20993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20995. ], Camera.prototype, "mode", void 0);
  20996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20998. ], Camera.prototype, "layerMask", void 0);
  20999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21001. ], Camera.prototype, "fovMode", void 0);
  21002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21004. ], Camera.prototype, "cameraRigMode", void 0);
  21005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21007. ], Camera.prototype, "interaxialDistance", void 0);
  21008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21010. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21011. return Camera;
  21012. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21013. /***/ }),
  21014. /***/ "./Cameras/cameraInputsManager.ts":
  21015. /*!****************************************!*\
  21016. !*** ./Cameras/cameraInputsManager.ts ***!
  21017. \****************************************/
  21018. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21020. "use strict";
  21021. __webpack_require__.r(__webpack_exports__);
  21022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21024. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21025. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21026. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21027. /**
  21028. * @ignore
  21029. * This is a list of all the different input types that are available in the application.
  21030. * Fo instance: ArcRotateCameraGamepadInput...
  21031. */
  21032. var CameraInputTypes = {};
  21033. /**
  21034. * This represents the input manager used within a camera.
  21035. * It helps dealing with all the different kind of input attached to a camera.
  21036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21037. */
  21038. var CameraInputsManager = /** @class */ (function () {
  21039. /**
  21040. * Instantiate a new Camera Input Manager.
  21041. * @param camera Defines the camera the input manager blongs to
  21042. */
  21043. function CameraInputsManager(camera) {
  21044. this.attached = {};
  21045. this.camera = camera;
  21046. this.checkInputs = function () { };
  21047. }
  21048. /**
  21049. * Add an input method to a camera
  21050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21051. * @param input camera input method
  21052. */
  21053. CameraInputsManager.prototype.add = function (input) {
  21054. var type = input.getSimpleName();
  21055. if (this.attached[type]) {
  21056. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21057. return;
  21058. }
  21059. this.attached[type] = input;
  21060. input.camera = this.camera;
  21061. //for checkInputs, we are dynamically creating a function
  21062. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21063. if (input.checkInputs) {
  21064. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21065. }
  21066. if (this.attachedElement) {
  21067. input.attachControl(this.attachedElement);
  21068. }
  21069. };
  21070. /**
  21071. * Remove a specific input method from a camera
  21072. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21073. * @param inputToRemove camera input method
  21074. */
  21075. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21076. for (var cam in this.attached) {
  21077. var input = this.attached[cam];
  21078. if (input === inputToRemove) {
  21079. input.detachControl(this.attachedElement);
  21080. input.camera = null;
  21081. delete this.attached[cam];
  21082. this.rebuildInputCheck();
  21083. }
  21084. }
  21085. };
  21086. /**
  21087. * Remove a specific input type from a camera
  21088. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21089. * @param inputType the type of the input to remove
  21090. */
  21091. CameraInputsManager.prototype.removeByType = function (inputType) {
  21092. for (var cam in this.attached) {
  21093. var input = this.attached[cam];
  21094. if (input.getClassName() === inputType) {
  21095. input.detachControl(this.attachedElement);
  21096. input.camera = null;
  21097. delete this.attached[cam];
  21098. this.rebuildInputCheck();
  21099. }
  21100. }
  21101. };
  21102. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21103. var current = this.checkInputs;
  21104. return function () {
  21105. current();
  21106. fn();
  21107. };
  21108. };
  21109. /**
  21110. * Attach the input controls to the currently attached dom element to listen the events from.
  21111. * @param input Defines the input to attach
  21112. */
  21113. CameraInputsManager.prototype.attachInput = function (input) {
  21114. if (this.attachedElement) {
  21115. input.attachControl(this.attachedElement, this.noPreventDefault);
  21116. }
  21117. };
  21118. /**
  21119. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21120. * @param element Defines the dom element to collect the events from
  21121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21122. */
  21123. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21124. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21125. if (this.attachedElement) {
  21126. return;
  21127. }
  21128. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21129. this.attachedElement = element;
  21130. this.noPreventDefault = noPreventDefault;
  21131. for (var cam in this.attached) {
  21132. this.attached[cam].attachControl(element, noPreventDefault);
  21133. }
  21134. };
  21135. /**
  21136. * Detach the current manager inputs controls from a specific dom element.
  21137. * @param element Defines the dom element to collect the events from
  21138. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21139. */
  21140. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21141. if (disconnect === void 0) { disconnect = false; }
  21142. if (this.attachedElement !== element) {
  21143. return;
  21144. }
  21145. for (var cam in this.attached) {
  21146. this.attached[cam].detachControl(element);
  21147. if (disconnect) {
  21148. this.attached[cam].camera = null;
  21149. }
  21150. }
  21151. this.attachedElement = null;
  21152. };
  21153. /**
  21154. * Rebuild the dynamic inputCheck function from the current list of
  21155. * defined inputs in the manager.
  21156. */
  21157. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21158. this.checkInputs = function () { };
  21159. for (var cam in this.attached) {
  21160. var input = this.attached[cam];
  21161. if (input.checkInputs) {
  21162. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21163. }
  21164. }
  21165. };
  21166. /**
  21167. * Remove all attached input methods from a camera
  21168. */
  21169. CameraInputsManager.prototype.clear = function () {
  21170. if (this.attachedElement) {
  21171. this.detachElement(this.attachedElement, true);
  21172. }
  21173. this.attached = {};
  21174. this.attachedElement = null;
  21175. this.checkInputs = function () { };
  21176. };
  21177. /**
  21178. * Serialize the current input manager attached to a camera.
  21179. * This ensures than once parsed,
  21180. * the input associated to the camera will be identical to the current ones
  21181. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21182. */
  21183. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21184. var inputs = {};
  21185. for (var cam in this.attached) {
  21186. var input = this.attached[cam];
  21187. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21188. inputs[input.getClassName()] = res;
  21189. }
  21190. serializedCamera.inputsmgr = inputs;
  21191. };
  21192. /**
  21193. * Parses an input manager serialized JSON to restore the previous list of inputs
  21194. * and states associated to a camera.
  21195. * @param parsedCamera Defines the JSON to parse
  21196. */
  21197. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21198. var parsedInputs = parsedCamera.inputsmgr;
  21199. if (parsedInputs) {
  21200. this.clear();
  21201. for (var n in parsedInputs) {
  21202. var construct = CameraInputTypes[n];
  21203. if (construct) {
  21204. var parsedinput = parsedInputs[n];
  21205. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21206. this.add(input);
  21207. }
  21208. }
  21209. }
  21210. else {
  21211. //2016-03-08 this part is for managing backward compatibility
  21212. for (var n in this.attached) {
  21213. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21214. if (construct) {
  21215. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21216. this.remove(this.attached[n]);
  21217. this.add(input);
  21218. }
  21219. }
  21220. }
  21221. };
  21222. return CameraInputsManager;
  21223. }());
  21224. /***/ }),
  21225. /***/ "./Cameras/deviceOrientationCamera.ts":
  21226. /*!********************************************!*\
  21227. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21228. \********************************************/
  21229. /*! exports provided: DeviceOrientationCamera */
  21230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21231. "use strict";
  21232. __webpack_require__.r(__webpack_exports__);
  21233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21234. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21235. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21236. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21237. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21238. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21239. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21240. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21241. });
  21242. // We're mainly based on the logic defined into the FreeCamera code
  21243. /**
  21244. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21245. * being tilted forward or back and left or right.
  21246. */
  21247. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21248. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21249. /**
  21250. * Creates a new device orientation camera
  21251. * @param name The name of the camera
  21252. * @param position The start position camera
  21253. * @param scene The scene the camera belongs to
  21254. */
  21255. function DeviceOrientationCamera(name, position, scene) {
  21256. var _this = _super.call(this, name, position, scene) || this;
  21257. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21258. _this.inputs.addDeviceOrientation();
  21259. return _this;
  21260. }
  21261. /**
  21262. * Gets the current instance class name ("DeviceOrientationCamera").
  21263. * This helps avoiding instanceof at run time.
  21264. * @returns the class name
  21265. */
  21266. DeviceOrientationCamera.prototype.getClassName = function () {
  21267. return "DeviceOrientationCamera";
  21268. };
  21269. /**
  21270. * @hidden
  21271. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21272. */
  21273. DeviceOrientationCamera.prototype._checkInputs = function () {
  21274. _super.prototype._checkInputs.call(this);
  21275. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21276. if (this._initialQuaternion) {
  21277. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21278. }
  21279. };
  21280. /**
  21281. * Reset the camera to its default orientation on the specified axis only.
  21282. * @param axis The axis to reset
  21283. */
  21284. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21285. var _this = this;
  21286. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21287. //can only work if this camera has a rotation quaternion already.
  21288. if (!this.rotationQuaternion) {
  21289. return;
  21290. }
  21291. if (!this._initialQuaternion) {
  21292. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21293. }
  21294. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21295. ['x', 'y', 'z'].forEach(function (axisName) {
  21296. if (!axis[axisName]) {
  21297. _this._initialQuaternion[axisName] = 0;
  21298. }
  21299. else {
  21300. _this._initialQuaternion[axisName] *= -1;
  21301. }
  21302. });
  21303. this._initialQuaternion.normalize();
  21304. //force rotation update
  21305. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21306. };
  21307. return DeviceOrientationCamera;
  21308. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21309. /***/ }),
  21310. /***/ "./Cameras/flyCamera.ts":
  21311. /*!******************************!*\
  21312. !*** ./Cameras/flyCamera.ts ***!
  21313. \******************************/
  21314. /*! exports provided: FlyCamera */
  21315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21316. "use strict";
  21317. __webpack_require__.r(__webpack_exports__);
  21318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21319. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21320. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21321. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21322. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21323. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21324. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21325. /**
  21326. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21327. * such as in a 3D Space Shooter or a Flight Simulator.
  21328. */
  21329. var FlyCamera = /** @class */ (function (_super) {
  21330. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21331. /**
  21332. * Instantiates a FlyCamera.
  21333. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21334. * such as in a 3D Space Shooter or a Flight Simulator.
  21335. * @param name Define the name of the camera in the scene.
  21336. * @param position Define the starting position of the camera in the scene.
  21337. * @param scene Define the scene the camera belongs to.
  21338. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21339. */
  21340. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21341. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21342. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21343. /**
  21344. * Define the collision ellipsoid of the camera.
  21345. * This is helpful for simulating a camera body, like a player's body.
  21346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21347. */
  21348. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21349. /**
  21350. * Define an offset for the position of the ellipsoid around the camera.
  21351. * This can be helpful if the camera is attached away from the player's body center,
  21352. * such as at its head.
  21353. */
  21354. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21355. /**
  21356. * Enable or disable collisions of the camera with the rest of the scene objects.
  21357. */
  21358. _this.checkCollisions = false;
  21359. /**
  21360. * Enable or disable gravity on the camera.
  21361. */
  21362. _this.applyGravity = false;
  21363. /**
  21364. * Define the current direction the camera is moving to.
  21365. */
  21366. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21367. /**
  21368. * Track Roll to maintain the wanted Rolling when looking around.
  21369. */
  21370. _this._trackRoll = 0;
  21371. /**
  21372. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21373. */
  21374. _this.rollCorrect = 100;
  21375. /**
  21376. * Mimic a banked turn, Rolling the camera when Yawing.
  21377. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21378. */
  21379. _this.bankedTurn = false;
  21380. /**
  21381. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21382. */
  21383. _this.bankedTurnLimit = Math.PI / 2;
  21384. /**
  21385. * Value of 0 disables the banked Roll.
  21386. * Value of 1 is equal to the Yaw angle in radians.
  21387. */
  21388. _this.bankedTurnMultiplier = 1;
  21389. _this._needMoveForGravity = false;
  21390. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21391. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21392. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21393. // Collisions.
  21394. _this._collisionMask = -1;
  21395. /** @hidden */
  21396. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21397. if (collidedMesh === void 0) { collidedMesh = null; }
  21398. var updatePosition = function (newPos) {
  21399. _this._newPosition.copyFrom(newPos);
  21400. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21401. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21402. _this.position.addInPlace(_this._diffPosition);
  21403. if (_this.onCollide && collidedMesh) {
  21404. _this.onCollide(collidedMesh);
  21405. }
  21406. }
  21407. };
  21408. updatePosition(newPosition);
  21409. };
  21410. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21411. _this.inputs.addKeyboard().addMouse();
  21412. return _this;
  21413. }
  21414. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21415. /**
  21416. * Gets the input sensibility for mouse input.
  21417. * Higher values reduce sensitivity.
  21418. */
  21419. get: function () {
  21420. var mouse = this.inputs.attached["mouse"];
  21421. if (mouse) {
  21422. return mouse.angularSensibility;
  21423. }
  21424. return 0;
  21425. },
  21426. /**
  21427. * Sets the input sensibility for a mouse input.
  21428. * Higher values reduce sensitivity.
  21429. */
  21430. set: function (value) {
  21431. var mouse = this.inputs.attached["mouse"];
  21432. if (mouse) {
  21433. mouse.angularSensibility = value;
  21434. }
  21435. },
  21436. enumerable: true,
  21437. configurable: true
  21438. });
  21439. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21440. /**
  21441. * Get the keys for camera movement forward.
  21442. */
  21443. get: function () {
  21444. var keyboard = this.inputs.attached["keyboard"];
  21445. if (keyboard) {
  21446. return keyboard.keysForward;
  21447. }
  21448. return [];
  21449. },
  21450. /**
  21451. * Set the keys for camera movement forward.
  21452. */
  21453. set: function (value) {
  21454. var keyboard = this.inputs.attached["keyboard"];
  21455. if (keyboard) {
  21456. keyboard.keysForward = value;
  21457. }
  21458. },
  21459. enumerable: true,
  21460. configurable: true
  21461. });
  21462. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21463. /**
  21464. * Get the keys for camera movement backward.
  21465. */
  21466. get: function () {
  21467. var keyboard = this.inputs.attached["keyboard"];
  21468. if (keyboard) {
  21469. return keyboard.keysBackward;
  21470. }
  21471. return [];
  21472. },
  21473. set: function (value) {
  21474. var keyboard = this.inputs.attached["keyboard"];
  21475. if (keyboard) {
  21476. keyboard.keysBackward = value;
  21477. }
  21478. },
  21479. enumerable: true,
  21480. configurable: true
  21481. });
  21482. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21483. /**
  21484. * Get the keys for camera movement up.
  21485. */
  21486. get: function () {
  21487. var keyboard = this.inputs.attached["keyboard"];
  21488. if (keyboard) {
  21489. return keyboard.keysUp;
  21490. }
  21491. return [];
  21492. },
  21493. /**
  21494. * Set the keys for camera movement up.
  21495. */
  21496. set: function (value) {
  21497. var keyboard = this.inputs.attached["keyboard"];
  21498. if (keyboard) {
  21499. keyboard.keysUp = value;
  21500. }
  21501. },
  21502. enumerable: true,
  21503. configurable: true
  21504. });
  21505. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21506. /**
  21507. * Get the keys for camera movement down.
  21508. */
  21509. get: function () {
  21510. var keyboard = this.inputs.attached["keyboard"];
  21511. if (keyboard) {
  21512. return keyboard.keysDown;
  21513. }
  21514. return [];
  21515. },
  21516. /**
  21517. * Set the keys for camera movement down.
  21518. */
  21519. set: function (value) {
  21520. var keyboard = this.inputs.attached["keyboard"];
  21521. if (keyboard) {
  21522. keyboard.keysDown = value;
  21523. }
  21524. },
  21525. enumerable: true,
  21526. configurable: true
  21527. });
  21528. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21529. /**
  21530. * Get the keys for camera movement left.
  21531. */
  21532. get: function () {
  21533. var keyboard = this.inputs.attached["keyboard"];
  21534. if (keyboard) {
  21535. return keyboard.keysLeft;
  21536. }
  21537. return [];
  21538. },
  21539. /**
  21540. * Set the keys for camera movement left.
  21541. */
  21542. set: function (value) {
  21543. var keyboard = this.inputs.attached["keyboard"];
  21544. if (keyboard) {
  21545. keyboard.keysLeft = value;
  21546. }
  21547. },
  21548. enumerable: true,
  21549. configurable: true
  21550. });
  21551. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  21552. /**
  21553. * Set the keys for camera movement right.
  21554. */
  21555. get: function () {
  21556. var keyboard = this.inputs.attached["keyboard"];
  21557. if (keyboard) {
  21558. return keyboard.keysRight;
  21559. }
  21560. return [];
  21561. },
  21562. /**
  21563. * Set the keys for camera movement right.
  21564. */
  21565. set: function (value) {
  21566. var keyboard = this.inputs.attached["keyboard"];
  21567. if (keyboard) {
  21568. keyboard.keysRight = value;
  21569. }
  21570. },
  21571. enumerable: true,
  21572. configurable: true
  21573. });
  21574. /**
  21575. * Attach a control to the HTML DOM element.
  21576. * @param element Defines the element that listens to the input events.
  21577. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  21578. */
  21579. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  21580. this.inputs.attachElement(element, noPreventDefault);
  21581. };
  21582. /**
  21583. * Detach a control from the HTML DOM element.
  21584. * The camera will stop reacting to that input.
  21585. * @param element Defines the element that listens to the input events.
  21586. */
  21587. FlyCamera.prototype.detachControl = function (element) {
  21588. this.inputs.detachElement(element);
  21589. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21590. };
  21591. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  21592. /**
  21593. * Get the mask that the camera ignores in collision events.
  21594. */
  21595. get: function () {
  21596. return this._collisionMask;
  21597. },
  21598. /**
  21599. * Set the mask that the camera ignores in collision events.
  21600. */
  21601. set: function (mask) {
  21602. this._collisionMask = !isNaN(mask) ? mask : -1;
  21603. },
  21604. enumerable: true,
  21605. configurable: true
  21606. });
  21607. /** @hidden */
  21608. FlyCamera.prototype._collideWithWorld = function (displacement) {
  21609. var globalPosition;
  21610. if (this.parent) {
  21611. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21612. }
  21613. else {
  21614. globalPosition = this.position;
  21615. }
  21616. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21617. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21618. var coordinator = this.getScene().collisionCoordinator;
  21619. if (!this._collider) {
  21620. this._collider = coordinator.createCollider();
  21621. }
  21622. this._collider._radius = this.ellipsoid;
  21623. this._collider.collisionMask = this._collisionMask;
  21624. // No need for clone, as long as gravity is not on.
  21625. var actualDisplacement = displacement;
  21626. // Add gravity to direction to prevent dual-collision checking.
  21627. if (this.applyGravity) {
  21628. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  21629. actualDisplacement = displacement.add(this.getScene().gravity);
  21630. }
  21631. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21632. };
  21633. /** @hidden */
  21634. FlyCamera.prototype._checkInputs = function () {
  21635. if (!this._localDirection) {
  21636. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21637. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21638. }
  21639. this.inputs.checkInputs();
  21640. _super.prototype._checkInputs.call(this);
  21641. };
  21642. /** @hidden */
  21643. FlyCamera.prototype._decideIfNeedsToMove = function () {
  21644. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21645. };
  21646. /** @hidden */
  21647. FlyCamera.prototype._updatePosition = function () {
  21648. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21649. this._collideWithWorld(this.cameraDirection);
  21650. }
  21651. else {
  21652. _super.prototype._updatePosition.call(this);
  21653. }
  21654. };
  21655. /**
  21656. * Restore the Roll to its target value at the rate specified.
  21657. * @param rate - Higher means slower restoring.
  21658. * @hidden
  21659. */
  21660. FlyCamera.prototype.restoreRoll = function (rate) {
  21661. var limit = this._trackRoll; // Target Roll.
  21662. var z = this.rotation.z; // Current Roll.
  21663. var delta = limit - z; // Difference in Roll.
  21664. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21665. // If the difference is noticable, restore the Roll.
  21666. if (Math.abs(delta) >= minRad) {
  21667. // Change Z rotation towards the target Roll.
  21668. this.rotation.z += delta / rate;
  21669. // Match when near enough.
  21670. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21671. this.rotation.z = limit;
  21672. }
  21673. }
  21674. };
  21675. /**
  21676. * Destroy the camera and release the current resources held by it.
  21677. */
  21678. FlyCamera.prototype.dispose = function () {
  21679. this.inputs.clear();
  21680. _super.prototype.dispose.call(this);
  21681. };
  21682. /**
  21683. * Get the current object class name.
  21684. * @returns the class name.
  21685. */
  21686. FlyCamera.prototype.getClassName = function () {
  21687. return "FlyCamera";
  21688. };
  21689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21691. ], FlyCamera.prototype, "ellipsoid", void 0);
  21692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21694. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21697. ], FlyCamera.prototype, "checkCollisions", void 0);
  21698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21700. ], FlyCamera.prototype, "applyGravity", void 0);
  21701. return FlyCamera;
  21702. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  21703. /***/ }),
  21704. /***/ "./Cameras/flyCameraInputsManager.ts":
  21705. /*!*******************************************!*\
  21706. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21707. \*******************************************/
  21708. /*! exports provided: FlyCameraInputsManager */
  21709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21710. "use strict";
  21711. __webpack_require__.r(__webpack_exports__);
  21712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21714. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21715. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21716. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21717. /**
  21718. * Default Inputs manager for the FlyCamera.
  21719. * It groups all the default supported inputs for ease of use.
  21720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21721. */
  21722. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21723. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21724. /**
  21725. * Instantiates a new FlyCameraInputsManager.
  21726. * @param camera Defines the camera the inputs belong to.
  21727. */
  21728. function FlyCameraInputsManager(camera) {
  21729. return _super.call(this, camera) || this;
  21730. }
  21731. /**
  21732. * Add keyboard input support to the input manager.
  21733. * @returns the new FlyCameraKeyboardMoveInput().
  21734. */
  21735. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21736. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21737. return this;
  21738. };
  21739. /**
  21740. * Add mouse input support to the input manager.
  21741. * @param touchEnabled Enable touch screen support.
  21742. * @returns the new FlyCameraMouseInput().
  21743. */
  21744. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21745. if (touchEnabled === void 0) { touchEnabled = true; }
  21746. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21747. return this;
  21748. };
  21749. return FlyCameraInputsManager;
  21750. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21751. /***/ }),
  21752. /***/ "./Cameras/followCamera.ts":
  21753. /*!*********************************!*\
  21754. !*** ./Cameras/followCamera.ts ***!
  21755. \*********************************/
  21756. /*! exports provided: FollowCamera, ArcFollowCamera */
  21757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21758. "use strict";
  21759. __webpack_require__.r(__webpack_exports__);
  21760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21762. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21763. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21764. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21765. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21767. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21768. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21769. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21770. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21771. });
  21772. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21773. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21774. });
  21775. /**
  21776. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21777. * an arc rotate version arcFollowCamera are available.
  21778. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21779. */
  21780. var FollowCamera = /** @class */ (function (_super) {
  21781. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21782. /**
  21783. * Instantiates the follow camera.
  21784. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21785. * @param name Define the name of the camera in the scene
  21786. * @param position Define the position of the camera
  21787. * @param scene Define the scene the camera belong to
  21788. * @param lockedTarget Define the target of the camera
  21789. */
  21790. function FollowCamera(name, position, scene, lockedTarget) {
  21791. if (lockedTarget === void 0) { lockedTarget = null; }
  21792. var _this = _super.call(this, name, position, scene) || this;
  21793. /**
  21794. * Distance the follow camera should follow an object at
  21795. */
  21796. _this.radius = 12;
  21797. /**
  21798. * Minimum allowed distance of the camera to the axis of rotation
  21799. * (The camera can not get closer).
  21800. * This can help limiting how the Camera is able to move in the scene.
  21801. */
  21802. _this.lowerRadiusLimit = null;
  21803. /**
  21804. * Maximum allowed distance of the camera to the axis of rotation
  21805. * (The camera can not get further).
  21806. * This can help limiting how the Camera is able to move in the scene.
  21807. */
  21808. _this.upperRadiusLimit = null;
  21809. /**
  21810. * Define a rotation offset between the camera and the object it follows
  21811. */
  21812. _this.rotationOffset = 0;
  21813. /**
  21814. * Minimum allowed angle to camera position relative to target object.
  21815. * This can help limiting how the Camera is able to move in the scene.
  21816. */
  21817. _this.lowerRotationOffsetLimit = null;
  21818. /**
  21819. * Maximum allowed angle to camera position relative to target object.
  21820. * This can help limiting how the Camera is able to move in the scene.
  21821. */
  21822. _this.upperRotationOffsetLimit = null;
  21823. /**
  21824. * Define a height offset between the camera and the object it follows.
  21825. * It can help following an object from the top (like a car chaing a plane)
  21826. */
  21827. _this.heightOffset = 4;
  21828. /**
  21829. * Minimum allowed height of camera position relative to target object.
  21830. * This can help limiting how the Camera is able to move in the scene.
  21831. */
  21832. _this.lowerHeightOffsetLimit = null;
  21833. /**
  21834. * Maximum allowed height of camera position relative to target object.
  21835. * This can help limiting how the Camera is able to move in the scene.
  21836. */
  21837. _this.upperHeightOffsetLimit = null;
  21838. /**
  21839. * Define how fast the camera can accelerate to follow it s target.
  21840. */
  21841. _this.cameraAcceleration = 0.05;
  21842. /**
  21843. * Define the speed limit of the camera following an object.
  21844. */
  21845. _this.maxCameraSpeed = 20;
  21846. _this.lockedTarget = lockedTarget;
  21847. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21848. _this.inputs.addKeyboard().addMouseWheel();
  21849. return _this;
  21850. // Uncomment the following line when the relevant handlers have been implemented.
  21851. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21852. }
  21853. FollowCamera.prototype._follow = function (cameraTarget) {
  21854. if (!cameraTarget) {
  21855. return;
  21856. }
  21857. var yRotation;
  21858. if (cameraTarget.rotationQuaternion) {
  21859. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21860. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21861. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21862. }
  21863. else {
  21864. yRotation = cameraTarget.rotation.y;
  21865. }
  21866. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21867. var targetPosition = cameraTarget.getAbsolutePosition();
  21868. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21869. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21870. var dx = targetX - this.position.x;
  21871. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21872. var dz = (targetZ) - this.position.z;
  21873. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21874. var vy = dy * this.cameraAcceleration;
  21875. var vz = dz * this.cameraAcceleration * 2;
  21876. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21877. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21878. }
  21879. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21880. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21881. }
  21882. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21883. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21884. }
  21885. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21886. this.setTarget(targetPosition);
  21887. };
  21888. /**
  21889. * Attached controls to the current camera.
  21890. * @param element Defines the element the controls should be listened from
  21891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21892. */
  21893. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21894. this.inputs.attachElement(element, noPreventDefault);
  21895. this._reset = function () {
  21896. };
  21897. };
  21898. /**
  21899. * Detach the current controls from the camera.
  21900. * The camera will stop reacting to inputs.
  21901. * @param element Defines the element to stop listening the inputs from
  21902. */
  21903. FollowCamera.prototype.detachControl = function (element) {
  21904. this.inputs.detachElement(element);
  21905. if (this._reset) {
  21906. this._reset();
  21907. }
  21908. };
  21909. /** @hidden */
  21910. FollowCamera.prototype._checkInputs = function () {
  21911. this.inputs.checkInputs();
  21912. this._checkLimits();
  21913. _super.prototype._checkInputs.call(this);
  21914. if (this.lockedTarget) {
  21915. this._follow(this.lockedTarget);
  21916. }
  21917. };
  21918. FollowCamera.prototype._checkLimits = function () {
  21919. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  21920. this.radius = this.lowerRadiusLimit;
  21921. }
  21922. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  21923. this.radius = this.upperRadiusLimit;
  21924. }
  21925. if (this.lowerHeightOffsetLimit !== null &&
  21926. this.heightOffset < this.lowerHeightOffsetLimit) {
  21927. this.heightOffset = this.lowerHeightOffsetLimit;
  21928. }
  21929. if (this.upperHeightOffsetLimit !== null &&
  21930. this.heightOffset > this.upperHeightOffsetLimit) {
  21931. this.heightOffset = this.upperHeightOffsetLimit;
  21932. }
  21933. if (this.lowerRotationOffsetLimit !== null &&
  21934. this.rotationOffset < this.lowerRotationOffsetLimit) {
  21935. this.rotationOffset = this.lowerRotationOffsetLimit;
  21936. }
  21937. if (this.upperRotationOffsetLimit !== null &&
  21938. this.rotationOffset > this.upperRotationOffsetLimit) {
  21939. this.rotationOffset = this.upperRotationOffsetLimit;
  21940. }
  21941. };
  21942. /**
  21943. * Gets the camera class name.
  21944. * @returns the class name
  21945. */
  21946. FollowCamera.prototype.getClassName = function () {
  21947. return "FollowCamera";
  21948. };
  21949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21951. ], FollowCamera.prototype, "radius", void 0);
  21952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21954. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  21955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21957. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  21958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21960. ], FollowCamera.prototype, "rotationOffset", void 0);
  21961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21963. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  21964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21966. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  21967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21969. ], FollowCamera.prototype, "heightOffset", void 0);
  21970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21972. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  21973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21975. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  21976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21978. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21979. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21981. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21984. ], FollowCamera.prototype, "lockedTarget", void 0);
  21985. return FollowCamera;
  21986. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21987. /**
  21988. * Arc Rotate version of the follow camera.
  21989. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21990. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21991. */
  21992. var ArcFollowCamera = /** @class */ (function (_super) {
  21993. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21994. /**
  21995. * Instantiates a new ArcFollowCamera
  21996. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21997. * @param name Define the name of the camera
  21998. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21999. * @param beta Define the rotation angle of the camera around the elevation axis
  22000. * @param radius Define the radius of the camera from its target point
  22001. * @param target Define the target of the camera
  22002. * @param scene Define the scene the camera belongs to
  22003. */
  22004. function ArcFollowCamera(name,
  22005. /** The longitudinal angle of the camera */
  22006. alpha,
  22007. /** The latitudinal angle of the camera */
  22008. beta,
  22009. /** The radius of the camera from its target */
  22010. radius,
  22011. /** Define the camera target (the messh it should follow) */
  22012. target, scene) {
  22013. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22014. _this.alpha = alpha;
  22015. _this.beta = beta;
  22016. _this.radius = radius;
  22017. _this.target = target;
  22018. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22019. _this._follow();
  22020. return _this;
  22021. }
  22022. ArcFollowCamera.prototype._follow = function () {
  22023. if (!this.target) {
  22024. return;
  22025. }
  22026. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22027. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22028. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22029. var targetPosition = this.target.getAbsolutePosition();
  22030. this.position = targetPosition.add(this._cartesianCoordinates);
  22031. this.setTarget(targetPosition);
  22032. };
  22033. /** @hidden */
  22034. ArcFollowCamera.prototype._checkInputs = function () {
  22035. _super.prototype._checkInputs.call(this);
  22036. this._follow();
  22037. };
  22038. /**
  22039. * Returns the class name of the object.
  22040. * It is mostly used internally for serialization purposes.
  22041. */
  22042. ArcFollowCamera.prototype.getClassName = function () {
  22043. return "ArcFollowCamera";
  22044. };
  22045. return ArcFollowCamera;
  22046. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22047. /***/ }),
  22048. /***/ "./Cameras/followCameraInputsManager.ts":
  22049. /*!**********************************************!*\
  22050. !*** ./Cameras/followCameraInputsManager.ts ***!
  22051. \**********************************************/
  22052. /*! exports provided: FollowCameraInputsManager */
  22053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22054. "use strict";
  22055. __webpack_require__.r(__webpack_exports__);
  22056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22057. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22058. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22059. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22060. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22061. /**
  22062. * Default Inputs manager for the FollowCamera.
  22063. * It groups all the default supported inputs for ease of use.
  22064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22065. */
  22066. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22067. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22068. /**
  22069. * Instantiates a new FollowCameraInputsManager.
  22070. * @param camera Defines the camera the inputs belong to
  22071. */
  22072. function FollowCameraInputsManager(camera) {
  22073. return _super.call(this, camera) || this;
  22074. }
  22075. /**
  22076. * Add keyboard input support to the input manager.
  22077. * @returns the current input manager
  22078. */
  22079. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22080. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22081. return this;
  22082. };
  22083. /**
  22084. * Add mouse wheel input support to the input manager.
  22085. * @returns the current input manager
  22086. */
  22087. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22088. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22089. return this;
  22090. };
  22091. /**
  22092. * Add pointers input support to the input manager.
  22093. * @returns the current input manager
  22094. */
  22095. FollowCameraInputsManager.prototype.addPointers = function () {
  22096. console.warn("Pointer support not yet implemented for FollowCamera.");
  22097. return this;
  22098. };
  22099. /**
  22100. * Add orientation input support to the input manager.
  22101. * @returns the current input manager
  22102. */
  22103. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22104. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22105. return this;
  22106. };
  22107. return FollowCameraInputsManager;
  22108. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22109. /***/ }),
  22110. /***/ "./Cameras/freeCamera.ts":
  22111. /*!*******************************!*\
  22112. !*** ./Cameras/freeCamera.ts ***!
  22113. \*******************************/
  22114. /*! exports provided: FreeCamera */
  22115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22116. "use strict";
  22117. __webpack_require__.r(__webpack_exports__);
  22118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22119. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22120. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22121. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22122. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22123. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22124. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22125. /**
  22126. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22127. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22129. */
  22130. var FreeCamera = /** @class */ (function (_super) {
  22131. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22132. /**
  22133. * Instantiates a Free Camera.
  22134. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22135. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22136. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22137. * @param name Define the name of the camera in the scene
  22138. * @param position Define the start position of the camera in the scene
  22139. * @param scene Define the scene the camera belongs to
  22140. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22141. */
  22142. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22143. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22144. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22145. /**
  22146. * Define the collision ellipsoid of the camera.
  22147. * This is helpful to simulate a camera body like the player body around the camera
  22148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22149. */
  22150. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22151. /**
  22152. * Define an offset for the position of the ellipsoid around the camera.
  22153. * This can be helpful to determine the center of the body near the gravity center of the body
  22154. * instead of its head.
  22155. */
  22156. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22157. /**
  22158. * Enable or disable collisions of the camera with the rest of the scene objects.
  22159. */
  22160. _this.checkCollisions = false;
  22161. /**
  22162. * Enable or disable gravity on the camera.
  22163. */
  22164. _this.applyGravity = false;
  22165. _this._needMoveForGravity = false;
  22166. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22167. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22168. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22169. // Collisions
  22170. _this._collisionMask = -1;
  22171. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22172. if (collidedMesh === void 0) { collidedMesh = null; }
  22173. var updatePosition = function (newPos) {
  22174. _this._newPosition.copyFrom(newPos);
  22175. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22176. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22177. _this.position.addInPlace(_this._diffPosition);
  22178. if (_this.onCollide && collidedMesh) {
  22179. _this.onCollide(collidedMesh);
  22180. }
  22181. }
  22182. };
  22183. updatePosition(newPosition);
  22184. };
  22185. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22186. _this.inputs.addKeyboard().addMouse();
  22187. return _this;
  22188. }
  22189. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22190. /**
  22191. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22192. * Higher values reduce sensitivity.
  22193. */
  22194. get: function () {
  22195. var mouse = this.inputs.attached["mouse"];
  22196. if (mouse) {
  22197. return mouse.angularSensibility;
  22198. }
  22199. return 0;
  22200. },
  22201. /**
  22202. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22203. * Higher values reduce sensitivity.
  22204. */
  22205. set: function (value) {
  22206. var mouse = this.inputs.attached["mouse"];
  22207. if (mouse) {
  22208. mouse.angularSensibility = value;
  22209. }
  22210. },
  22211. enumerable: true,
  22212. configurable: true
  22213. });
  22214. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22215. /**
  22216. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22217. */
  22218. get: function () {
  22219. var keyboard = this.inputs.attached["keyboard"];
  22220. if (keyboard) {
  22221. return keyboard.keysUp;
  22222. }
  22223. return [];
  22224. },
  22225. set: function (value) {
  22226. var keyboard = this.inputs.attached["keyboard"];
  22227. if (keyboard) {
  22228. keyboard.keysUp = value;
  22229. }
  22230. },
  22231. enumerable: true,
  22232. configurable: true
  22233. });
  22234. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22235. /**
  22236. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22237. */
  22238. get: function () {
  22239. var keyboard = this.inputs.attached["keyboard"];
  22240. if (keyboard) {
  22241. return keyboard.keysDown;
  22242. }
  22243. return [];
  22244. },
  22245. set: function (value) {
  22246. var keyboard = this.inputs.attached["keyboard"];
  22247. if (keyboard) {
  22248. keyboard.keysDown = value;
  22249. }
  22250. },
  22251. enumerable: true,
  22252. configurable: true
  22253. });
  22254. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22255. /**
  22256. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22257. */
  22258. get: function () {
  22259. var keyboard = this.inputs.attached["keyboard"];
  22260. if (keyboard) {
  22261. return keyboard.keysLeft;
  22262. }
  22263. return [];
  22264. },
  22265. set: function (value) {
  22266. var keyboard = this.inputs.attached["keyboard"];
  22267. if (keyboard) {
  22268. keyboard.keysLeft = value;
  22269. }
  22270. },
  22271. enumerable: true,
  22272. configurable: true
  22273. });
  22274. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22275. /**
  22276. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22277. */
  22278. get: function () {
  22279. var keyboard = this.inputs.attached["keyboard"];
  22280. if (keyboard) {
  22281. return keyboard.keysRight;
  22282. }
  22283. return [];
  22284. },
  22285. set: function (value) {
  22286. var keyboard = this.inputs.attached["keyboard"];
  22287. if (keyboard) {
  22288. keyboard.keysRight = value;
  22289. }
  22290. },
  22291. enumerable: true,
  22292. configurable: true
  22293. });
  22294. /**
  22295. * Attached controls to the current camera.
  22296. * @param element Defines the element the controls should be listened from
  22297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22298. */
  22299. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22300. this.inputs.attachElement(element, noPreventDefault);
  22301. };
  22302. /**
  22303. * Detach the current controls from the camera.
  22304. * The camera will stop reacting to inputs.
  22305. * @param element Defines the element to stop listening the inputs from
  22306. */
  22307. FreeCamera.prototype.detachControl = function (element) {
  22308. this.inputs.detachElement(element);
  22309. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22310. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22311. };
  22312. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22313. /**
  22314. * Define a collision mask to limit the list of object the camera can collide with
  22315. */
  22316. get: function () {
  22317. return this._collisionMask;
  22318. },
  22319. set: function (mask) {
  22320. this._collisionMask = !isNaN(mask) ? mask : -1;
  22321. },
  22322. enumerable: true,
  22323. configurable: true
  22324. });
  22325. /** @hidden */
  22326. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22327. var globalPosition;
  22328. if (this.parent) {
  22329. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22330. }
  22331. else {
  22332. globalPosition = this.position;
  22333. }
  22334. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22335. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22336. var coordinator = this.getScene().collisionCoordinator;
  22337. if (!this._collider) {
  22338. this._collider = coordinator.createCollider();
  22339. }
  22340. this._collider._radius = this.ellipsoid;
  22341. this._collider.collisionMask = this._collisionMask;
  22342. //no need for clone, as long as gravity is not on.
  22343. var actualDisplacement = displacement;
  22344. //add gravity to the direction to prevent the dual-collision checking
  22345. if (this.applyGravity) {
  22346. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22347. actualDisplacement = displacement.add(this.getScene().gravity);
  22348. }
  22349. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22350. };
  22351. /** @hidden */
  22352. FreeCamera.prototype._checkInputs = function () {
  22353. if (!this._localDirection) {
  22354. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22355. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22356. }
  22357. this.inputs.checkInputs();
  22358. _super.prototype._checkInputs.call(this);
  22359. };
  22360. /** @hidden */
  22361. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22362. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22363. };
  22364. /** @hidden */
  22365. FreeCamera.prototype._updatePosition = function () {
  22366. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22367. this._collideWithWorld(this.cameraDirection);
  22368. }
  22369. else {
  22370. _super.prototype._updatePosition.call(this);
  22371. }
  22372. };
  22373. /**
  22374. * Destroy the camera and release the current resources hold by it.
  22375. */
  22376. FreeCamera.prototype.dispose = function () {
  22377. this.inputs.clear();
  22378. _super.prototype.dispose.call(this);
  22379. };
  22380. /**
  22381. * Gets the current object class name.
  22382. * @return the class name
  22383. */
  22384. FreeCamera.prototype.getClassName = function () {
  22385. return "FreeCamera";
  22386. };
  22387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22389. ], FreeCamera.prototype, "ellipsoid", void 0);
  22390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22392. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22395. ], FreeCamera.prototype, "checkCollisions", void 0);
  22396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22398. ], FreeCamera.prototype, "applyGravity", void 0);
  22399. return FreeCamera;
  22400. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22401. /***/ }),
  22402. /***/ "./Cameras/freeCameraInputsManager.ts":
  22403. /*!********************************************!*\
  22404. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22405. \********************************************/
  22406. /*! exports provided: FreeCameraInputsManager */
  22407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22408. "use strict";
  22409. __webpack_require__.r(__webpack_exports__);
  22410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22411. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22412. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22413. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22414. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22415. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22416. /**
  22417. * Default Inputs manager for the FreeCamera.
  22418. * It groups all the default supported inputs for ease of use.
  22419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22420. */
  22421. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22422. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22423. /**
  22424. * Instantiates a new FreeCameraInputsManager.
  22425. * @param camera Defines the camera the inputs belong to
  22426. */
  22427. function FreeCameraInputsManager(camera) {
  22428. return _super.call(this, camera) || this;
  22429. }
  22430. /**
  22431. * Add keyboard input support to the input manager.
  22432. * @returns the current input manager
  22433. */
  22434. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22435. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22436. return this;
  22437. };
  22438. /**
  22439. * Add mouse input support to the input manager.
  22440. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22441. * @returns the current input manager
  22442. */
  22443. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22444. if (touchEnabled === void 0) { touchEnabled = true; }
  22445. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22446. return this;
  22447. };
  22448. /**
  22449. * Add touch input support to the input manager.
  22450. * @returns the current input manager
  22451. */
  22452. FreeCameraInputsManager.prototype.addTouch = function () {
  22453. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22454. return this;
  22455. };
  22456. return FreeCameraInputsManager;
  22457. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22458. /***/ }),
  22459. /***/ "./Cameras/gamepadCamera.ts":
  22460. /*!**********************************!*\
  22461. !*** ./Cameras/gamepadCamera.ts ***!
  22462. \**********************************/
  22463. /*! exports provided: GamepadCamera */
  22464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22465. "use strict";
  22466. __webpack_require__.r(__webpack_exports__);
  22467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22469. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22470. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22471. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22472. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22473. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22474. });
  22475. /**
  22476. * This represents a FPS type of camera. This is only here for back compat purpose.
  22477. * Please use the UniversalCamera instead as both are identical.
  22478. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22479. */
  22480. var GamepadCamera = /** @class */ (function (_super) {
  22481. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22482. /**
  22483. * Instantiates a new Gamepad Camera
  22484. * This represents a FPS type of camera. This is only here for back compat purpose.
  22485. * Please use the UniversalCamera instead as both are identical.
  22486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22487. * @param name Define the name of the camera in the scene
  22488. * @param position Define the start position of the camera in the scene
  22489. * @param scene Define the scene the camera belongs to
  22490. */
  22491. function GamepadCamera(name, position, scene) {
  22492. return _super.call(this, name, position, scene) || this;
  22493. }
  22494. /**
  22495. * Gets the current object class name.
  22496. * @return the class name
  22497. */
  22498. GamepadCamera.prototype.getClassName = function () {
  22499. return "GamepadCamera";
  22500. };
  22501. return GamepadCamera;
  22502. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22503. /***/ }),
  22504. /***/ "./Cameras/index.ts":
  22505. /*!**************************!*\
  22506. !*** ./Cameras/index.ts ***!
  22507. \**************************/
  22508. /*! 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 */
  22509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22510. "use strict";
  22511. __webpack_require__.r(__webpack_exports__);
  22512. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22526. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22529. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  22531. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  22533. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  22535. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  22537. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  22539. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  22540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  22541. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  22542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  22543. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  22544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  22545. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  22546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  22547. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  22549. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  22550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  22551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  22552. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  22553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  22554. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  22555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  22556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  22557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  22558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  22559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  22560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  22561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  22562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  22563. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  22565. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  22566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  22567. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  22568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  22569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  22570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  22571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  22572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  22573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  22574. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  22575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  22576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  22577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  22578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  22579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  22580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  22581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  22582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  22583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  22584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  22585. /***/ }),
  22586. /***/ "./Cameras/targetCamera.ts":
  22587. /*!*********************************!*\
  22588. !*** ./Cameras/targetCamera.ts ***!
  22589. \*********************************/
  22590. /*! exports provided: TargetCamera */
  22591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22592. "use strict";
  22593. __webpack_require__.r(__webpack_exports__);
  22594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  22595. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22596. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22597. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22598. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22599. /**
  22600. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  22601. * This is the base of the follow, arc rotate cameras and Free camera
  22602. * @see http://doc.babylonjs.com/features/cameras
  22603. */
  22604. var TargetCamera = /** @class */ (function (_super) {
  22605. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  22606. /**
  22607. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  22608. * This is the base of the follow, arc rotate cameras and Free camera
  22609. * @see http://doc.babylonjs.com/features/cameras
  22610. * @param name Defines the name of the camera in the scene
  22611. * @param position Defines the start position of the camera in the scene
  22612. * @param scene Defines the scene the camera belongs to
  22613. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22614. */
  22615. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22616. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22617. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22618. /**
  22619. * Define the current direction the camera is moving to
  22620. */
  22621. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22622. /**
  22623. * Define the current rotation the camera is rotating to
  22624. */
  22625. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  22626. /**
  22627. * When set, the up vector of the camera will be updated by the rotation of the camera
  22628. */
  22629. _this.updateUpVectorFromRotation = false;
  22630. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22631. /**
  22632. * Define the current rotation of the camera
  22633. */
  22634. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22635. /**
  22636. * Define the current speed of the camera
  22637. */
  22638. _this.speed = 2.0;
  22639. /**
  22640. * Add cconstraint to the camera to prevent it to move freely in all directions and
  22641. * around all axis.
  22642. */
  22643. _this.noRotationConstraint = false;
  22644. /**
  22645. * Define the current target of the camera as an object or a position.
  22646. */
  22647. _this.lockedTarget = null;
  22648. /** @hidden */
  22649. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22650. /** @hidden */
  22651. _this._initialFocalDistance = 1;
  22652. /** @hidden */
  22653. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22654. /** @hidden */
  22655. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22656. /** @hidden */
  22657. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22658. /** @hidden */
  22659. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22660. /** @hidden */
  22661. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  22662. /** @hidden */
  22663. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22664. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22665. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22666. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  22667. _this._cachedRotationZ = 0;
  22668. _this._cachedQuaternionRotationZ = 0;
  22669. return _this;
  22670. }
  22671. /**
  22672. * Gets the position in front of the camera at a given distance.
  22673. * @param distance The distance from the camera we want the position to be
  22674. * @returns the position
  22675. */
  22676. TargetCamera.prototype.getFrontPosition = function (distance) {
  22677. this.getWorldMatrix();
  22678. var direction = this.getTarget().subtract(this.position);
  22679. direction.normalize();
  22680. direction.scaleInPlace(distance);
  22681. return this.globalPosition.add(direction);
  22682. };
  22683. /** @hidden */
  22684. TargetCamera.prototype._getLockedTargetPosition = function () {
  22685. if (!this.lockedTarget) {
  22686. return null;
  22687. }
  22688. if (this.lockedTarget.absolutePosition) {
  22689. this.lockedTarget.computeWorldMatrix();
  22690. }
  22691. return this.lockedTarget.absolutePosition || this.lockedTarget;
  22692. };
  22693. /**
  22694. * Store current camera state of the camera (fov, position, rotation, etc..)
  22695. * @returns the camera
  22696. */
  22697. TargetCamera.prototype.storeState = function () {
  22698. this._storedPosition = this.position.clone();
  22699. this._storedRotation = this.rotation.clone();
  22700. if (this.rotationQuaternion) {
  22701. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  22702. }
  22703. return _super.prototype.storeState.call(this);
  22704. };
  22705. /**
  22706. * Restored camera state. You must call storeState() first
  22707. * @returns whether it was successful or not
  22708. * @hidden
  22709. */
  22710. TargetCamera.prototype._restoreStateValues = function () {
  22711. if (!_super.prototype._restoreStateValues.call(this)) {
  22712. return false;
  22713. }
  22714. this.position = this._storedPosition.clone();
  22715. this.rotation = this._storedRotation.clone();
  22716. if (this.rotationQuaternion) {
  22717. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  22718. }
  22719. this.cameraDirection.copyFromFloats(0, 0, 0);
  22720. this.cameraRotation.copyFromFloats(0, 0);
  22721. return true;
  22722. };
  22723. /** @hidden */
  22724. TargetCamera.prototype._initCache = function () {
  22725. _super.prototype._initCache.call(this);
  22726. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22727. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22728. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22729. };
  22730. /** @hidden */
  22731. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22732. if (!ignoreParentClass) {
  22733. _super.prototype._updateCache.call(this);
  22734. }
  22735. var lockedTargetPosition = this._getLockedTargetPosition();
  22736. if (!lockedTargetPosition) {
  22737. this._cache.lockedTarget = null;
  22738. }
  22739. else {
  22740. if (!this._cache.lockedTarget) {
  22741. this._cache.lockedTarget = lockedTargetPosition.clone();
  22742. }
  22743. else {
  22744. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22745. }
  22746. }
  22747. this._cache.rotation.copyFrom(this.rotation);
  22748. if (this.rotationQuaternion) {
  22749. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22750. }
  22751. };
  22752. // Synchronized
  22753. /** @hidden */
  22754. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22755. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22756. return false;
  22757. }
  22758. var lockedTargetPosition = this._getLockedTargetPosition();
  22759. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22760. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22761. };
  22762. // Methods
  22763. /** @hidden */
  22764. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22765. var engine = this.getEngine();
  22766. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22767. };
  22768. // Target
  22769. /** @hidden */
  22770. TargetCamera.prototype.setTarget = function (target) {
  22771. this.upVector.normalize();
  22772. this._initialFocalDistance = target.subtract(this.position).length();
  22773. if (this.position.z === target.z) {
  22774. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22775. }
  22776. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22777. this._camMatrix.invert();
  22778. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22779. var vDir = target.subtract(this.position);
  22780. if (vDir.x >= 0.0) {
  22781. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22782. }
  22783. else {
  22784. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22785. }
  22786. this.rotation.z = 0;
  22787. if (isNaN(this.rotation.x)) {
  22788. this.rotation.x = 0;
  22789. }
  22790. if (isNaN(this.rotation.y)) {
  22791. this.rotation.y = 0;
  22792. }
  22793. if (isNaN(this.rotation.z)) {
  22794. this.rotation.z = 0;
  22795. }
  22796. if (this.rotationQuaternion) {
  22797. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22798. }
  22799. };
  22800. /**
  22801. * Return the current target position of the camera. This value is expressed in local space.
  22802. * @returns the target position
  22803. */
  22804. TargetCamera.prototype.getTarget = function () {
  22805. return this._currentTarget;
  22806. };
  22807. /** @hidden */
  22808. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22809. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22810. };
  22811. /** @hidden */
  22812. TargetCamera.prototype._updatePosition = function () {
  22813. if (this.parent) {
  22814. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22815. _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]);
  22816. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22817. return;
  22818. }
  22819. this.position.addInPlace(this.cameraDirection);
  22820. };
  22821. /** @hidden */
  22822. TargetCamera.prototype._checkInputs = function () {
  22823. var needToMove = this._decideIfNeedsToMove();
  22824. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22825. // Move
  22826. if (needToMove) {
  22827. this._updatePosition();
  22828. }
  22829. // Rotate
  22830. if (needToRotate) {
  22831. this.rotation.x += this.cameraRotation.x;
  22832. this.rotation.y += this.cameraRotation.y;
  22833. //rotate, if quaternion is set and rotation was used
  22834. if (this.rotationQuaternion) {
  22835. var len = this.rotation.lengthSquared();
  22836. if (len) {
  22837. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22838. }
  22839. }
  22840. if (!this.noRotationConstraint) {
  22841. var limit = (Math.PI / 2) * 0.95;
  22842. if (this.rotation.x > limit) {
  22843. this.rotation.x = limit;
  22844. }
  22845. if (this.rotation.x < -limit) {
  22846. this.rotation.x = -limit;
  22847. }
  22848. }
  22849. }
  22850. // Inertia
  22851. if (needToMove) {
  22852. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22853. this.cameraDirection.x = 0;
  22854. }
  22855. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22856. this.cameraDirection.y = 0;
  22857. }
  22858. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22859. this.cameraDirection.z = 0;
  22860. }
  22861. this.cameraDirection.scaleInPlace(this.inertia);
  22862. }
  22863. if (needToRotate) {
  22864. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22865. this.cameraRotation.x = 0;
  22866. }
  22867. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22868. this.cameraRotation.y = 0;
  22869. }
  22870. this.cameraRotation.scaleInPlace(this.inertia);
  22871. }
  22872. _super.prototype._checkInputs.call(this);
  22873. };
  22874. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22875. if (this.rotationQuaternion) {
  22876. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22877. }
  22878. else {
  22879. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22880. }
  22881. };
  22882. /**
  22883. * 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)
  22884. * @returns the current camera
  22885. */
  22886. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22887. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22888. return this;
  22889. };
  22890. /** @hidden */
  22891. TargetCamera.prototype._getViewMatrix = function () {
  22892. if (this.lockedTarget) {
  22893. this.setTarget(this._getLockedTargetPosition());
  22894. }
  22895. // Compute
  22896. this._updateCameraRotationMatrix();
  22897. // Apply the changed rotation to the upVector
  22898. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22899. this._rotateUpVectorWithCameraRotationMatrix();
  22900. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22901. }
  22902. else if (this._cachedRotationZ != this.rotation.z) {
  22903. this._rotateUpVectorWithCameraRotationMatrix();
  22904. this._cachedRotationZ = this.rotation.z;
  22905. }
  22906. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22907. // Computing target and final matrix
  22908. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22909. if (this.updateUpVectorFromRotation) {
  22910. if (this.rotationQuaternion) {
  22911. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22912. }
  22913. else {
  22914. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22915. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22916. }
  22917. }
  22918. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22919. return this._viewMatrix;
  22920. };
  22921. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22922. if (this.parent) {
  22923. var parentWorldMatrix = this.parent.getWorldMatrix();
  22924. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22925. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22926. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22927. this._markSyncedWithParent();
  22928. }
  22929. else {
  22930. this._globalPosition.copyFrom(position);
  22931. this._globalCurrentTarget.copyFrom(target);
  22932. this._globalCurrentUpVector.copyFrom(up);
  22933. }
  22934. if (this.getScene().useRightHandedSystem) {
  22935. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22936. }
  22937. else {
  22938. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22939. }
  22940. };
  22941. /**
  22942. * @hidden
  22943. */
  22944. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22945. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22946. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22947. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22948. if (!this.rotationQuaternion) {
  22949. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22950. }
  22951. rigCamera._cameraRigParams = {};
  22952. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22953. }
  22954. return rigCamera;
  22955. }
  22956. return null;
  22957. };
  22958. /**
  22959. * @hidden
  22960. */
  22961. TargetCamera.prototype._updateRigCameras = function () {
  22962. var camLeft = this._rigCameras[0];
  22963. var camRight = this._rigCameras[1];
  22964. this.computeWorldMatrix();
  22965. switch (this.cameraRigMode) {
  22966. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22967. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22968. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22969. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22970. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22971. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22972. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22973. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22974. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22975. break;
  22976. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22977. if (camLeft.rotationQuaternion) {
  22978. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22979. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22980. }
  22981. else {
  22982. camLeft.rotation.copyFrom(this.rotation);
  22983. camRight.rotation.copyFrom(this.rotation);
  22984. }
  22985. camLeft.position.copyFrom(this.position);
  22986. camRight.position.copyFrom(this.position);
  22987. break;
  22988. }
  22989. _super.prototype._updateRigCameras.call(this);
  22990. };
  22991. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22992. var target = this.getTarget();
  22993. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22994. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22995. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22996. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22997. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22998. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22999. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23000. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23001. rigCamera.setTarget(newFocalTarget);
  23002. };
  23003. /**
  23004. * Gets the current object class name.
  23005. * @return the class name
  23006. */
  23007. TargetCamera.prototype.getClassName = function () {
  23008. return "TargetCamera";
  23009. };
  23010. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23011. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23012. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23015. ], TargetCamera.prototype, "rotation", void 0);
  23016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23018. ], TargetCamera.prototype, "speed", void 0);
  23019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23021. ], TargetCamera.prototype, "lockedTarget", void 0);
  23022. return TargetCamera;
  23023. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23024. /***/ }),
  23025. /***/ "./Cameras/touchCamera.ts":
  23026. /*!********************************!*\
  23027. !*** ./Cameras/touchCamera.ts ***!
  23028. \********************************/
  23029. /*! exports provided: TouchCamera */
  23030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23031. "use strict";
  23032. __webpack_require__.r(__webpack_exports__);
  23033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23034. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23035. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23037. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23038. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23039. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23040. });
  23041. /**
  23042. * This represents a FPS type of camera controlled by touch.
  23043. * This is like a universal camera minus the Gamepad controls.
  23044. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23045. */
  23046. var TouchCamera = /** @class */ (function (_super) {
  23047. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23048. /**
  23049. * Instantiates a new touch camera.
  23050. * This represents a FPS type of camera controlled by touch.
  23051. * This is like a universal camera minus the Gamepad controls.
  23052. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23053. * @param name Define the name of the camera in the scene
  23054. * @param position Define the start position of the camera in the scene
  23055. * @param scene Define the scene the camera belongs to
  23056. */
  23057. function TouchCamera(name, position, scene) {
  23058. var _this = _super.call(this, name, position, scene) || this;
  23059. _this.inputs.addTouch();
  23060. _this._setupInputs();
  23061. return _this;
  23062. }
  23063. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23064. /**
  23065. * Defines the touch sensibility for rotation.
  23066. * The higher the faster.
  23067. */
  23068. get: function () {
  23069. var touch = this.inputs.attached["touch"];
  23070. if (touch) {
  23071. return touch.touchAngularSensibility;
  23072. }
  23073. return 0;
  23074. },
  23075. set: function (value) {
  23076. var touch = this.inputs.attached["touch"];
  23077. if (touch) {
  23078. touch.touchAngularSensibility = value;
  23079. }
  23080. },
  23081. enumerable: true,
  23082. configurable: true
  23083. });
  23084. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23085. /**
  23086. * Defines the touch sensibility for move.
  23087. * The higher the faster.
  23088. */
  23089. get: function () {
  23090. var touch = this.inputs.attached["touch"];
  23091. if (touch) {
  23092. return touch.touchMoveSensibility;
  23093. }
  23094. return 0;
  23095. },
  23096. set: function (value) {
  23097. var touch = this.inputs.attached["touch"];
  23098. if (touch) {
  23099. touch.touchMoveSensibility = value;
  23100. }
  23101. },
  23102. enumerable: true,
  23103. configurable: true
  23104. });
  23105. /**
  23106. * Gets the current object class name.
  23107. * @return the class name
  23108. */
  23109. TouchCamera.prototype.getClassName = function () {
  23110. return "TouchCamera";
  23111. };
  23112. /** @hidden */
  23113. TouchCamera.prototype._setupInputs = function () {
  23114. var mouse = this.inputs.attached["mouse"];
  23115. if (mouse) {
  23116. mouse.touchEnabled = false;
  23117. }
  23118. };
  23119. return TouchCamera;
  23120. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23121. /***/ }),
  23122. /***/ "./Cameras/universalCamera.ts":
  23123. /*!************************************!*\
  23124. !*** ./Cameras/universalCamera.ts ***!
  23125. \************************************/
  23126. /*! exports provided: UniversalCamera */
  23127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23128. "use strict";
  23129. __webpack_require__.r(__webpack_exports__);
  23130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23132. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23133. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23134. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23135. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23136. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23137. // Forcing to use the Universal camera
  23138. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23139. });
  23140. /**
  23141. * 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,
  23142. * which still works and will still be found in many Playgrounds.
  23143. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23144. */
  23145. var UniversalCamera = /** @class */ (function (_super) {
  23146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23147. /**
  23148. * 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,
  23149. * which still works and will still be found in many Playgrounds.
  23150. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23151. * @param name Define the name of the camera in the scene
  23152. * @param position Define the start position of the camera in the scene
  23153. * @param scene Define the scene the camera belongs to
  23154. */
  23155. function UniversalCamera(name, position, scene) {
  23156. var _this = _super.call(this, name, position, scene) || this;
  23157. _this.inputs.addGamepad();
  23158. return _this;
  23159. }
  23160. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23161. /**
  23162. * Defines the gamepad rotation sensiblity.
  23163. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23164. */
  23165. get: function () {
  23166. var gamepad = this.inputs.attached["gamepad"];
  23167. if (gamepad) {
  23168. return gamepad.gamepadAngularSensibility;
  23169. }
  23170. return 0;
  23171. },
  23172. set: function (value) {
  23173. var gamepad = this.inputs.attached["gamepad"];
  23174. if (gamepad) {
  23175. gamepad.gamepadAngularSensibility = value;
  23176. }
  23177. },
  23178. enumerable: true,
  23179. configurable: true
  23180. });
  23181. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23182. /**
  23183. * Defines the gamepad move sensiblity.
  23184. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23185. */
  23186. get: function () {
  23187. var gamepad = this.inputs.attached["gamepad"];
  23188. if (gamepad) {
  23189. return gamepad.gamepadMoveSensibility;
  23190. }
  23191. return 0;
  23192. },
  23193. set: function (value) {
  23194. var gamepad = this.inputs.attached["gamepad"];
  23195. if (gamepad) {
  23196. gamepad.gamepadMoveSensibility = value;
  23197. }
  23198. },
  23199. enumerable: true,
  23200. configurable: true
  23201. });
  23202. /**
  23203. * Gets the current object class name.
  23204. * @return the class name
  23205. */
  23206. UniversalCamera.prototype.getClassName = function () {
  23207. return "UniversalCamera";
  23208. };
  23209. return UniversalCamera;
  23210. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23211. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23212. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23213. };
  23214. /***/ }),
  23215. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23216. /*!*******************************************!*\
  23217. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23218. \*******************************************/
  23219. /*! exports provided: VirtualJoysticksCamera */
  23220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23221. "use strict";
  23222. __webpack_require__.r(__webpack_exports__);
  23223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23225. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23226. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23227. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23228. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23229. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23230. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23231. });
  23232. /**
  23233. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23234. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23235. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23236. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23237. */
  23238. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23239. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23240. /**
  23241. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23242. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23243. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23244. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23245. * @param name Define the name of the camera in the scene
  23246. * @param position Define the start position of the camera in the scene
  23247. * @param scene Define the scene the camera belongs to
  23248. */
  23249. function VirtualJoysticksCamera(name, position, scene) {
  23250. var _this = _super.call(this, name, position, scene) || this;
  23251. _this.inputs.addVirtualJoystick();
  23252. return _this;
  23253. }
  23254. /**
  23255. * Gets the current object class name.
  23256. * @return the class name
  23257. */
  23258. VirtualJoysticksCamera.prototype.getClassName = function () {
  23259. return "VirtualJoysticksCamera";
  23260. };
  23261. return VirtualJoysticksCamera;
  23262. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23263. /***/ }),
  23264. /***/ "./Collisions/collider.ts":
  23265. /*!********************************!*\
  23266. !*** ./Collisions/collider.ts ***!
  23267. \********************************/
  23268. /*! exports provided: Collider */
  23269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23270. "use strict";
  23271. __webpack_require__.r(__webpack_exports__);
  23272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23273. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23274. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23275. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23276. return false;
  23277. }
  23278. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23279. return false;
  23280. }
  23281. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23282. return false;
  23283. }
  23284. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23285. return false;
  23286. }
  23287. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23288. return false;
  23289. }
  23290. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23291. return false;
  23292. }
  23293. return true;
  23294. };
  23295. var getLowestRoot = (function () {
  23296. var result = { root: 0, found: false };
  23297. return function (a, b, c, maxR) {
  23298. result.root = 0;
  23299. result.found = false;
  23300. var determinant = b * b - 4.0 * a * c;
  23301. if (determinant < 0) {
  23302. return result;
  23303. }
  23304. var sqrtD = Math.sqrt(determinant);
  23305. var r1 = (-b - sqrtD) / (2.0 * a);
  23306. var r2 = (-b + sqrtD) / (2.0 * a);
  23307. if (r1 > r2) {
  23308. var temp = r2;
  23309. r2 = r1;
  23310. r1 = temp;
  23311. }
  23312. if (r1 > 0 && r1 < maxR) {
  23313. result.root = r1;
  23314. result.found = true;
  23315. return result;
  23316. }
  23317. if (r2 > 0 && r2 < maxR) {
  23318. result.root = r2;
  23319. result.found = true;
  23320. return result;
  23321. }
  23322. return result;
  23323. };
  23324. })();
  23325. /** @hidden */
  23326. var Collider = /** @class */ (function () {
  23327. function Collider() {
  23328. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23329. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23330. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23331. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23332. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23333. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23334. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23335. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23336. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23337. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23338. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23339. /** @hidden */
  23340. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23341. /** @hidden */
  23342. this._retry = 0;
  23343. /** @hidden */
  23344. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23345. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23346. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23347. this._collisionMask = -1;
  23348. }
  23349. Object.defineProperty(Collider.prototype, "collisionMask", {
  23350. get: function () {
  23351. return this._collisionMask;
  23352. },
  23353. set: function (mask) {
  23354. this._collisionMask = !isNaN(mask) ? mask : -1;
  23355. },
  23356. enumerable: true,
  23357. configurable: true
  23358. });
  23359. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23360. /**
  23361. * Gets the plane normal used to compute the sliding response (in local space)
  23362. */
  23363. get: function () {
  23364. return this._slidePlaneNormal;
  23365. },
  23366. enumerable: true,
  23367. configurable: true
  23368. });
  23369. // Methods
  23370. /** @hidden */
  23371. Collider.prototype._initialize = function (source, dir, e) {
  23372. this._velocity = dir;
  23373. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23374. this._basePoint = source;
  23375. source.multiplyToRef(this._radius, this._basePointWorld);
  23376. dir.multiplyToRef(this._radius, this._velocityWorld);
  23377. this._velocityWorldLength = this._velocityWorld.length();
  23378. this._epsilon = e;
  23379. this.collisionFound = false;
  23380. };
  23381. /** @hidden */
  23382. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23383. pa.subtractToRef(point, this._tempVector);
  23384. pb.subtractToRef(point, this._tempVector2);
  23385. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23386. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23387. if (d < 0) {
  23388. return false;
  23389. }
  23390. pc.subtractToRef(point, this._tempVector3);
  23391. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23392. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23393. if (d < 0) {
  23394. return false;
  23395. }
  23396. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23397. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23398. return d >= 0;
  23399. };
  23400. /** @hidden */
  23401. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23402. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23403. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23404. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23405. return false;
  23406. }
  23407. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23408. return false;
  23409. }
  23410. return true;
  23411. };
  23412. /** @hidden */
  23413. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23414. var t0;
  23415. var embeddedInPlane = false;
  23416. //defensive programming, actually not needed.
  23417. if (!trianglePlaneArray) {
  23418. trianglePlaneArray = [];
  23419. }
  23420. if (!trianglePlaneArray[faceIndex]) {
  23421. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23422. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23423. }
  23424. var trianglePlane = trianglePlaneArray[faceIndex];
  23425. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23426. return;
  23427. }
  23428. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23429. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23430. if (normalDotVelocity == 0) {
  23431. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23432. return;
  23433. }
  23434. embeddedInPlane = true;
  23435. t0 = 0;
  23436. }
  23437. else {
  23438. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23439. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23440. if (t0 > t1) {
  23441. var temp = t1;
  23442. t1 = t0;
  23443. t0 = temp;
  23444. }
  23445. if (t0 > 1.0 || t1 < 0.0) {
  23446. return;
  23447. }
  23448. if (t0 < 0) {
  23449. t0 = 0;
  23450. }
  23451. if (t0 > 1.0) {
  23452. t0 = 1.0;
  23453. }
  23454. }
  23455. this._collisionPoint.copyFromFloats(0, 0, 0);
  23456. var found = false;
  23457. var t = 1.0;
  23458. if (!embeddedInPlane) {
  23459. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23460. this._velocity.scaleToRef(t0, this._tempVector);
  23461. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23462. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23463. found = true;
  23464. t = t0;
  23465. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23466. }
  23467. }
  23468. if (!found) {
  23469. var velocitySquaredLength = this._velocity.lengthSquared();
  23470. var a = velocitySquaredLength;
  23471. this._basePoint.subtractToRef(p1, this._tempVector);
  23472. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23473. var c = this._tempVector.lengthSquared() - 1.0;
  23474. var lowestRoot = getLowestRoot(a, b, c, t);
  23475. if (lowestRoot.found) {
  23476. t = lowestRoot.root;
  23477. found = true;
  23478. this._collisionPoint.copyFrom(p1);
  23479. }
  23480. this._basePoint.subtractToRef(p2, this._tempVector);
  23481. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23482. c = this._tempVector.lengthSquared() - 1.0;
  23483. lowestRoot = getLowestRoot(a, b, c, t);
  23484. if (lowestRoot.found) {
  23485. t = lowestRoot.root;
  23486. found = true;
  23487. this._collisionPoint.copyFrom(p2);
  23488. }
  23489. this._basePoint.subtractToRef(p3, this._tempVector);
  23490. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23491. c = this._tempVector.lengthSquared() - 1.0;
  23492. lowestRoot = getLowestRoot(a, b, c, t);
  23493. if (lowestRoot.found) {
  23494. t = lowestRoot.root;
  23495. found = true;
  23496. this._collisionPoint.copyFrom(p3);
  23497. }
  23498. p2.subtractToRef(p1, this._edge);
  23499. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23500. var edgeSquaredLength = this._edge.lengthSquared();
  23501. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23502. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23503. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23504. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23505. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23506. lowestRoot = getLowestRoot(a, b, c, t);
  23507. if (lowestRoot.found) {
  23508. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23509. if (f >= 0.0 && f <= 1.0) {
  23510. t = lowestRoot.root;
  23511. found = true;
  23512. this._edge.scaleInPlace(f);
  23513. p1.addToRef(this._edge, this._collisionPoint);
  23514. }
  23515. }
  23516. p3.subtractToRef(p2, this._edge);
  23517. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23518. edgeSquaredLength = this._edge.lengthSquared();
  23519. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23520. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23521. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23522. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23523. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23524. lowestRoot = getLowestRoot(a, b, c, t);
  23525. if (lowestRoot.found) {
  23526. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23527. if (f >= 0.0 && f <= 1.0) {
  23528. t = lowestRoot.root;
  23529. found = true;
  23530. this._edge.scaleInPlace(f);
  23531. p2.addToRef(this._edge, this._collisionPoint);
  23532. }
  23533. }
  23534. p1.subtractToRef(p3, this._edge);
  23535. p3.subtractToRef(this._basePoint, this._baseToVertex);
  23536. edgeSquaredLength = this._edge.lengthSquared();
  23537. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23538. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23539. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23540. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23541. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23542. lowestRoot = getLowestRoot(a, b, c, t);
  23543. if (lowestRoot.found) {
  23544. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23545. if (f >= 0.0 && f <= 1.0) {
  23546. t = lowestRoot.root;
  23547. found = true;
  23548. this._edge.scaleInPlace(f);
  23549. p3.addToRef(this._edge, this._collisionPoint);
  23550. }
  23551. }
  23552. }
  23553. if (found) {
  23554. var distToCollision = t * this._velocity.length();
  23555. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  23556. if (!this.intersectionPoint) {
  23557. this.intersectionPoint = this._collisionPoint.clone();
  23558. }
  23559. else {
  23560. this.intersectionPoint.copyFrom(this._collisionPoint);
  23561. }
  23562. this._nearestDistance = distToCollision;
  23563. this.collisionFound = true;
  23564. }
  23565. }
  23566. };
  23567. /** @hidden */
  23568. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  23569. for (var i = indexStart; i < indexEnd; i += 3) {
  23570. var p1 = pts[indices[i] - decal];
  23571. var p2 = pts[indices[i + 1] - decal];
  23572. var p3 = pts[indices[i + 2] - decal];
  23573. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  23574. }
  23575. };
  23576. /** @hidden */
  23577. Collider.prototype._getResponse = function (pos, vel) {
  23578. pos.addToRef(vel, this._destinationPoint);
  23579. vel.scaleInPlace((this._nearestDistance / vel.length()));
  23580. this._basePoint.addToRef(vel, pos);
  23581. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  23582. this._slidePlaneNormal.normalize();
  23583. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  23584. pos.addInPlace(this._displacementVector);
  23585. this.intersectionPoint.addInPlace(this._displacementVector);
  23586. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  23587. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  23588. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  23589. };
  23590. return Collider;
  23591. }());
  23592. /***/ }),
  23593. /***/ "./Collisions/collisionCoordinator.ts":
  23594. /*!********************************************!*\
  23595. !*** ./Collisions/collisionCoordinator.ts ***!
  23596. \********************************************/
  23597. /*! exports provided: DefaultCollisionCoordinator */
  23598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23599. "use strict";
  23600. __webpack_require__.r(__webpack_exports__);
  23601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  23602. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  23603. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23604. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  23605. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23606. /** @hidden */
  23607. var DefaultCollisionCoordinator = /** @class */ (function () {
  23608. function DefaultCollisionCoordinator() {
  23609. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23610. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23611. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23612. }
  23613. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  23614. position.divideToRef(collider._radius, this._scaledPosition);
  23615. displacement.divideToRef(collider._radius, this._scaledVelocity);
  23616. collider.collidedMesh = null;
  23617. collider._retry = 0;
  23618. collider._initialVelocity = this._scaledVelocity;
  23619. collider._initialPosition = this._scaledPosition;
  23620. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  23621. this._finalPosition.multiplyInPlace(collider._radius);
  23622. //run the callback
  23623. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  23624. };
  23625. DefaultCollisionCoordinator.prototype.createCollider = function () {
  23626. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  23627. };
  23628. DefaultCollisionCoordinator.prototype.init = function (scene) {
  23629. this._scene = scene;
  23630. };
  23631. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  23632. if (excludedMesh === void 0) { excludedMesh = null; }
  23633. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  23634. if (collider._retry >= maximumRetry) {
  23635. finalPosition.copyFrom(position);
  23636. return;
  23637. }
  23638. // Check if this is a mesh else camera or -1
  23639. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  23640. collider._initialize(position, velocity, closeDistance);
  23641. // Check all meshes
  23642. for (var index = 0; index < this._scene.meshes.length; index++) {
  23643. var mesh = this._scene.meshes[index];
  23644. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  23645. mesh._checkCollision(collider);
  23646. }
  23647. }
  23648. if (!collider.collisionFound) {
  23649. position.addToRef(velocity, finalPosition);
  23650. return;
  23651. }
  23652. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  23653. collider._getResponse(position, velocity);
  23654. }
  23655. if (velocity.length() <= closeDistance) {
  23656. finalPosition.copyFrom(position);
  23657. return;
  23658. }
  23659. collider._retry++;
  23660. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  23661. };
  23662. return DefaultCollisionCoordinator;
  23663. }());
  23664. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  23665. return new DefaultCollisionCoordinator();
  23666. };
  23667. /***/ }),
  23668. /***/ "./Collisions/index.ts":
  23669. /*!*****************************!*\
  23670. !*** ./Collisions/index.ts ***!
  23671. \*****************************/
  23672. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  23673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23674. "use strict";
  23675. __webpack_require__.r(__webpack_exports__);
  23676. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  23678. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  23679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  23680. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  23681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  23682. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  23683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  23684. /***/ }),
  23685. /***/ "./Collisions/intersectionInfo.ts":
  23686. /*!****************************************!*\
  23687. !*** ./Collisions/intersectionInfo.ts ***!
  23688. \****************************************/
  23689. /*! exports provided: IntersectionInfo */
  23690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23691. "use strict";
  23692. __webpack_require__.r(__webpack_exports__);
  23693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  23694. /**
  23695. * @hidden
  23696. */
  23697. var IntersectionInfo = /** @class */ (function () {
  23698. function IntersectionInfo(bu, bv, distance) {
  23699. this.bu = bu;
  23700. this.bv = bv;
  23701. this.distance = distance;
  23702. this.faceId = 0;
  23703. this.subMeshId = 0;
  23704. }
  23705. return IntersectionInfo;
  23706. }());
  23707. /***/ }),
  23708. /***/ "./Collisions/pickingInfo.ts":
  23709. /*!***********************************!*\
  23710. !*** ./Collisions/pickingInfo.ts ***!
  23711. \***********************************/
  23712. /*! exports provided: PickingInfo */
  23713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23714. "use strict";
  23715. __webpack_require__.r(__webpack_exports__);
  23716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  23717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23718. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  23719. /**
  23720. * Information about the result of picking within a scene
  23721. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23722. */
  23723. var PickingInfo = /** @class */ (function () {
  23724. function PickingInfo() {
  23725. /** @hidden */
  23726. this._pickingUnavailable = false;
  23727. /**
  23728. * If the pick collided with an object
  23729. */
  23730. this.hit = false;
  23731. /**
  23732. * Distance away where the pick collided
  23733. */
  23734. this.distance = 0;
  23735. /**
  23736. * The location of pick collision
  23737. */
  23738. this.pickedPoint = null;
  23739. /**
  23740. * The mesh corresponding the the pick collision
  23741. */
  23742. this.pickedMesh = null;
  23743. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23744. this.bu = 0;
  23745. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23746. this.bv = 0;
  23747. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23748. this.faceId = -1;
  23749. /** Id of the the submesh that was picked */
  23750. this.subMeshId = 0;
  23751. /** If a sprite was picked, this will be the sprite the pick collided with */
  23752. this.pickedSprite = null;
  23753. /**
  23754. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23755. */
  23756. this.originMesh = null;
  23757. /**
  23758. * The ray that was used to perform the picking.
  23759. */
  23760. this.ray = null;
  23761. }
  23762. /**
  23763. * Gets the normal correspodning to the face the pick collided with
  23764. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23765. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23766. * @returns The normal correspodning to the face the pick collided with
  23767. */
  23768. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23769. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23770. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23771. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23772. return null;
  23773. }
  23774. var indices = this.pickedMesh.getIndices();
  23775. if (!indices) {
  23776. return null;
  23777. }
  23778. var result;
  23779. if (useVerticesNormals) {
  23780. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23781. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23782. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23783. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23784. normal0 = normal0.scale(this.bu);
  23785. normal1 = normal1.scale(this.bv);
  23786. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23787. 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);
  23788. }
  23789. else {
  23790. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23791. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23792. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23793. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23794. var p1p2 = vertex1.subtract(vertex2);
  23795. var p3p2 = vertex3.subtract(vertex2);
  23796. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23797. }
  23798. if (useWorldCoordinates) {
  23799. var wm = this.pickedMesh.getWorldMatrix();
  23800. if (this.pickedMesh.nonUniformScaling) {
  23801. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23802. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23803. wm.setTranslationFromFloats(0, 0, 0);
  23804. wm.invert();
  23805. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23806. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23807. }
  23808. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23809. }
  23810. result.normalize();
  23811. return result;
  23812. };
  23813. /**
  23814. * Gets the texture coordinates of where the pick occured
  23815. * @returns the vector containing the coordnates of the texture
  23816. */
  23817. PickingInfo.prototype.getTextureCoordinates = function () {
  23818. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23819. return null;
  23820. }
  23821. var indices = this.pickedMesh.getIndices();
  23822. if (!indices) {
  23823. return null;
  23824. }
  23825. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23826. if (!uvs) {
  23827. return null;
  23828. }
  23829. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23830. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23831. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23832. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23833. uv1 = uv1.scale(this.bu);
  23834. uv2 = uv2.scale(this.bv);
  23835. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23836. };
  23837. return PickingInfo;
  23838. }());
  23839. /***/ }),
  23840. /***/ "./Culling/Octrees/index.ts":
  23841. /*!**********************************!*\
  23842. !*** ./Culling/Octrees/index.ts ***!
  23843. \**********************************/
  23844. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23846. "use strict";
  23847. __webpack_require__.r(__webpack_exports__);
  23848. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23850. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23852. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23854. /***/ }),
  23855. /***/ "./Culling/Octrees/octree.ts":
  23856. /*!***********************************!*\
  23857. !*** ./Culling/Octrees/octree.ts ***!
  23858. \***********************************/
  23859. /*! exports provided: Octree */
  23860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23861. "use strict";
  23862. __webpack_require__.r(__webpack_exports__);
  23863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23864. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23865. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23866. /**
  23867. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23869. */
  23870. var Octree = /** @class */ (function () {
  23871. /**
  23872. * Creates a octree
  23873. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23874. * @param creationFunc function to be used to instatiate the octree
  23875. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23876. * @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.)
  23877. */
  23878. function Octree(creationFunc, maxBlockCapacity,
  23879. /** 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.) */
  23880. maxDepth) {
  23881. if (maxDepth === void 0) { maxDepth = 2; }
  23882. this.maxDepth = maxDepth;
  23883. /**
  23884. * Content stored in the octree
  23885. */
  23886. this.dynamicContent = new Array();
  23887. this._maxBlockCapacity = maxBlockCapacity || 64;
  23888. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23889. this._creationFunc = creationFunc;
  23890. }
  23891. // Methods
  23892. /**
  23893. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23894. * @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);
  23895. * @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);
  23896. * @param entries meshes to be added to the octree blocks
  23897. */
  23898. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23899. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23900. };
  23901. /**
  23902. * Adds a mesh to the octree
  23903. * @param entry Mesh to add to the octree
  23904. */
  23905. Octree.prototype.addMesh = function (entry) {
  23906. for (var index = 0; index < this.blocks.length; index++) {
  23907. var block = this.blocks[index];
  23908. block.addEntry(entry);
  23909. }
  23910. };
  23911. /**
  23912. * Remove an element from the octree
  23913. * @param entry defines the element to remove
  23914. */
  23915. Octree.prototype.removeMesh = function (entry) {
  23916. for (var index = 0; index < this.blocks.length; index++) {
  23917. var block = this.blocks[index];
  23918. block.removeEntry(entry);
  23919. }
  23920. };
  23921. /**
  23922. * Selects an array of meshes within the frustum
  23923. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23924. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23925. * @returns array of meshes within the frustum
  23926. */
  23927. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23928. this._selectionContent.reset();
  23929. for (var index = 0; index < this.blocks.length; index++) {
  23930. var block = this.blocks[index];
  23931. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23932. }
  23933. if (allowDuplicate) {
  23934. this._selectionContent.concat(this.dynamicContent);
  23935. }
  23936. else {
  23937. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23938. }
  23939. return this._selectionContent;
  23940. };
  23941. /**
  23942. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23943. * @param sphereCenter defines the bounding sphere center
  23944. * @param sphereRadius defines the bounding sphere radius
  23945. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23946. * @returns an array of objects that intersect the sphere
  23947. */
  23948. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23949. this._selectionContent.reset();
  23950. for (var index = 0; index < this.blocks.length; index++) {
  23951. var block = this.blocks[index];
  23952. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23953. }
  23954. if (allowDuplicate) {
  23955. this._selectionContent.concat(this.dynamicContent);
  23956. }
  23957. else {
  23958. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23959. }
  23960. return this._selectionContent;
  23961. };
  23962. /**
  23963. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23964. * @param ray defines the ray to test with
  23965. * @returns array of intersected objects
  23966. */
  23967. Octree.prototype.intersectsRay = function (ray) {
  23968. this._selectionContent.reset();
  23969. for (var index = 0; index < this.blocks.length; index++) {
  23970. var block = this.blocks[index];
  23971. block.intersectsRay(ray, this._selectionContent);
  23972. }
  23973. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23974. return this._selectionContent;
  23975. };
  23976. /**
  23977. * Adds a mesh into the octree block if it intersects the block
  23978. */
  23979. Octree.CreationFuncForMeshes = function (entry, block) {
  23980. var boundingInfo = entry.getBoundingInfo();
  23981. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23982. block.entries.push(entry);
  23983. }
  23984. };
  23985. /**
  23986. * Adds a submesh into the octree block if it intersects the block
  23987. */
  23988. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23989. var boundingInfo = entry.getBoundingInfo();
  23990. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23991. block.entries.push(entry);
  23992. }
  23993. };
  23994. return Octree;
  23995. }());
  23996. /***/ }),
  23997. /***/ "./Culling/Octrees/octreeBlock.ts":
  23998. /*!****************************************!*\
  23999. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24000. \****************************************/
  24001. /*! exports provided: OctreeBlock */
  24002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24003. "use strict";
  24004. __webpack_require__.r(__webpack_exports__);
  24005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24006. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24007. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24008. /**
  24009. * Class used to store a cell in an octree
  24010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24011. */
  24012. var OctreeBlock = /** @class */ (function () {
  24013. /**
  24014. * Creates a new block
  24015. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24016. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24017. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24018. * @param depth defines the current depth of this block in the octree
  24019. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24020. * @param creationFunc defines a callback to call when an element is added to the block
  24021. */
  24022. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24023. /**
  24024. * Gets the content of the current block
  24025. */
  24026. this.entries = new Array();
  24027. this._boundingVectors = new Array();
  24028. this._capacity = capacity;
  24029. this._depth = depth;
  24030. this._maxDepth = maxDepth;
  24031. this._creationFunc = creationFunc;
  24032. this._minPoint = minPoint;
  24033. this._maxPoint = maxPoint;
  24034. this._boundingVectors.push(minPoint.clone());
  24035. this._boundingVectors.push(maxPoint.clone());
  24036. this._boundingVectors.push(minPoint.clone());
  24037. this._boundingVectors[2].x = maxPoint.x;
  24038. this._boundingVectors.push(minPoint.clone());
  24039. this._boundingVectors[3].y = maxPoint.y;
  24040. this._boundingVectors.push(minPoint.clone());
  24041. this._boundingVectors[4].z = maxPoint.z;
  24042. this._boundingVectors.push(maxPoint.clone());
  24043. this._boundingVectors[5].z = minPoint.z;
  24044. this._boundingVectors.push(maxPoint.clone());
  24045. this._boundingVectors[6].x = minPoint.x;
  24046. this._boundingVectors.push(maxPoint.clone());
  24047. this._boundingVectors[7].y = minPoint.y;
  24048. }
  24049. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24050. // Property
  24051. /**
  24052. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24053. */
  24054. get: function () {
  24055. return this._capacity;
  24056. },
  24057. enumerable: true,
  24058. configurable: true
  24059. });
  24060. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24061. /**
  24062. * Gets the minimum vector (in world space) of the block's bounding box
  24063. */
  24064. get: function () {
  24065. return this._minPoint;
  24066. },
  24067. enumerable: true,
  24068. configurable: true
  24069. });
  24070. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24071. /**
  24072. * Gets the maximum vector (in world space) of the block's bounding box
  24073. */
  24074. get: function () {
  24075. return this._maxPoint;
  24076. },
  24077. enumerable: true,
  24078. configurable: true
  24079. });
  24080. // Methods
  24081. /**
  24082. * Add a new element to this block
  24083. * @param entry defines the element to add
  24084. */
  24085. OctreeBlock.prototype.addEntry = function (entry) {
  24086. if (this.blocks) {
  24087. for (var index = 0; index < this.blocks.length; index++) {
  24088. var block = this.blocks[index];
  24089. block.addEntry(entry);
  24090. }
  24091. return;
  24092. }
  24093. this._creationFunc(entry, this);
  24094. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24095. this.createInnerBlocks();
  24096. }
  24097. };
  24098. /**
  24099. * Remove an element from this block
  24100. * @param entry defines the element to remove
  24101. */
  24102. OctreeBlock.prototype.removeEntry = function (entry) {
  24103. if (this.blocks) {
  24104. for (var index = 0; index < this.blocks.length; index++) {
  24105. var block = this.blocks[index];
  24106. block.removeEntry(entry);
  24107. }
  24108. return;
  24109. }
  24110. var entryIndex = this.entries.indexOf(entry);
  24111. if (entryIndex > -1) {
  24112. this.entries.splice(entryIndex, 1);
  24113. }
  24114. };
  24115. /**
  24116. * Add an array of elements to this block
  24117. * @param entries defines the array of elements to add
  24118. */
  24119. OctreeBlock.prototype.addEntries = function (entries) {
  24120. for (var index = 0; index < entries.length; index++) {
  24121. var mesh = entries[index];
  24122. this.addEntry(mesh);
  24123. }
  24124. };
  24125. /**
  24126. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24127. * @param frustumPlanes defines the frustum planes to test
  24128. * @param selection defines the array to store current content if selection is positive
  24129. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24130. */
  24131. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24132. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24133. if (this.blocks) {
  24134. for (var index = 0; index < this.blocks.length; index++) {
  24135. var block = this.blocks[index];
  24136. block.select(frustumPlanes, selection, allowDuplicate);
  24137. }
  24138. return;
  24139. }
  24140. if (allowDuplicate) {
  24141. selection.concat(this.entries);
  24142. }
  24143. else {
  24144. selection.concatWithNoDuplicate(this.entries);
  24145. }
  24146. }
  24147. };
  24148. /**
  24149. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24150. * @param sphereCenter defines the bounding sphere center
  24151. * @param sphereRadius defines the bounding sphere radius
  24152. * @param selection defines the array to store current content if selection is positive
  24153. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24154. */
  24155. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24156. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24157. if (this.blocks) {
  24158. for (var index = 0; index < this.blocks.length; index++) {
  24159. var block = this.blocks[index];
  24160. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24161. }
  24162. return;
  24163. }
  24164. if (allowDuplicate) {
  24165. selection.concat(this.entries);
  24166. }
  24167. else {
  24168. selection.concatWithNoDuplicate(this.entries);
  24169. }
  24170. }
  24171. };
  24172. /**
  24173. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24174. * @param ray defines the ray to test with
  24175. * @param selection defines the array to store current content if selection is positive
  24176. */
  24177. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24178. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24179. if (this.blocks) {
  24180. for (var index = 0; index < this.blocks.length; index++) {
  24181. var block = this.blocks[index];
  24182. block.intersectsRay(ray, selection);
  24183. }
  24184. return;
  24185. }
  24186. selection.concatWithNoDuplicate(this.entries);
  24187. }
  24188. };
  24189. /**
  24190. * Subdivide the content into child blocks (this block will then be empty)
  24191. */
  24192. OctreeBlock.prototype.createInnerBlocks = function () {
  24193. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24194. };
  24195. /**
  24196. * @hidden
  24197. */
  24198. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24199. target.blocks = new Array();
  24200. 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);
  24201. // Segmenting space
  24202. for (var x = 0; x < 2; x++) {
  24203. for (var y = 0; y < 2; y++) {
  24204. for (var z = 0; z < 2; z++) {
  24205. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24206. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24207. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24208. block.addEntries(entries);
  24209. target.blocks.push(block);
  24210. }
  24211. }
  24212. }
  24213. };
  24214. return OctreeBlock;
  24215. }());
  24216. /***/ }),
  24217. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24218. /*!*************************************************!*\
  24219. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24220. \*************************************************/
  24221. /*! exports provided: OctreeSceneComponent */
  24222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24223. "use strict";
  24224. __webpack_require__.r(__webpack_exports__);
  24225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24226. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24227. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24228. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24229. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24230. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24231. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24232. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24233. if (maxCapacity === void 0) { maxCapacity = 64; }
  24234. if (maxDepth === void 0) { maxDepth = 2; }
  24235. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24236. if (!component) {
  24237. component = new OctreeSceneComponent(this);
  24238. this._addComponent(component);
  24239. }
  24240. if (!this._selectionOctree) {
  24241. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24242. }
  24243. var worldExtends = this.getWorldExtends();
  24244. // Update octree
  24245. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24246. return this._selectionOctree;
  24247. };
  24248. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24249. get: function () {
  24250. return this._selectionOctree;
  24251. },
  24252. enumerable: true,
  24253. configurable: true
  24254. });
  24255. /**
  24256. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24257. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24258. * @param maxCapacity defines the maximum size of each block (64 by default)
  24259. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24260. * @returns the new octree
  24261. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24262. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24263. */
  24264. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24265. if (maxCapacity === void 0) { maxCapacity = 64; }
  24266. if (maxDepth === void 0) { maxDepth = 2; }
  24267. var scene = this.getScene();
  24268. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24269. if (!component) {
  24270. component = new OctreeSceneComponent(scene);
  24271. scene._addComponent(component);
  24272. }
  24273. if (!this._submeshesOctree) {
  24274. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24275. }
  24276. this.computeWorldMatrix(true);
  24277. var boundingInfo = this.getBoundingInfo();
  24278. // Update octree
  24279. var bbox = boundingInfo.boundingBox;
  24280. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24281. return this._submeshesOctree;
  24282. };
  24283. /**
  24284. * Defines the octree scene component responsible to manage any octrees
  24285. * in a given scene.
  24286. */
  24287. var OctreeSceneComponent = /** @class */ (function () {
  24288. /**
  24289. * Creates a new instance of the component for the given scene
  24290. * @param scene Defines the scene to register the component in
  24291. */
  24292. function OctreeSceneComponent(scene) {
  24293. /**
  24294. * The component name helpfull to identify the component in the list of scene components.
  24295. */
  24296. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24297. /**
  24298. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24299. */
  24300. this.checksIsEnabled = true;
  24301. 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));
  24302. this.scene = scene;
  24303. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24304. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24305. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24306. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24307. }
  24308. /**
  24309. * Registers the component in a given scene
  24310. */
  24311. OctreeSceneComponent.prototype.register = function () {
  24312. var _this = this;
  24313. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24314. var sceneOctree = _this.scene.selectionOctree;
  24315. if (sceneOctree !== undefined && sceneOctree !== null) {
  24316. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24317. if (index !== -1) {
  24318. sceneOctree.dynamicContent.splice(index, 1);
  24319. }
  24320. }
  24321. });
  24322. this.scene.onMeshImportedObservable.add(function (mesh) {
  24323. var sceneOctree = _this.scene.selectionOctree;
  24324. if (sceneOctree !== undefined && sceneOctree !== null) {
  24325. sceneOctree.addMesh(mesh);
  24326. }
  24327. });
  24328. };
  24329. /**
  24330. * Return the list of active meshes
  24331. * @returns the list of active meshes
  24332. */
  24333. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24334. if (this.scene._selectionOctree) {
  24335. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24336. return selection;
  24337. }
  24338. return this.scene._getDefaultMeshCandidates();
  24339. };
  24340. /**
  24341. * Return the list of active sub meshes
  24342. * @param mesh The mesh to get the candidates sub meshes from
  24343. * @returns the list of active sub meshes
  24344. */
  24345. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24346. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24347. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24348. return intersections;
  24349. }
  24350. return this.scene._getDefaultSubMeshCandidates(mesh);
  24351. };
  24352. /**
  24353. * Return the list of sub meshes intersecting with a given local ray
  24354. * @param mesh defines the mesh to find the submesh for
  24355. * @param localRay defines the ray in local space
  24356. * @returns the list of intersecting sub meshes
  24357. */
  24358. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24359. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24360. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24361. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24362. return intersections;
  24363. }
  24364. return this.scene._getDefaultSubMeshCandidates(mesh);
  24365. };
  24366. /**
  24367. * Return the list of sub meshes colliding with a collider
  24368. * @param mesh defines the mesh to find the submesh for
  24369. * @param collider defines the collider to evaluate the collision against
  24370. * @returns the list of colliding sub meshes
  24371. */
  24372. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24373. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24374. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24375. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24376. return intersections;
  24377. }
  24378. return this.scene._getDefaultSubMeshCandidates(mesh);
  24379. };
  24380. /**
  24381. * Rebuilds the elements related to this component in case of
  24382. * context lost for instance.
  24383. */
  24384. OctreeSceneComponent.prototype.rebuild = function () {
  24385. // Nothing to do here.
  24386. };
  24387. /**
  24388. * Disposes the component and the associated ressources.
  24389. */
  24390. OctreeSceneComponent.prototype.dispose = function () {
  24391. // Nothing to do here.
  24392. };
  24393. return OctreeSceneComponent;
  24394. }());
  24395. /***/ }),
  24396. /***/ "./Culling/boundingBox.ts":
  24397. /*!********************************!*\
  24398. !*** ./Culling/boundingBox.ts ***!
  24399. \********************************/
  24400. /*! exports provided: BoundingBox */
  24401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24402. "use strict";
  24403. __webpack_require__.r(__webpack_exports__);
  24404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24405. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24406. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24407. /**
  24408. * Class used to store bounding box information
  24409. */
  24410. var BoundingBox = /** @class */ (function () {
  24411. /**
  24412. * Creates a new bounding box
  24413. * @param min defines the minimum vector (in local space)
  24414. * @param max defines the maximum vector (in local space)
  24415. * @param worldMatrix defines the new world matrix
  24416. */
  24417. function BoundingBox(min, max, worldMatrix) {
  24418. /**
  24419. * Gets the 8 vectors representing the bounding box in local space
  24420. */
  24421. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24422. /**
  24423. * Gets the center of the bounding box in local space
  24424. */
  24425. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24426. /**
  24427. * Gets the center of the bounding box in world space
  24428. */
  24429. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24430. /**
  24431. * Gets the extend size in local space
  24432. */
  24433. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24434. /**
  24435. * Gets the extend size in world space
  24436. */
  24437. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24438. /**
  24439. * Gets the OBB (object bounding box) directions
  24440. */
  24441. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24442. /**
  24443. * Gets the 8 vectors representing the bounding box in world space
  24444. */
  24445. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24446. /**
  24447. * Gets the minimum vector in world space
  24448. */
  24449. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24450. /**
  24451. * Gets the maximum vector in world space
  24452. */
  24453. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24454. /**
  24455. * Gets the minimum vector in local space
  24456. */
  24457. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24458. /**
  24459. * Gets the maximum vector in local space
  24460. */
  24461. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24462. this.reConstruct(min, max, worldMatrix);
  24463. }
  24464. // Methods
  24465. /**
  24466. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24467. * @param min defines the new minimum vector (in local space)
  24468. * @param max defines the new maximum vector (in local space)
  24469. * @param worldMatrix defines the new world matrix
  24470. */
  24471. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24472. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24473. var vectors = this.vectors;
  24474. this.minimum.copyFromFloats(minX, minY, minZ);
  24475. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24476. vectors[0].copyFromFloats(minX, minY, minZ);
  24477. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24478. vectors[2].copyFromFloats(maxX, minY, minZ);
  24479. vectors[3].copyFromFloats(minX, maxY, minZ);
  24480. vectors[4].copyFromFloats(minX, minY, maxZ);
  24481. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24482. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24483. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24484. // OBB
  24485. max.addToRef(min, this.center).scaleInPlace(0.5);
  24486. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24487. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24488. };
  24489. /**
  24490. * Scale the current bounding box by applying a scale factor
  24491. * @param factor defines the scale factor to apply
  24492. * @returns the current bounding box
  24493. */
  24494. BoundingBox.prototype.scale = function (factor) {
  24495. var tmpVectors = BoundingBox.TmpVector3;
  24496. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24497. var len = diff.length();
  24498. diff.normalizeFromLength(len);
  24499. var distance = len * factor;
  24500. var newRadius = diff.scaleInPlace(distance * 0.5);
  24501. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24502. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24503. this.reConstruct(min, max, this._worldMatrix);
  24504. return this;
  24505. };
  24506. /**
  24507. * Gets the world matrix of the bounding box
  24508. * @returns a matrix
  24509. */
  24510. BoundingBox.prototype.getWorldMatrix = function () {
  24511. return this._worldMatrix;
  24512. };
  24513. /** @hidden */
  24514. BoundingBox.prototype._update = function (world) {
  24515. var minWorld = this.minimumWorld;
  24516. var maxWorld = this.maximumWorld;
  24517. var directions = this.directions;
  24518. var vectorsWorld = this.vectorsWorld;
  24519. var vectors = this.vectors;
  24520. if (!world.isIdentity()) {
  24521. minWorld.setAll(Number.MAX_VALUE);
  24522. maxWorld.setAll(-Number.MAX_VALUE);
  24523. for (var index = 0; index < 8; ++index) {
  24524. var v = vectorsWorld[index];
  24525. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  24526. minWorld.minimizeInPlace(v);
  24527. maxWorld.maximizeInPlace(v);
  24528. }
  24529. // Extend
  24530. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  24531. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  24532. }
  24533. else {
  24534. minWorld.copyFrom(this.minimum);
  24535. maxWorld.copyFrom(this.maximum);
  24536. for (var index = 0; index < 8; ++index) {
  24537. vectorsWorld[index].copyFrom(vectors[index]);
  24538. }
  24539. // Extend
  24540. this.extendSizeWorld.copyFrom(this.extendSize);
  24541. this.centerWorld.copyFrom(this.center);
  24542. }
  24543. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  24544. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  24545. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  24546. this._worldMatrix = world;
  24547. };
  24548. /**
  24549. * Tests if the bounding box is intersecting the frustum planes
  24550. * @param frustumPlanes defines the frustum planes to test
  24551. * @returns true if there is an intersection
  24552. */
  24553. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  24554. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  24555. };
  24556. /**
  24557. * Tests if the bounding box is entirely inside the frustum planes
  24558. * @param frustumPlanes defines the frustum planes to test
  24559. * @returns true if there is an inclusion
  24560. */
  24561. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24562. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  24563. };
  24564. /**
  24565. * Tests if a point is inside the bounding box
  24566. * @param point defines the point to test
  24567. * @returns true if the point is inside the bounding box
  24568. */
  24569. BoundingBox.prototype.intersectsPoint = function (point) {
  24570. var min = this.minimumWorld;
  24571. var max = this.maximumWorld;
  24572. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24573. var pointX = point.x, pointY = point.y, pointZ = point.z;
  24574. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  24575. if (maxX - pointX < delta || delta > pointX - minX) {
  24576. return false;
  24577. }
  24578. if (maxY - pointY < delta || delta > pointY - minY) {
  24579. return false;
  24580. }
  24581. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  24582. return false;
  24583. }
  24584. return true;
  24585. };
  24586. /**
  24587. * Tests if the bounding box intersects with a bounding sphere
  24588. * @param sphere defines the sphere to test
  24589. * @returns true if there is an intersection
  24590. */
  24591. BoundingBox.prototype.intersectsSphere = function (sphere) {
  24592. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  24593. };
  24594. /**
  24595. * Tests if the bounding box intersects with a box defined by a min and max vectors
  24596. * @param min defines the min vector to use
  24597. * @param max defines the max vector to use
  24598. * @returns true if there is an intersection
  24599. */
  24600. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  24601. var myMin = this.minimumWorld;
  24602. var myMax = this.maximumWorld;
  24603. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  24604. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24605. if (myMaxX < minX || myMinX > maxX) {
  24606. return false;
  24607. }
  24608. if (myMaxY < minY || myMinY > maxY) {
  24609. return false;
  24610. }
  24611. if (myMaxZ < minZ || myMinZ > maxZ) {
  24612. return false;
  24613. }
  24614. return true;
  24615. };
  24616. // Statics
  24617. /**
  24618. * Tests if two bounding boxes are intersections
  24619. * @param box0 defines the first box to test
  24620. * @param box1 defines the second box to test
  24621. * @returns true if there is an intersection
  24622. */
  24623. BoundingBox.Intersects = function (box0, box1) {
  24624. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  24625. };
  24626. /**
  24627. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  24628. * @param minPoint defines the minimum vector of the bounding box
  24629. * @param maxPoint defines the maximum vector of the bounding box
  24630. * @param sphereCenter defines the sphere center
  24631. * @param sphereRadius defines the sphere radius
  24632. * @returns true if there is an intersection
  24633. */
  24634. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  24635. var vector = BoundingBox.TmpVector3[0];
  24636. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  24637. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  24638. return (num <= (sphereRadius * sphereRadius));
  24639. };
  24640. /**
  24641. * Tests if a bounding box defined with 8 vectors is entirely inside 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 inclusion
  24645. */
  24646. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  24647. for (var p = 0; p < 6; ++p) {
  24648. var frustumPlane = frustumPlanes[p];
  24649. for (var i = 0; i < 8; ++i) {
  24650. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  24651. return false;
  24652. }
  24653. }
  24654. }
  24655. return true;
  24656. };
  24657. /**
  24658. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  24659. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24660. * @param frustumPlanes defines the frustum planes to test
  24661. * @return true if there is an intersection
  24662. */
  24663. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  24664. for (var p = 0; p < 6; ++p) {
  24665. var canReturnFalse = true;
  24666. var frustumPlane = frustumPlanes[p];
  24667. for (var i = 0; i < 8; ++i) {
  24668. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  24669. canReturnFalse = false;
  24670. break;
  24671. }
  24672. }
  24673. if (canReturnFalse) {
  24674. return false;
  24675. }
  24676. }
  24677. return true;
  24678. };
  24679. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24680. return BoundingBox;
  24681. }());
  24682. /***/ }),
  24683. /***/ "./Culling/boundingInfo.ts":
  24684. /*!*********************************!*\
  24685. !*** ./Culling/boundingInfo.ts ***!
  24686. \*********************************/
  24687. /*! exports provided: BoundingInfo */
  24688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24689. "use strict";
  24690. __webpack_require__.r(__webpack_exports__);
  24691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  24692. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24693. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24694. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  24695. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24696. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24697. var _result0 = { min: 0, max: 0 };
  24698. var _result1 = { min: 0, max: 0 };
  24699. var computeBoxExtents = function (axis, box, result) {
  24700. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  24701. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  24702. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  24703. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  24704. var r = r0 + r1 + r2;
  24705. result.min = p - r;
  24706. result.max = p + r;
  24707. };
  24708. var axisOverlap = function (axis, box0, box1) {
  24709. computeBoxExtents(axis, box0, _result0);
  24710. computeBoxExtents(axis, box1, _result1);
  24711. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  24712. };
  24713. /**
  24714. * Info for a bounding data of a mesh
  24715. */
  24716. var BoundingInfo = /** @class */ (function () {
  24717. /**
  24718. * Constructs bounding info
  24719. * @param minimum min vector of the bounding box/sphere
  24720. * @param maximum max vector of the bounding box/sphere
  24721. * @param worldMatrix defines the new world matrix
  24722. */
  24723. function BoundingInfo(minimum, maximum, worldMatrix) {
  24724. this._isLocked = false;
  24725. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24726. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24727. }
  24728. /**
  24729. * Recreates the entire bounding info from scratch as if we call the constructor in place
  24730. * @param min defines the new minimum vector (in local space)
  24731. * @param max defines the new maximum vector (in local space)
  24732. * @param worldMatrix defines the new world matrix
  24733. */
  24734. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24735. this.boundingBox.reConstruct(min, max, worldMatrix);
  24736. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24737. };
  24738. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24739. /**
  24740. * min vector of the bounding box/sphere
  24741. */
  24742. get: function () {
  24743. return this.boundingBox.minimum;
  24744. },
  24745. enumerable: true,
  24746. configurable: true
  24747. });
  24748. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24749. /**
  24750. * max vector of the bounding box/sphere
  24751. */
  24752. get: function () {
  24753. return this.boundingBox.maximum;
  24754. },
  24755. enumerable: true,
  24756. configurable: true
  24757. });
  24758. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24759. /**
  24760. * If the info is locked and won't be updated to avoid perf overhead
  24761. */
  24762. get: function () {
  24763. return this._isLocked;
  24764. },
  24765. set: function (value) {
  24766. this._isLocked = value;
  24767. },
  24768. enumerable: true,
  24769. configurable: true
  24770. });
  24771. // Methods
  24772. /**
  24773. * Updates the bounding sphere and box
  24774. * @param world world matrix to be used to update
  24775. */
  24776. BoundingInfo.prototype.update = function (world) {
  24777. if (this._isLocked) {
  24778. return;
  24779. }
  24780. this.boundingBox._update(world);
  24781. this.boundingSphere._update(world);
  24782. };
  24783. /**
  24784. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24785. * @param center New center of the bounding info
  24786. * @param extend New extend of the bounding info
  24787. * @returns the current bounding info
  24788. */
  24789. BoundingInfo.prototype.centerOn = function (center, extend) {
  24790. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24791. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24792. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24793. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24794. return this;
  24795. };
  24796. /**
  24797. * Scale the current bounding info by applying a scale factor
  24798. * @param factor defines the scale factor to apply
  24799. * @returns the current bounding info
  24800. */
  24801. BoundingInfo.prototype.scale = function (factor) {
  24802. this.boundingBox.scale(factor);
  24803. this.boundingSphere.scale(factor);
  24804. return this;
  24805. };
  24806. /**
  24807. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24808. * @param frustumPlanes defines the frustum to test
  24809. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24810. * @returns true if the bounding info is in the frustum planes
  24811. */
  24812. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24813. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24814. 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);
  24815. if (inclusionTest) {
  24816. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24817. return true;
  24818. }
  24819. }
  24820. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24821. return false;
  24822. }
  24823. 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);
  24824. if (bSphereOnlyTest) {
  24825. return true;
  24826. }
  24827. return this.boundingBox.isInFrustum(frustumPlanes);
  24828. };
  24829. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24830. /**
  24831. * Gets the world distance between the min and max points of the bounding box
  24832. */
  24833. get: function () {
  24834. var boundingBox = this.boundingBox;
  24835. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24836. return diag.length();
  24837. },
  24838. enumerable: true,
  24839. configurable: true
  24840. });
  24841. /**
  24842. * Checks if a cullable object (mesh...) is in the camera frustum
  24843. * Unlike isInFrustum this cheks the full bounding box
  24844. * @param frustumPlanes Camera near/planes
  24845. * @returns true if the object is in frustum otherwise false
  24846. */
  24847. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24848. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24849. };
  24850. /** @hidden */
  24851. BoundingInfo.prototype._checkCollision = function (collider) {
  24852. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24853. };
  24854. /**
  24855. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24856. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24857. * @param point the point to check intersection with
  24858. * @returns if the point intersects
  24859. */
  24860. BoundingInfo.prototype.intersectsPoint = function (point) {
  24861. if (!this.boundingSphere.centerWorld) {
  24862. return false;
  24863. }
  24864. if (!this.boundingSphere.intersectsPoint(point)) {
  24865. return false;
  24866. }
  24867. if (!this.boundingBox.intersectsPoint(point)) {
  24868. return false;
  24869. }
  24870. return true;
  24871. };
  24872. /**
  24873. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24874. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24875. * @param boundingInfo the bounding info to check intersection with
  24876. * @param precise if the intersection should be done using OBB
  24877. * @returns if the bounding info intersects
  24878. */
  24879. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24880. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24881. return false;
  24882. }
  24883. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24884. return false;
  24885. }
  24886. if (!precise) {
  24887. return true;
  24888. }
  24889. var box0 = this.boundingBox;
  24890. var box1 = boundingInfo.boundingBox;
  24891. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24892. return false;
  24893. }
  24894. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24895. return false;
  24896. }
  24897. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24898. return false;
  24899. }
  24900. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24901. return false;
  24902. }
  24903. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24904. return false;
  24905. }
  24906. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24907. return false;
  24908. }
  24909. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24910. return false;
  24911. }
  24912. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24913. return false;
  24914. }
  24915. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24916. return false;
  24917. }
  24918. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24919. return false;
  24920. }
  24921. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24922. return false;
  24923. }
  24924. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24925. return false;
  24926. }
  24927. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24928. return false;
  24929. }
  24930. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24931. return false;
  24932. }
  24933. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24934. return false;
  24935. }
  24936. return true;
  24937. };
  24938. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24939. return BoundingInfo;
  24940. }());
  24941. /***/ }),
  24942. /***/ "./Culling/boundingSphere.ts":
  24943. /*!***********************************!*\
  24944. !*** ./Culling/boundingSphere.ts ***!
  24945. \***********************************/
  24946. /*! exports provided: BoundingSphere */
  24947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24948. "use strict";
  24949. __webpack_require__.r(__webpack_exports__);
  24950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24951. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24952. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24953. /**
  24954. * Class used to store bounding sphere information
  24955. */
  24956. var BoundingSphere = /** @class */ (function () {
  24957. /**
  24958. * Creates a new bounding sphere
  24959. * @param min defines the minimum vector (in local space)
  24960. * @param max defines the maximum vector (in local space)
  24961. * @param worldMatrix defines the new world matrix
  24962. */
  24963. function BoundingSphere(min, max, worldMatrix) {
  24964. /**
  24965. * Gets the center of the bounding sphere in local space
  24966. */
  24967. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24968. /**
  24969. * Gets the center of the bounding sphere in world space
  24970. */
  24971. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24972. /**
  24973. * Gets the minimum vector in local space
  24974. */
  24975. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24976. /**
  24977. * Gets the maximum vector in local space
  24978. */
  24979. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24980. this.reConstruct(min, max, worldMatrix);
  24981. }
  24982. /**
  24983. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24984. * @param min defines the new minimum vector (in local space)
  24985. * @param max defines the new maximum vector (in local space)
  24986. * @param worldMatrix defines the new world matrix
  24987. */
  24988. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24989. this.minimum.copyFrom(min);
  24990. this.maximum.copyFrom(max);
  24991. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24992. max.addToRef(min, this.center).scaleInPlace(0.5);
  24993. this.radius = distance * 0.5;
  24994. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24995. };
  24996. /**
  24997. * Scale the current bounding sphere by applying a scale factor
  24998. * @param factor defines the scale factor to apply
  24999. * @returns the current bounding box
  25000. */
  25001. BoundingSphere.prototype.scale = function (factor) {
  25002. var newRadius = this.radius * factor;
  25003. var tmpVectors = BoundingSphere.TmpVector3;
  25004. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25005. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25006. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25007. this.reConstruct(min, max, this._worldMatrix);
  25008. return this;
  25009. };
  25010. /**
  25011. * Gets the world matrix of the bounding box
  25012. * @returns a matrix
  25013. */
  25014. BoundingSphere.prototype.getWorldMatrix = function () {
  25015. return this._worldMatrix;
  25016. };
  25017. // Methods
  25018. /** @hidden */
  25019. BoundingSphere.prototype._update = function (worldMatrix) {
  25020. if (!worldMatrix.isIdentity()) {
  25021. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25022. var tempVector = BoundingSphere.TmpVector3[0];
  25023. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25024. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25025. }
  25026. else {
  25027. this.centerWorld.copyFrom(this.center);
  25028. this.radiusWorld = this.radius;
  25029. }
  25030. };
  25031. /**
  25032. * Tests if the bounding sphere is intersecting the frustum planes
  25033. * @param frustumPlanes defines the frustum planes to test
  25034. * @returns true if there is an intersection
  25035. */
  25036. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25037. var center = this.centerWorld;
  25038. var radius = this.radiusWorld;
  25039. for (var i = 0; i < 6; i++) {
  25040. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25041. return false;
  25042. }
  25043. }
  25044. return true;
  25045. };
  25046. /**
  25047. * Tests if the bounding sphere center is in between the frustum planes.
  25048. * Used for optimistic fast inclusion.
  25049. * @param frustumPlanes defines the frustum planes to test
  25050. * @returns true if the sphere center is in between the frustum planes
  25051. */
  25052. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25053. var center = this.centerWorld;
  25054. for (var i = 0; i < 6; i++) {
  25055. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25056. return false;
  25057. }
  25058. }
  25059. return true;
  25060. };
  25061. /**
  25062. * Tests if a point is inside the bounding sphere
  25063. * @param point defines the point to test
  25064. * @returns true if the point is inside the bounding sphere
  25065. */
  25066. BoundingSphere.prototype.intersectsPoint = function (point) {
  25067. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25068. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25069. return false;
  25070. }
  25071. return true;
  25072. };
  25073. // Statics
  25074. /**
  25075. * Checks if two sphere intersct
  25076. * @param sphere0 sphere 0
  25077. * @param sphere1 sphere 1
  25078. * @returns true if the speres intersect
  25079. */
  25080. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25081. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25082. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25083. if (radiusSum * radiusSum < squareDistance) {
  25084. return false;
  25085. }
  25086. return true;
  25087. };
  25088. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25089. return BoundingSphere;
  25090. }());
  25091. /***/ }),
  25092. /***/ "./Culling/index.ts":
  25093. /*!**************************!*\
  25094. !*** ./Culling/index.ts ***!
  25095. \**************************/
  25096. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25098. "use strict";
  25099. __webpack_require__.r(__webpack_exports__);
  25100. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25102. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25104. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25106. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25110. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25112. /***/ }),
  25113. /***/ "./Culling/ray.ts":
  25114. /*!************************!*\
  25115. !*** ./Culling/ray.ts ***!
  25116. \************************/
  25117. /*! exports provided: Ray */
  25118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25119. "use strict";
  25120. __webpack_require__.r(__webpack_exports__);
  25121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25122. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25123. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25124. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25125. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25126. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25127. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25128. /**
  25129. * Class representing a ray with position and direction
  25130. */
  25131. var Ray = /** @class */ (function () {
  25132. /**
  25133. * Creates a new ray
  25134. * @param origin origin point
  25135. * @param direction direction
  25136. * @param length length of the ray
  25137. */
  25138. function Ray(
  25139. /** origin point */
  25140. origin,
  25141. /** direction */
  25142. direction,
  25143. /** length of the ray */
  25144. length) {
  25145. if (length === void 0) { length = Number.MAX_VALUE; }
  25146. this.origin = origin;
  25147. this.direction = direction;
  25148. this.length = length;
  25149. }
  25150. // Methods
  25151. /**
  25152. * Checks if the ray intersects a box
  25153. * @param minimum bound of the box
  25154. * @param maximum bound of the box
  25155. * @param intersectionTreshold extra extend to be added to the box in all direction
  25156. * @returns if the box was hit
  25157. */
  25158. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25159. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25160. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25161. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25162. var d = 0.0;
  25163. var maxValue = Number.MAX_VALUE;
  25164. var inv;
  25165. var min;
  25166. var max;
  25167. var temp;
  25168. if (Math.abs(this.direction.x) < 0.0000001) {
  25169. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25170. return false;
  25171. }
  25172. }
  25173. else {
  25174. inv = 1.0 / this.direction.x;
  25175. min = (newMinimum.x - this.origin.x) * inv;
  25176. max = (newMaximum.x - this.origin.x) * inv;
  25177. if (max === -Infinity) {
  25178. max = Infinity;
  25179. }
  25180. if (min > max) {
  25181. temp = min;
  25182. min = max;
  25183. max = temp;
  25184. }
  25185. d = Math.max(min, d);
  25186. maxValue = Math.min(max, maxValue);
  25187. if (d > maxValue) {
  25188. return false;
  25189. }
  25190. }
  25191. if (Math.abs(this.direction.y) < 0.0000001) {
  25192. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25193. return false;
  25194. }
  25195. }
  25196. else {
  25197. inv = 1.0 / this.direction.y;
  25198. min = (newMinimum.y - this.origin.y) * inv;
  25199. max = (newMaximum.y - this.origin.y) * inv;
  25200. if (max === -Infinity) {
  25201. max = Infinity;
  25202. }
  25203. if (min > max) {
  25204. temp = min;
  25205. min = max;
  25206. max = temp;
  25207. }
  25208. d = Math.max(min, d);
  25209. maxValue = Math.min(max, maxValue);
  25210. if (d > maxValue) {
  25211. return false;
  25212. }
  25213. }
  25214. if (Math.abs(this.direction.z) < 0.0000001) {
  25215. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25216. return false;
  25217. }
  25218. }
  25219. else {
  25220. inv = 1.0 / this.direction.z;
  25221. min = (newMinimum.z - this.origin.z) * inv;
  25222. max = (newMaximum.z - this.origin.z) * inv;
  25223. if (max === -Infinity) {
  25224. max = Infinity;
  25225. }
  25226. if (min > max) {
  25227. temp = min;
  25228. min = max;
  25229. max = temp;
  25230. }
  25231. d = Math.max(min, d);
  25232. maxValue = Math.min(max, maxValue);
  25233. if (d > maxValue) {
  25234. return false;
  25235. }
  25236. }
  25237. return true;
  25238. };
  25239. /**
  25240. * Checks if the ray intersects a box
  25241. * @param box the bounding box to check
  25242. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25243. * @returns if the box was hit
  25244. */
  25245. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25246. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25247. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25248. };
  25249. /**
  25250. * If the ray hits a sphere
  25251. * @param sphere the bounding sphere to check
  25252. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25253. * @returns true if it hits the sphere
  25254. */
  25255. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25256. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25257. var x = sphere.center.x - this.origin.x;
  25258. var y = sphere.center.y - this.origin.y;
  25259. var z = sphere.center.z - this.origin.z;
  25260. var pyth = (x * x) + (y * y) + (z * z);
  25261. var radius = sphere.radius + intersectionTreshold;
  25262. var rr = radius * radius;
  25263. if (pyth <= rr) {
  25264. return true;
  25265. }
  25266. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25267. if (dot < 0.0) {
  25268. return false;
  25269. }
  25270. var temp = pyth - (dot * dot);
  25271. return temp <= rr;
  25272. };
  25273. /**
  25274. * If the ray hits a triange
  25275. * @param vertex0 triangle vertex
  25276. * @param vertex1 triangle vertex
  25277. * @param vertex2 triangle vertex
  25278. * @returns intersection information if hit
  25279. */
  25280. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25281. var edge1 = Ray.TmpVector3[0];
  25282. var edge2 = Ray.TmpVector3[1];
  25283. var pvec = Ray.TmpVector3[2];
  25284. var tvec = Ray.TmpVector3[3];
  25285. var qvec = Ray.TmpVector3[4];
  25286. vertex1.subtractToRef(vertex0, edge1);
  25287. vertex2.subtractToRef(vertex0, edge2);
  25288. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25289. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25290. if (det === 0) {
  25291. return null;
  25292. }
  25293. var invdet = 1 / det;
  25294. this.origin.subtractToRef(vertex0, tvec);
  25295. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25296. if (bu < 0 || bu > 1.0) {
  25297. return null;
  25298. }
  25299. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25300. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25301. if (bv < 0 || bu + bv > 1.0) {
  25302. return null;
  25303. }
  25304. //check if the distance is longer than the predefined length.
  25305. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25306. if (distance > this.length) {
  25307. return null;
  25308. }
  25309. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25310. };
  25311. /**
  25312. * Checks if ray intersects a plane
  25313. * @param plane the plane to check
  25314. * @returns the distance away it was hit
  25315. */
  25316. Ray.prototype.intersectsPlane = function (plane) {
  25317. var distance;
  25318. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25319. if (Math.abs(result1) < 9.99999997475243E-07) {
  25320. return null;
  25321. }
  25322. else {
  25323. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25324. distance = (-plane.d - result2) / result1;
  25325. if (distance < 0.0) {
  25326. if (distance < -9.99999997475243E-07) {
  25327. return null;
  25328. }
  25329. else {
  25330. return 0;
  25331. }
  25332. }
  25333. return distance;
  25334. }
  25335. };
  25336. /**
  25337. * Checks if ray intersects a mesh
  25338. * @param mesh the mesh to check
  25339. * @param fastCheck if only the bounding box should checked
  25340. * @returns picking info of the intersecton
  25341. */
  25342. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25343. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25344. mesh.getWorldMatrix().invertToRef(tm);
  25345. if (this._tmpRay) {
  25346. Ray.TransformToRef(this, tm, this._tmpRay);
  25347. }
  25348. else {
  25349. this._tmpRay = Ray.Transform(this, tm);
  25350. }
  25351. return mesh.intersects(this._tmpRay, fastCheck);
  25352. };
  25353. /**
  25354. * Checks if ray intersects a mesh
  25355. * @param meshes the meshes to check
  25356. * @param fastCheck if only the bounding box should checked
  25357. * @param results array to store result in
  25358. * @returns Array of picking infos
  25359. */
  25360. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25361. if (results) {
  25362. results.length = 0;
  25363. }
  25364. else {
  25365. results = [];
  25366. }
  25367. for (var i = 0; i < meshes.length; i++) {
  25368. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25369. if (pickInfo.hit) {
  25370. results.push(pickInfo);
  25371. }
  25372. }
  25373. results.sort(this._comparePickingInfo);
  25374. return results;
  25375. };
  25376. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25377. if (pickingInfoA.distance < pickingInfoB.distance) {
  25378. return -1;
  25379. }
  25380. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25381. return 1;
  25382. }
  25383. else {
  25384. return 0;
  25385. }
  25386. };
  25387. /**
  25388. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25389. * @param sega the first point of the segment to test the intersection against
  25390. * @param segb the second point of the segment to test the intersection against
  25391. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25392. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25393. */
  25394. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25395. var o = this.origin;
  25396. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25397. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25398. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25399. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25400. segb.subtractToRef(sega, u);
  25401. this.direction.scaleToRef(Ray.rayl, v);
  25402. o.addToRef(v, rsegb);
  25403. sega.subtractToRef(o, w);
  25404. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25405. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25406. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25407. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25408. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25409. var D = a * c - b * b; // always >= 0
  25410. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25411. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25412. // compute the line parameters of the two closest points
  25413. if (D < Ray.smallnum) { // the lines are almost parallel
  25414. sN = 0.0; // force using point P0 on segment S1
  25415. sD = 1.0; // to prevent possible division by 0.0 later
  25416. tN = e;
  25417. tD = c;
  25418. }
  25419. else { // get the closest points on the infinite lines
  25420. sN = (b * e - c * d);
  25421. tN = (a * e - b * d);
  25422. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25423. sN = 0.0;
  25424. tN = e;
  25425. tD = c;
  25426. }
  25427. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25428. sN = sD;
  25429. tN = e + b;
  25430. tD = c;
  25431. }
  25432. }
  25433. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25434. tN = 0.0;
  25435. // recompute sc for this edge
  25436. if (-d < 0.0) {
  25437. sN = 0.0;
  25438. }
  25439. else if (-d > a) {
  25440. sN = sD;
  25441. }
  25442. else {
  25443. sN = -d;
  25444. sD = a;
  25445. }
  25446. }
  25447. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25448. tN = tD;
  25449. // recompute sc for this edge
  25450. if ((-d + b) < 0.0) {
  25451. sN = 0;
  25452. }
  25453. else if ((-d + b) > a) {
  25454. sN = sD;
  25455. }
  25456. else {
  25457. sN = (-d + b);
  25458. sD = a;
  25459. }
  25460. }
  25461. // finally do the division to get sc and tc
  25462. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25463. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25464. // get the difference of the two closest points
  25465. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25466. v.scaleToRef(tc, qtc);
  25467. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25468. u.scaleToRef(sc, qsc);
  25469. qsc.addInPlace(w);
  25470. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25471. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25472. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25473. if (isIntersected) {
  25474. return qsc.length();
  25475. }
  25476. return -1;
  25477. };
  25478. /**
  25479. * Update the ray from viewport position
  25480. * @param x position
  25481. * @param y y position
  25482. * @param viewportWidth viewport width
  25483. * @param viewportHeight viewport height
  25484. * @param world world matrix
  25485. * @param view view matrix
  25486. * @param projection projection matrix
  25487. * @returns this ray updated
  25488. */
  25489. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25490. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25491. return this;
  25492. };
  25493. // Statics
  25494. /**
  25495. * Creates a ray with origin and direction of 0,0,0
  25496. * @returns the new ray
  25497. */
  25498. Ray.Zero = function () {
  25499. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25500. };
  25501. /**
  25502. * Creates a new ray from screen space and viewport
  25503. * @param x position
  25504. * @param y y position
  25505. * @param viewportWidth viewport width
  25506. * @param viewportHeight viewport height
  25507. * @param world world matrix
  25508. * @param view view matrix
  25509. * @param projection projection matrix
  25510. * @returns new ray
  25511. */
  25512. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25513. var result = Ray.Zero();
  25514. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25515. };
  25516. /**
  25517. * 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
  25518. * transformed to the given world matrix.
  25519. * @param origin The origin point
  25520. * @param end The end point
  25521. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25522. * @returns the new ray
  25523. */
  25524. Ray.CreateNewFromTo = function (origin, end, world) {
  25525. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  25526. var direction = end.subtract(origin);
  25527. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  25528. direction.normalize();
  25529. return Ray.Transform(new Ray(origin, direction, length), world);
  25530. };
  25531. /**
  25532. * Transforms a ray by a matrix
  25533. * @param ray ray to transform
  25534. * @param matrix matrix to apply
  25535. * @returns the resulting new ray
  25536. */
  25537. Ray.Transform = function (ray, matrix) {
  25538. 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));
  25539. Ray.TransformToRef(ray, matrix, result);
  25540. return result;
  25541. };
  25542. /**
  25543. * Transforms a ray by a matrix
  25544. * @param ray ray to transform
  25545. * @param matrix matrix to apply
  25546. * @param result ray to store result in
  25547. */
  25548. Ray.TransformToRef = function (ray, matrix, result) {
  25549. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  25550. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  25551. result.length = ray.length;
  25552. var dir = result.direction;
  25553. var len = dir.length();
  25554. if (!(len === 0 || len === 1)) {
  25555. var num = 1.0 / len;
  25556. dir.x *= num;
  25557. dir.y *= num;
  25558. dir.z *= num;
  25559. result.length *= len;
  25560. }
  25561. };
  25562. /**
  25563. * Unproject a ray from screen space to object space
  25564. * @param sourceX defines the screen space x coordinate to use
  25565. * @param sourceY defines the screen space y coordinate to use
  25566. * @param viewportWidth defines the current width of the viewport
  25567. * @param viewportHeight defines the current height of the viewport
  25568. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  25569. * @param view defines the view matrix to use
  25570. * @param projection defines the projection matrix to use
  25571. */
  25572. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  25573. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25574. world.multiplyToRef(view, matrix);
  25575. matrix.multiplyToRef(projection, matrix);
  25576. matrix.invert();
  25577. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25578. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  25579. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  25580. nearScreenSource.z = -1.0;
  25581. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  25582. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25583. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25584. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  25585. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  25586. this.origin.copyFrom(nearVec3);
  25587. farVec3.subtractToRef(nearVec3, this.direction);
  25588. this.direction.normalize();
  25589. };
  25590. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25591. Ray.smallnum = 0.00000001;
  25592. Ray.rayl = 10e8;
  25593. return Ray;
  25594. }());
  25595. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  25596. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25597. var result = Ray.Zero();
  25598. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  25599. return result;
  25600. };
  25601. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  25602. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25603. var engine = this.getEngine();
  25604. if (!camera) {
  25605. if (!this.activeCamera) {
  25606. throw new Error("Active camera not set");
  25607. }
  25608. camera = this.activeCamera;
  25609. }
  25610. var cameraViewport = camera.viewport;
  25611. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25612. // Moving coordinates to local viewport world
  25613. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25614. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25615. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  25616. return this;
  25617. };
  25618. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  25619. var result = Ray.Zero();
  25620. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  25621. return result;
  25622. };
  25623. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  25624. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25625. return this;
  25626. }
  25627. var engine = this.getEngine();
  25628. if (!camera) {
  25629. if (!this.activeCamera) {
  25630. throw new Error("Active camera not set");
  25631. }
  25632. camera = this.activeCamera;
  25633. }
  25634. var cameraViewport = camera.viewport;
  25635. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25636. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25637. // Moving coordinates to local viewport world
  25638. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25639. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25640. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  25641. return this;
  25642. };
  25643. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  25644. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25645. return null;
  25646. }
  25647. var pickingInfo = null;
  25648. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25649. var mesh = this.meshes[meshIndex];
  25650. if (predicate) {
  25651. if (!predicate(mesh)) {
  25652. continue;
  25653. }
  25654. }
  25655. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25656. continue;
  25657. }
  25658. var world = mesh.getWorldMatrix();
  25659. var ray = rayFunction(world);
  25660. var result = mesh.intersects(ray, fastCheck);
  25661. if (!result || !result.hit) {
  25662. continue;
  25663. }
  25664. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  25665. continue;
  25666. }
  25667. pickingInfo = result;
  25668. if (fastCheck) {
  25669. break;
  25670. }
  25671. }
  25672. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  25673. };
  25674. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate) {
  25675. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25676. return null;
  25677. }
  25678. var pickingInfos = new Array();
  25679. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25680. var mesh = this.meshes[meshIndex];
  25681. if (predicate) {
  25682. if (!predicate(mesh)) {
  25683. continue;
  25684. }
  25685. }
  25686. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25687. continue;
  25688. }
  25689. var world = mesh.getWorldMatrix();
  25690. var ray = rayFunction(world);
  25691. var result = mesh.intersects(ray, false);
  25692. if (!result || !result.hit) {
  25693. continue;
  25694. }
  25695. pickingInfos.push(result);
  25696. }
  25697. return pickingInfos;
  25698. };
  25699. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera) {
  25700. var _this = this;
  25701. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25702. return null;
  25703. }
  25704. var result = this._internalPick(function (world) {
  25705. if (!_this._tempPickingRay) {
  25706. _this._tempPickingRay = Ray.Zero();
  25707. }
  25708. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  25709. return _this._tempPickingRay;
  25710. }, predicate, fastCheck);
  25711. if (result) {
  25712. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  25713. }
  25714. return result;
  25715. };
  25716. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck) {
  25717. var _this = this;
  25718. var result = this._internalPick(function (world) {
  25719. if (!_this._pickWithRayInverseMatrix) {
  25720. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25721. }
  25722. world.invertToRef(_this._pickWithRayInverseMatrix);
  25723. if (!_this._cachedRayForTransform) {
  25724. _this._cachedRayForTransform = Ray.Zero();
  25725. }
  25726. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25727. return _this._cachedRayForTransform;
  25728. }, predicate, fastCheck);
  25729. if (result) {
  25730. result.ray = ray;
  25731. }
  25732. return result;
  25733. };
  25734. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera) {
  25735. var _this = this;
  25736. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  25737. };
  25738. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate) {
  25739. var _this = this;
  25740. return this._internalMultiPick(function (world) {
  25741. if (!_this._pickWithRayInverseMatrix) {
  25742. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25743. }
  25744. world.invertToRef(_this._pickWithRayInverseMatrix);
  25745. if (!_this._cachedRayForTransform) {
  25746. _this._cachedRayForTransform = Ray.Zero();
  25747. }
  25748. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25749. return _this._cachedRayForTransform;
  25750. }, predicate);
  25751. };
  25752. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  25753. if (length === void 0) { length = 100; }
  25754. if (!transform) {
  25755. transform = this.getWorldMatrix();
  25756. }
  25757. if (!origin) {
  25758. origin = this.position;
  25759. }
  25760. var forward = this._scene.useRightHandedSystem ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1) : new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
  25761. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  25762. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  25763. return new Ray(origin, direction, length);
  25764. };
  25765. /***/ }),
  25766. /***/ "./Debug/axesViewer.ts":
  25767. /*!*****************************!*\
  25768. !*** ./Debug/axesViewer.ts ***!
  25769. \*****************************/
  25770. /*! exports provided: AxesViewer */
  25771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25772. "use strict";
  25773. __webpack_require__.r(__webpack_exports__);
  25774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  25775. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25776. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25777. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  25778. /**
  25779. * The Axes viewer will show 3 axes in a specific point in space
  25780. */
  25781. var AxesViewer = /** @class */ (function () {
  25782. /**
  25783. * Creates a new AxesViewer
  25784. * @param scene defines the hosting scene
  25785. * @param scaleLines defines a number used to scale line length (1 by default)
  25786. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  25787. * @param xAxis defines the node hierarchy used to render the x-axis
  25788. * @param yAxis defines the node hierarchy used to render the y-axis
  25789. * @param zAxis defines the node hierarchy used to render the z-axis
  25790. */
  25791. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  25792. if (scaleLines === void 0) { scaleLines = 1; }
  25793. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  25794. this._scaleLinesFactor = 4;
  25795. this._instanced = false;
  25796. /**
  25797. * Gets or sets a number used to scale line length
  25798. */
  25799. this.scaleLines = 1;
  25800. this.scaleLines = scaleLines;
  25801. if (!xAxis) {
  25802. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25803. redColoredMaterial.disableLighting = true;
  25804. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  25805. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  25806. }
  25807. if (!yAxis) {
  25808. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25809. greenColoredMaterial.disableLighting = true;
  25810. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  25811. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  25812. }
  25813. if (!zAxis) {
  25814. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25815. blueColoredMaterial.disableLighting = true;
  25816. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  25817. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  25818. }
  25819. this._xAxis = xAxis;
  25820. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25821. this._yAxis = yAxis;
  25822. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25823. this._zAxis = zAxis;
  25824. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25825. if (renderingGroupId != null) {
  25826. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  25827. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  25828. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  25829. }
  25830. this.scene = scene;
  25831. 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());
  25832. }
  25833. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  25834. /** Gets the node hierarchy used to render x-axis */
  25835. get: function () {
  25836. return this._xAxis;
  25837. },
  25838. enumerable: true,
  25839. configurable: true
  25840. });
  25841. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  25842. /** Gets the node hierarchy used to render y-axis */
  25843. get: function () {
  25844. return this._yAxis;
  25845. },
  25846. enumerable: true,
  25847. configurable: true
  25848. });
  25849. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  25850. /** Gets the node hierarchy used to render z-axis */
  25851. get: function () {
  25852. return this._zAxis;
  25853. },
  25854. enumerable: true,
  25855. configurable: true
  25856. });
  25857. /**
  25858. * Force the viewer to update
  25859. * @param position defines the position of the viewer
  25860. * @param xaxis defines the x axis of the viewer
  25861. * @param yaxis defines the y axis of the viewer
  25862. * @param zaxis defines the z axis of the viewer
  25863. */
  25864. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  25865. this._xAxis.position.copyFrom(position);
  25866. this._xAxis.setDirection(xaxis);
  25867. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25868. this._yAxis.position.copyFrom(position);
  25869. this._yAxis.setDirection(yaxis);
  25870. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25871. this._zAxis.position.copyFrom(position);
  25872. this._zAxis.setDirection(zaxis);
  25873. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25874. };
  25875. /**
  25876. * Creates an instance of this axes viewer.
  25877. * @returns a new axes viewer with instanced meshes
  25878. */
  25879. AxesViewer.prototype.createInstance = function () {
  25880. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  25881. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  25882. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  25883. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  25884. axesViewer._instanced = true;
  25885. return axesViewer;
  25886. };
  25887. /** Releases resources */
  25888. AxesViewer.prototype.dispose = function () {
  25889. if (this._xAxis) {
  25890. this._xAxis.dispose(false, !this._instanced);
  25891. delete this._xAxis;
  25892. }
  25893. if (this._yAxis) {
  25894. this._yAxis.dispose(false, !this._instanced);
  25895. delete this._yAxis;
  25896. }
  25897. if (this._zAxis) {
  25898. this._zAxis.dispose(false, !this._instanced);
  25899. delete this._zAxis;
  25900. }
  25901. delete this.scene;
  25902. };
  25903. AxesViewer._SetRenderingGroupId = function (node, id) {
  25904. node.getChildMeshes().forEach(function (mesh) {
  25905. mesh.renderingGroupId = id;
  25906. });
  25907. };
  25908. return AxesViewer;
  25909. }());
  25910. /***/ }),
  25911. /***/ "./Debug/boneAxesViewer.ts":
  25912. /*!*********************************!*\
  25913. !*** ./Debug/boneAxesViewer.ts ***!
  25914. \*********************************/
  25915. /*! exports provided: BoneAxesViewer */
  25916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25917. "use strict";
  25918. __webpack_require__.r(__webpack_exports__);
  25919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25920. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25921. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25922. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25923. /**
  25924. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25925. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25926. */
  25927. var BoneAxesViewer = /** @class */ (function (_super) {
  25928. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25929. /**
  25930. * Creates a new BoneAxesViewer
  25931. * @param scene defines the hosting scene
  25932. * @param bone defines the target bone
  25933. * @param mesh defines the target mesh
  25934. * @param scaleLines defines a scaling factor for line length (1 by default)
  25935. */
  25936. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25937. if (scaleLines === void 0) { scaleLines = 1; }
  25938. var _this = _super.call(this, scene, scaleLines) || this;
  25939. /** Gets current position */
  25940. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25941. /** Gets direction of X axis */
  25942. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25943. /** Gets direction of Y axis */
  25944. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25945. /** Gets direction of Z axis */
  25946. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25947. _this.mesh = mesh;
  25948. _this.bone = bone;
  25949. return _this;
  25950. }
  25951. /**
  25952. * Force the viewer to update
  25953. */
  25954. BoneAxesViewer.prototype.update = function () {
  25955. if (!this.mesh || !this.bone) {
  25956. return;
  25957. }
  25958. var bone = this.bone;
  25959. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25960. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25961. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25962. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25963. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25964. };
  25965. /** Releases resources */
  25966. BoneAxesViewer.prototype.dispose = function () {
  25967. if (this.mesh) {
  25968. this.mesh = null;
  25969. this.bone = null;
  25970. _super.prototype.dispose.call(this);
  25971. }
  25972. };
  25973. return BoneAxesViewer;
  25974. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25975. /***/ }),
  25976. /***/ "./Debug/debugLayer.ts":
  25977. /*!*****************************!*\
  25978. !*** ./Debug/debugLayer.ts ***!
  25979. \*****************************/
  25980. /*! exports provided: DebugLayer */
  25981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25982. "use strict";
  25983. __webpack_require__.r(__webpack_exports__);
  25984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25985. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25986. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25987. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25988. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25989. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25990. get: function () {
  25991. if (!this._debugLayer) {
  25992. this._debugLayer = new DebugLayer(this);
  25993. }
  25994. return this._debugLayer;
  25995. },
  25996. enumerable: true,
  25997. configurable: true
  25998. });
  25999. /**
  26000. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26001. * what is happening in your scene
  26002. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26003. */
  26004. var DebugLayer = /** @class */ (function () {
  26005. /**
  26006. * Instantiates a new debug layer.
  26007. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26008. * what is happening in your scene
  26009. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26010. * @param scene Defines the scene to inspect
  26011. */
  26012. function DebugLayer(scene) {
  26013. var _this = this;
  26014. this.BJSINSPECTOR = this._getGlobalInspector();
  26015. /**
  26016. * Observable triggered when a property is changed through the inspector.
  26017. */
  26018. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26019. this._scene = scene;
  26020. this._scene.onDisposeObservable.add(function () {
  26021. // Debug layer
  26022. if (_this._scene._debugLayer) {
  26023. _this._scene._debugLayer.hide();
  26024. }
  26025. });
  26026. }
  26027. /** Creates the inspector window. */
  26028. DebugLayer.prototype._createInspector = function (config) {
  26029. if (this.isVisible()) {
  26030. return;
  26031. }
  26032. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26033. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26034. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26035. };
  26036. /** Get the inspector from bundle or global */
  26037. DebugLayer.prototype._getGlobalInspector = function () {
  26038. // UMD Global name detection from Webpack Bundle UMD Name.
  26039. if (typeof INSPECTOR !== 'undefined') {
  26040. return INSPECTOR;
  26041. }
  26042. // In case of module let s check the global emitted from the Inspector entry point.
  26043. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26044. return BABYLON;
  26045. }
  26046. return undefined;
  26047. };
  26048. /**
  26049. * Get if the inspector is visible or not.
  26050. * @returns true if visible otherwise, false
  26051. */
  26052. DebugLayer.prototype.isVisible = function () {
  26053. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26054. };
  26055. /**
  26056. * Hide the inspector and close its window.
  26057. */
  26058. DebugLayer.prototype.hide = function () {
  26059. if (this.BJSINSPECTOR) {
  26060. this.BJSINSPECTOR.Inspector.Hide();
  26061. }
  26062. };
  26063. /**
  26064. * Launch the debugLayer.
  26065. * @param config Define the configuration of the inspector
  26066. */
  26067. DebugLayer.prototype.show = function (config) {
  26068. if (typeof this.BJSINSPECTOR == 'undefined') {
  26069. // Load inspector and add it to the DOM
  26070. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  26071. }
  26072. else {
  26073. // Otherwise creates the inspector
  26074. this._createInspector(config);
  26075. }
  26076. };
  26077. /**
  26078. * Define the url to get the inspector script from.
  26079. * By default it uses the babylonjs CDN.
  26080. * @ignoreNaming
  26081. */
  26082. DebugLayer.InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
  26083. return DebugLayer;
  26084. }());
  26085. /***/ }),
  26086. /***/ "./Debug/index.ts":
  26087. /*!************************!*\
  26088. !*** ./Debug/index.ts ***!
  26089. \************************/
  26090. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26092. "use strict";
  26093. __webpack_require__.r(__webpack_exports__);
  26094. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26096. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26098. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26100. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26102. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26104. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26106. /***/ }),
  26107. /***/ "./Debug/physicsViewer.ts":
  26108. /*!********************************!*\
  26109. !*** ./Debug/physicsViewer.ts ***!
  26110. \********************************/
  26111. /*! exports provided: PhysicsViewer */
  26112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26113. "use strict";
  26114. __webpack_require__.r(__webpack_exports__);
  26115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26116. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26117. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26118. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26119. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26120. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26121. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26122. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26123. /**
  26124. * Used to show the physics impostor around the specific mesh
  26125. */
  26126. var PhysicsViewer = /** @class */ (function () {
  26127. /**
  26128. * Creates a new PhysicsViewer
  26129. * @param scene defines the hosting scene
  26130. */
  26131. function PhysicsViewer(scene) {
  26132. /** @hidden */
  26133. this._impostors = [];
  26134. /** @hidden */
  26135. this._meshes = [];
  26136. /** @hidden */
  26137. this._numMeshes = 0;
  26138. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  26139. var physicEngine = this._scene.getPhysicsEngine();
  26140. if (physicEngine) {
  26141. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26142. }
  26143. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  26144. this._utilityLayer.pickUtilitySceneFirst = false;
  26145. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26146. }
  26147. /** @hidden */
  26148. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26149. var plugin = this._physicsEnginePlugin;
  26150. for (var i = 0; i < this._numMeshes; i++) {
  26151. var impostor = this._impostors[i];
  26152. if (!impostor) {
  26153. continue;
  26154. }
  26155. if (impostor.isDisposed) {
  26156. this.hideImpostor(this._impostors[i--]);
  26157. }
  26158. else {
  26159. var mesh = this._meshes[i];
  26160. if (mesh && plugin) {
  26161. plugin.syncMeshWithImpostor(mesh, impostor);
  26162. }
  26163. }
  26164. }
  26165. };
  26166. /**
  26167. * Renders a specified physic impostor
  26168. * @param impostor defines the impostor to render
  26169. * @returns the new debug mesh used to render the impostor
  26170. */
  26171. PhysicsViewer.prototype.showImpostor = function (impostor) {
  26172. if (!this._scene) {
  26173. return null;
  26174. }
  26175. for (var i = 0; i < this._numMeshes; i++) {
  26176. if (this._impostors[i] == impostor) {
  26177. return null;
  26178. }
  26179. }
  26180. var debugMesh = this._getDebugMesh(impostor);
  26181. if (debugMesh) {
  26182. this._impostors[this._numMeshes] = impostor;
  26183. this._meshes[this._numMeshes] = debugMesh;
  26184. if (this._numMeshes === 0) {
  26185. this._renderFunction = this._updateDebugMeshes.bind(this);
  26186. this._scene.registerBeforeRender(this._renderFunction);
  26187. }
  26188. this._numMeshes++;
  26189. }
  26190. return debugMesh;
  26191. };
  26192. /**
  26193. * Hides a specified physic impostor
  26194. * @param impostor defines the impostor to hide
  26195. */
  26196. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26197. if (!impostor || !this._scene || !this._utilityLayer) {
  26198. return;
  26199. }
  26200. var removed = false;
  26201. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26202. for (var i = 0; i < this._numMeshes; i++) {
  26203. if (this._impostors[i] == impostor) {
  26204. var mesh = this._meshes[i];
  26205. if (!mesh) {
  26206. continue;
  26207. }
  26208. utilityLayerScene.removeMesh(mesh);
  26209. mesh.dispose();
  26210. this._numMeshes--;
  26211. if (this._numMeshes > 0) {
  26212. this._meshes[i] = this._meshes[this._numMeshes];
  26213. this._impostors[i] = this._impostors[this._numMeshes];
  26214. this._meshes[this._numMeshes] = null;
  26215. this._impostors[this._numMeshes] = null;
  26216. }
  26217. else {
  26218. this._meshes[0] = null;
  26219. this._impostors[0] = null;
  26220. }
  26221. removed = true;
  26222. break;
  26223. }
  26224. }
  26225. if (removed && this._numMeshes === 0) {
  26226. this._scene.unregisterBeforeRender(this._renderFunction);
  26227. }
  26228. };
  26229. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26230. if (!this._debugMaterial) {
  26231. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26232. this._debugMaterial.wireframe = true;
  26233. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26234. this._debugMaterial.disableLighting = true;
  26235. }
  26236. return this._debugMaterial;
  26237. };
  26238. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26239. if (!this._debugBoxMesh) {
  26240. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26241. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26242. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26243. }
  26244. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26245. };
  26246. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26247. if (!this._debugSphereMesh) {
  26248. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26249. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26250. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26251. }
  26252. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26253. };
  26254. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26255. if (!this._utilityLayer) {
  26256. return null;
  26257. }
  26258. var mesh = null;
  26259. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26260. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26261. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26262. impostor.getBoxSizeToRef(mesh.scaling);
  26263. }
  26264. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26265. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26266. var radius = impostor.getRadius();
  26267. mesh.scaling.x = radius * 2;
  26268. mesh.scaling.y = radius * 2;
  26269. mesh.scaling.z = radius * 2;
  26270. }
  26271. return mesh;
  26272. };
  26273. /** Releases all resources */
  26274. PhysicsViewer.prototype.dispose = function () {
  26275. for (var i = 0; i < this._numMeshes; i++) {
  26276. this.hideImpostor(this._impostors[i]);
  26277. }
  26278. if (this._debugBoxMesh) {
  26279. this._debugBoxMesh.dispose();
  26280. }
  26281. if (this._debugSphereMesh) {
  26282. this._debugSphereMesh.dispose();
  26283. }
  26284. if (this._debugMaterial) {
  26285. this._debugMaterial.dispose();
  26286. }
  26287. this._impostors.length = 0;
  26288. this._scene = null;
  26289. this._physicsEnginePlugin = null;
  26290. if (this._utilityLayer) {
  26291. this._utilityLayer.dispose();
  26292. this._utilityLayer = null;
  26293. }
  26294. };
  26295. return PhysicsViewer;
  26296. }());
  26297. /***/ }),
  26298. /***/ "./Debug/rayHelper.ts":
  26299. /*!****************************!*\
  26300. !*** ./Debug/rayHelper.ts ***!
  26301. \****************************/
  26302. /*! exports provided: RayHelper */
  26303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26304. "use strict";
  26305. __webpack_require__.r(__webpack_exports__);
  26306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26307. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26308. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26309. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26310. /**
  26311. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26312. * in order to better appreciate the issue one might have.
  26313. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26314. */
  26315. var RayHelper = /** @class */ (function () {
  26316. /**
  26317. * Instantiate a new ray helper.
  26318. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26319. * in order to better appreciate the issue one might have.
  26320. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26321. * @param ray Defines the ray we are currently tryin to visualize
  26322. */
  26323. function RayHelper(ray) {
  26324. this.ray = ray;
  26325. }
  26326. /**
  26327. * Helper function to create a colored helper in a scene in one line.
  26328. * @param ray Defines the ray we are currently tryin to visualize
  26329. * @param scene Defines the scene the ray is used in
  26330. * @param color Defines the color we want to see the ray in
  26331. * @returns The newly created ray helper.
  26332. */
  26333. RayHelper.CreateAndShow = function (ray, scene, color) {
  26334. var helper = new RayHelper(ray);
  26335. helper.show(scene, color);
  26336. return helper;
  26337. };
  26338. /**
  26339. * Shows the ray we are willing to debug.
  26340. * @param scene Defines the scene the ray needs to be rendered in
  26341. * @param color Defines the color the ray needs to be rendered in
  26342. */
  26343. RayHelper.prototype.show = function (scene, color) {
  26344. if (!this._renderFunction && this.ray) {
  26345. var ray = this.ray;
  26346. this._renderFunction = this._render.bind(this);
  26347. this._scene = scene;
  26348. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26349. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26350. if (this._renderFunction) {
  26351. this._scene.registerBeforeRender(this._renderFunction);
  26352. }
  26353. }
  26354. if (color && this._renderLine) {
  26355. this._renderLine.color.copyFrom(color);
  26356. }
  26357. };
  26358. /**
  26359. * Hides the ray we are debugging.
  26360. */
  26361. RayHelper.prototype.hide = function () {
  26362. if (this._renderFunction && this._scene) {
  26363. this._scene.unregisterBeforeRender(this._renderFunction);
  26364. this._scene = null;
  26365. this._renderFunction = null;
  26366. if (this._renderLine) {
  26367. this._renderLine.dispose();
  26368. this._renderLine = null;
  26369. }
  26370. this._renderPoints = [];
  26371. }
  26372. };
  26373. RayHelper.prototype._render = function () {
  26374. var ray = this.ray;
  26375. if (!ray) {
  26376. return;
  26377. }
  26378. var point = this._renderPoints[1];
  26379. var len = Math.min(ray.length, 1000000);
  26380. point.copyFrom(ray.direction);
  26381. point.scaleInPlace(len);
  26382. point.addInPlace(ray.origin);
  26383. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26384. };
  26385. /**
  26386. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26387. * @param mesh Defines the mesh we want the helper attached to
  26388. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26389. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26390. * @param length Defines the length of the ray
  26391. */
  26392. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26393. this._attachedToMesh = mesh;
  26394. var ray = this.ray;
  26395. if (!ray) {
  26396. return;
  26397. }
  26398. if (!ray.direction) {
  26399. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26400. }
  26401. if (!ray.origin) {
  26402. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26403. }
  26404. if (length) {
  26405. ray.length = length;
  26406. }
  26407. if (!meshSpaceOrigin) {
  26408. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26409. }
  26410. if (!meshSpaceDirection) {
  26411. // -1 so that this will work with Mesh.lookAt
  26412. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26413. }
  26414. if (!this._meshSpaceDirection) {
  26415. this._meshSpaceDirection = meshSpaceDirection.clone();
  26416. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26417. }
  26418. else {
  26419. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26420. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26421. }
  26422. if (!this._updateToMeshFunction) {
  26423. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26424. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26425. }
  26426. this._updateToMesh();
  26427. };
  26428. /**
  26429. * Detach the ray helper from the mesh it has previously been attached to.
  26430. */
  26431. RayHelper.prototype.detachFromMesh = function () {
  26432. if (this._attachedToMesh) {
  26433. if (this._updateToMeshFunction) {
  26434. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26435. }
  26436. this._attachedToMesh = null;
  26437. this._updateToMeshFunction = null;
  26438. }
  26439. };
  26440. RayHelper.prototype._updateToMesh = function () {
  26441. var ray = this.ray;
  26442. if (!this._attachedToMesh || !ray) {
  26443. return;
  26444. }
  26445. if (this._attachedToMesh._isDisposed) {
  26446. this.detachFromMesh();
  26447. return;
  26448. }
  26449. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26450. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26451. };
  26452. /**
  26453. * Dispose the helper and release its associated resources.
  26454. */
  26455. RayHelper.prototype.dispose = function () {
  26456. this.hide();
  26457. this.detachFromMesh();
  26458. this.ray = null;
  26459. };
  26460. return RayHelper;
  26461. }());
  26462. /***/ }),
  26463. /***/ "./Debug/skeletonViewer.ts":
  26464. /*!*********************************!*\
  26465. !*** ./Debug/skeletonViewer.ts ***!
  26466. \*********************************/
  26467. /*! exports provided: SkeletonViewer */
  26468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26469. "use strict";
  26470. __webpack_require__.r(__webpack_exports__);
  26471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26472. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26473. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26474. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26475. /**
  26476. * Class used to render a debug view of a given skeleton
  26477. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  26478. */
  26479. var SkeletonViewer = /** @class */ (function () {
  26480. /**
  26481. * Creates a new SkeletonViewer
  26482. * @param skeleton defines the skeleton to render
  26483. * @param mesh defines the mesh attached to the skeleton
  26484. * @param scene defines the hosting scene
  26485. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  26486. * @param renderingGroupId defines the rendering group id to use with the viewer
  26487. */
  26488. function SkeletonViewer(
  26489. /** defines the skeleton to render */
  26490. skeleton,
  26491. /** defines the mesh attached to the skeleton */
  26492. mesh, scene,
  26493. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  26494. autoUpdateBonesMatrices,
  26495. /** defines the rendering group id to use with the viewer */
  26496. renderingGroupId) {
  26497. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  26498. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  26499. this.skeleton = skeleton;
  26500. this.mesh = mesh;
  26501. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  26502. this.renderingGroupId = renderingGroupId;
  26503. /** Gets or sets the color used to render the skeleton */
  26504. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  26505. this._debugLines = new Array();
  26506. this._isEnabled = false;
  26507. this._scene = scene;
  26508. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  26509. this._utilityLayer.pickUtilitySceneFirst = false;
  26510. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26511. this.update();
  26512. this._renderFunction = this.update.bind(this);
  26513. }
  26514. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  26515. /**
  26516. * Returns the mesh used to render the bones
  26517. */
  26518. get: function () {
  26519. return this._debugMesh;
  26520. },
  26521. enumerable: true,
  26522. configurable: true
  26523. });
  26524. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  26525. get: function () {
  26526. return this._isEnabled;
  26527. },
  26528. /** Gets or sets a boolean indicating if the viewer is enabled */
  26529. set: function (value) {
  26530. if (this._isEnabled === value) {
  26531. return;
  26532. }
  26533. this._isEnabled = value;
  26534. if (value) {
  26535. this._scene.registerBeforeRender(this._renderFunction);
  26536. }
  26537. else {
  26538. this._scene.unregisterBeforeRender(this._renderFunction);
  26539. }
  26540. },
  26541. enumerable: true,
  26542. configurable: true
  26543. });
  26544. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  26545. if (x === void 0) { x = 0; }
  26546. if (y === void 0) { y = 0; }
  26547. if (z === void 0) { z = 0; }
  26548. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  26549. var parentBone = bone.getParent();
  26550. tmat.copyFrom(bone.getLocalMatrix());
  26551. if (x !== 0 || y !== 0 || z !== 0) {
  26552. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  26553. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  26554. tmat2.setTranslationFromFloats(x, y, z);
  26555. tmat2.multiplyToRef(tmat, tmat);
  26556. }
  26557. if (parentBone) {
  26558. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  26559. }
  26560. tmat.multiplyToRef(meshMat, tmat);
  26561. position.x = tmat.m[12];
  26562. position.y = tmat.m[13];
  26563. position.z = tmat.m[14];
  26564. };
  26565. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  26566. var len = bones.length;
  26567. var meshPos = this.mesh.position;
  26568. for (var i = 0; i < len; i++) {
  26569. var bone = bones[i];
  26570. var points = this._debugLines[i];
  26571. if (!points) {
  26572. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26573. this._debugLines[i] = points;
  26574. }
  26575. this._getBonePosition(points[0], bone, meshMat);
  26576. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  26577. points[0].subtractInPlace(meshPos);
  26578. points[1].subtractInPlace(meshPos);
  26579. }
  26580. };
  26581. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  26582. var len = bones.length;
  26583. var boneNum = 0;
  26584. var meshPos = this.mesh.position;
  26585. for (var i = len - 1; i >= 0; i--) {
  26586. var childBone = bones[i];
  26587. var parentBone = childBone.getParent();
  26588. if (!parentBone) {
  26589. continue;
  26590. }
  26591. var points = this._debugLines[boneNum];
  26592. if (!points) {
  26593. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26594. this._debugLines[boneNum] = points;
  26595. }
  26596. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  26597. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  26598. points[0].subtractInPlace(meshPos);
  26599. points[1].subtractInPlace(meshPos);
  26600. boneNum++;
  26601. }
  26602. };
  26603. /** Update the viewer to sync with current skeleton state */
  26604. SkeletonViewer.prototype.update = function () {
  26605. if (!this._utilityLayer) {
  26606. return;
  26607. }
  26608. if (this.autoUpdateBonesMatrices) {
  26609. this.skeleton.computeAbsoluteTransforms();
  26610. }
  26611. if (this.skeleton.bones[0].length === undefined) {
  26612. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26613. }
  26614. else {
  26615. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26616. }
  26617. var targetScene = this._utilityLayer.utilityLayerScene;
  26618. if (!this._debugMesh) {
  26619. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  26620. this._debugMesh.renderingGroupId = this.renderingGroupId;
  26621. }
  26622. else {
  26623. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  26624. }
  26625. this._debugMesh.position.copyFrom(this.mesh.position);
  26626. this._debugMesh.color = this.color;
  26627. };
  26628. /** Release associated resources */
  26629. SkeletonViewer.prototype.dispose = function () {
  26630. this.isEnabled = false;
  26631. if (this._debugMesh) {
  26632. this.isEnabled = false;
  26633. this._debugMesh.dispose();
  26634. this._debugMesh = null;
  26635. }
  26636. if (this._utilityLayer) {
  26637. this._utilityLayer.dispose();
  26638. this._utilityLayer = null;
  26639. }
  26640. };
  26641. return SkeletonViewer;
  26642. }());
  26643. /***/ }),
  26644. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  26645. /*!*****************************************************!*\
  26646. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  26647. \*****************************************************/
  26648. /*! exports provided: _OcclusionDataStorage */
  26649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26650. "use strict";
  26651. __webpack_require__.r(__webpack_exports__);
  26652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  26653. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26654. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  26655. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  26656. /** @hidden */
  26657. var _OcclusionDataStorage = /** @class */ (function () {
  26658. function _OcclusionDataStorage() {
  26659. /** @hidden */
  26660. this.occlusionInternalRetryCounter = 0;
  26661. /** @hidden */
  26662. this.isOcclusionQueryInProgress = false;
  26663. /** @hidden */
  26664. this.isOccluded = false;
  26665. /** @hidden */
  26666. this.occlusionRetryCount = -1;
  26667. /** @hidden */
  26668. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  26669. /** @hidden */
  26670. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  26671. }
  26672. return _OcclusionDataStorage;
  26673. }());
  26674. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  26675. return this._gl.createQuery();
  26676. };
  26677. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  26678. this._gl.deleteQuery(query);
  26679. return this;
  26680. };
  26681. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  26682. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  26683. };
  26684. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  26685. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  26686. };
  26687. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  26688. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26689. this._gl.beginQuery(glAlgorithm, query);
  26690. return this;
  26691. };
  26692. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  26693. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26694. this._gl.endQuery(glAlgorithm);
  26695. return this;
  26696. };
  26697. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  26698. var timerQuery = this.getCaps().timerQuery;
  26699. if (timerQuery.createQueryEXT) {
  26700. return timerQuery.createQueryEXT();
  26701. }
  26702. return this.createQuery();
  26703. };
  26704. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  26705. var timerQuery = this.getCaps().timerQuery;
  26706. if (timerQuery.deleteQueryEXT) {
  26707. timerQuery.deleteQueryEXT(query);
  26708. return;
  26709. }
  26710. this.deleteQuery(query);
  26711. };
  26712. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  26713. var timerQuery = this.getCaps().timerQuery;
  26714. if (timerQuery.getQueryObjectEXT) {
  26715. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  26716. }
  26717. return this.getQueryResult(query);
  26718. };
  26719. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  26720. var timerQuery = this.getCaps().timerQuery;
  26721. if (timerQuery.getQueryObjectEXT) {
  26722. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  26723. }
  26724. return this.isQueryResultAvailable(query);
  26725. };
  26726. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  26727. var caps = this.getCaps();
  26728. var timerQuery = caps.timerQuery;
  26729. if (!timerQuery) {
  26730. return null;
  26731. }
  26732. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  26733. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26734. if (caps.canUseTimestampForTimerQuery) {
  26735. token._startTimeQuery = this._createTimeQuery();
  26736. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  26737. }
  26738. else {
  26739. if (this._currentNonTimestampToken) {
  26740. return this._currentNonTimestampToken;
  26741. }
  26742. token._timeElapsedQuery = this._createTimeQuery();
  26743. if (timerQuery.beginQueryEXT) {
  26744. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26745. }
  26746. else {
  26747. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26748. }
  26749. this._currentNonTimestampToken = token;
  26750. }
  26751. return token;
  26752. };
  26753. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  26754. var caps = this.getCaps();
  26755. var timerQuery = caps.timerQuery;
  26756. if (!timerQuery || !token) {
  26757. return -1;
  26758. }
  26759. if (caps.canUseTimestampForTimerQuery) {
  26760. if (!token._startTimeQuery) {
  26761. return -1;
  26762. }
  26763. if (!token._endTimeQuery) {
  26764. token._endTimeQuery = this._createTimeQuery();
  26765. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  26766. }
  26767. }
  26768. else if (!token._timeElapsedQueryEnded) {
  26769. if (!token._timeElapsedQuery) {
  26770. return -1;
  26771. }
  26772. if (timerQuery.endQueryEXT) {
  26773. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  26774. }
  26775. else {
  26776. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  26777. }
  26778. token._timeElapsedQueryEnded = true;
  26779. }
  26780. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26781. var available = false;
  26782. if (token._endTimeQuery) {
  26783. available = this._getTimeQueryAvailability(token._endTimeQuery);
  26784. }
  26785. else if (token._timeElapsedQuery) {
  26786. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  26787. }
  26788. if (available && !disjoint) {
  26789. var result = 0;
  26790. if (caps.canUseTimestampForTimerQuery) {
  26791. if (!token._startTimeQuery || !token._endTimeQuery) {
  26792. return -1;
  26793. }
  26794. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  26795. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  26796. result = timeEnd - timeStart;
  26797. this._deleteTimeQuery(token._startTimeQuery);
  26798. this._deleteTimeQuery(token._endTimeQuery);
  26799. token._startTimeQuery = null;
  26800. token._endTimeQuery = null;
  26801. }
  26802. else {
  26803. if (!token._timeElapsedQuery) {
  26804. return -1;
  26805. }
  26806. result = this._getTimeQueryResult(token._timeElapsedQuery);
  26807. this._deleteTimeQuery(token._timeElapsedQuery);
  26808. token._timeElapsedQuery = null;
  26809. token._timeElapsedQueryEnded = false;
  26810. this._currentNonTimestampToken = null;
  26811. }
  26812. return result;
  26813. }
  26814. return -1;
  26815. };
  26816. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  26817. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  26818. };
  26819. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  26820. get: function () {
  26821. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  26822. },
  26823. enumerable: false,
  26824. configurable: true
  26825. });
  26826. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  26827. get: function () {
  26828. if (!this.__occlusionDataStorage) {
  26829. this.__occlusionDataStorage = new _OcclusionDataStorage();
  26830. }
  26831. return this.__occlusionDataStorage;
  26832. },
  26833. enumerable: false,
  26834. configurable: true
  26835. });
  26836. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  26837. get: function () {
  26838. return this._occlusionDataStorage.isOccluded;
  26839. },
  26840. set: function (value) {
  26841. this._occlusionDataStorage.isOccluded = value;
  26842. },
  26843. enumerable: true,
  26844. configurable: true
  26845. });
  26846. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  26847. get: function () {
  26848. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  26849. },
  26850. set: function (value) {
  26851. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  26852. },
  26853. enumerable: true,
  26854. configurable: true
  26855. });
  26856. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  26857. get: function () {
  26858. return this._occlusionDataStorage.occlusionType;
  26859. },
  26860. set: function (value) {
  26861. this._occlusionDataStorage.occlusionType = value;
  26862. },
  26863. enumerable: true,
  26864. configurable: true
  26865. });
  26866. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  26867. get: function () {
  26868. return this._occlusionDataStorage.occlusionRetryCount;
  26869. },
  26870. set: function (value) {
  26871. this._occlusionDataStorage.occlusionRetryCount = value;
  26872. },
  26873. enumerable: true,
  26874. configurable: true
  26875. });
  26876. // We also need to update AbstractMesh as there is a portion of the code there
  26877. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  26878. var dataStorage = this._occlusionDataStorage;
  26879. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  26880. dataStorage.isOccluded = false;
  26881. return false;
  26882. }
  26883. var engine = this.getEngine();
  26884. if (engine.webGLVersion < 2) {
  26885. dataStorage.isOccluded = false;
  26886. return false;
  26887. }
  26888. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  26889. dataStorage.isOccluded = false;
  26890. return false;
  26891. }
  26892. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  26893. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  26894. if (isOcclusionQueryAvailable) {
  26895. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  26896. dataStorage.isOcclusionQueryInProgress = false;
  26897. dataStorage.occlusionInternalRetryCounter = 0;
  26898. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26899. }
  26900. else {
  26901. dataStorage.occlusionInternalRetryCounter++;
  26902. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26903. dataStorage.isOcclusionQueryInProgress = false;
  26904. dataStorage.occlusionInternalRetryCounter = 0;
  26905. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26906. // if strict continue the last state of the object.
  26907. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26908. }
  26909. else {
  26910. return false;
  26911. }
  26912. }
  26913. }
  26914. var scene = this.getScene();
  26915. if (scene.getBoundingBoxRenderer) {
  26916. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26917. if (!this._occlusionQuery) {
  26918. this._occlusionQuery = engine.createQuery();
  26919. }
  26920. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26921. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26922. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26923. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26924. }
  26925. return dataStorage.isOccluded;
  26926. };
  26927. /***/ }),
  26928. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26929. /*!********************************************************!*\
  26930. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26931. \********************************************************/
  26932. /*! exports provided: _forceTransformFeedbackToBundle */
  26933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26934. "use strict";
  26935. __webpack_require__.r(__webpack_exports__);
  26936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26937. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26938. /** @hidden */
  26939. var _forceTransformFeedbackToBundle = true;
  26940. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26941. return this._gl.createTransformFeedback();
  26942. };
  26943. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26944. this._gl.deleteTransformFeedback(value);
  26945. };
  26946. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26947. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26948. };
  26949. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26950. if (usePoints === void 0) { usePoints = true; }
  26951. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26952. };
  26953. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26954. this._gl.endTransformFeedback();
  26955. };
  26956. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26957. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26958. };
  26959. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26960. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26961. };
  26962. /***/ }),
  26963. /***/ "./Engines/Extensions/index.ts":
  26964. /*!*************************************!*\
  26965. !*** ./Engines/Extensions/index.ts ***!
  26966. \*************************************/
  26967. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26968. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26969. "use strict";
  26970. __webpack_require__.r(__webpack_exports__);
  26971. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26973. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26975. /***/ }),
  26976. /***/ "./Engines/constants.ts":
  26977. /*!******************************!*\
  26978. !*** ./Engines/constants.ts ***!
  26979. \******************************/
  26980. /*! exports provided: Constants */
  26981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26982. "use strict";
  26983. __webpack_require__.r(__webpack_exports__);
  26984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  26985. /** Defines the cross module used constants to avoid circular dependncies */
  26986. var Constants = /** @class */ (function () {
  26987. function Constants() {
  26988. }
  26989. /** Defines that alpha blending is disabled */
  26990. Constants.ALPHA_DISABLE = 0;
  26991. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26992. Constants.ALPHA_ADD = 1;
  26993. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26994. Constants.ALPHA_COMBINE = 2;
  26995. /** Defines that alpha blending to DEST - SRC * DEST */
  26996. Constants.ALPHA_SUBTRACT = 3;
  26997. /** Defines that alpha blending to SRC * DEST */
  26998. Constants.ALPHA_MULTIPLY = 4;
  26999. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27000. Constants.ALPHA_MAXIMIZED = 5;
  27001. /** Defines that alpha blending to SRC + DEST */
  27002. Constants.ALPHA_ONEONE = 6;
  27003. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27004. Constants.ALPHA_PREMULTIPLIED = 7;
  27005. /**
  27006. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27007. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27008. */
  27009. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27010. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27011. Constants.ALPHA_INTERPOLATE = 9;
  27012. /**
  27013. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27014. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27015. */
  27016. Constants.ALPHA_SCREENMODE = 10;
  27017. /** Defines that the ressource is not delayed*/
  27018. Constants.DELAYLOADSTATE_NONE = 0;
  27019. /** Defines that the ressource was successfully delay loaded */
  27020. Constants.DELAYLOADSTATE_LOADED = 1;
  27021. /** Defines that the ressource is currently delay loading */
  27022. Constants.DELAYLOADSTATE_LOADING = 2;
  27023. /** Defines that the ressource is delayed and has not started loading */
  27024. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27025. // Depht or Stencil test Constants.
  27026. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27027. Constants.NEVER = 0x0200;
  27028. /** 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 */
  27029. Constants.ALWAYS = 0x0207;
  27030. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27031. Constants.LESS = 0x0201;
  27032. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27033. Constants.EQUAL = 0x0202;
  27034. /** 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 */
  27035. Constants.LEQUAL = 0x0203;
  27036. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27037. Constants.GREATER = 0x0204;
  27038. /** 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 */
  27039. Constants.GEQUAL = 0x0206;
  27040. /** 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 */
  27041. Constants.NOTEQUAL = 0x0205;
  27042. // Stencil Actions Constants.
  27043. /** Passed to stencilOperation to specify that stencil value must be kept */
  27044. Constants.KEEP = 0x1E00;
  27045. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27046. Constants.REPLACE = 0x1E01;
  27047. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27048. Constants.INCR = 0x1E02;
  27049. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27050. Constants.DECR = 0x1E03;
  27051. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27052. Constants.INVERT = 0x150A;
  27053. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27054. Constants.INCR_WRAP = 0x8507;
  27055. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27056. Constants.DECR_WRAP = 0x8508;
  27057. /** Texture is not repeating outside of 0..1 UVs */
  27058. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27059. /** Texture is repeating outside of 0..1 UVs */
  27060. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27061. /** Texture is repeating and mirrored */
  27062. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27063. /** ALPHA */
  27064. Constants.TEXTUREFORMAT_ALPHA = 0;
  27065. /** LUMINANCE */
  27066. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27067. /** LUMINANCE_ALPHA */
  27068. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27069. /** RGB */
  27070. Constants.TEXTUREFORMAT_RGB = 4;
  27071. /** RGBA */
  27072. Constants.TEXTUREFORMAT_RGBA = 5;
  27073. /** RED */
  27074. Constants.TEXTUREFORMAT_RED = 6;
  27075. /** RED (2nd reference) */
  27076. Constants.TEXTUREFORMAT_R = 6;
  27077. /** RG */
  27078. Constants.TEXTUREFORMAT_RG = 7;
  27079. /** RED_INTEGER */
  27080. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27081. /** RED_INTEGER (2nd reference) */
  27082. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27083. /** RG_INTEGER */
  27084. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27085. /** RGB_INTEGER */
  27086. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27087. /** RGBA_INTEGER */
  27088. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27089. /** UNSIGNED_BYTE */
  27090. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27091. /** UNSIGNED_BYTE (2nd reference) */
  27092. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27093. /** FLOAT */
  27094. Constants.TEXTURETYPE_FLOAT = 1;
  27095. /** HALF_FLOAT */
  27096. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27097. /** BYTE */
  27098. Constants.TEXTURETYPE_BYTE = 3;
  27099. /** SHORT */
  27100. Constants.TEXTURETYPE_SHORT = 4;
  27101. /** UNSIGNED_SHORT */
  27102. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27103. /** INT */
  27104. Constants.TEXTURETYPE_INT = 6;
  27105. /** UNSIGNED_INT */
  27106. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27107. /** UNSIGNED_SHORT_4_4_4_4 */
  27108. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27109. /** UNSIGNED_SHORT_5_5_5_1 */
  27110. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27111. /** UNSIGNED_SHORT_5_6_5 */
  27112. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27113. /** UNSIGNED_INT_2_10_10_10_REV */
  27114. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27115. /** UNSIGNED_INT_24_8 */
  27116. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27117. /** UNSIGNED_INT_10F_11F_11F_REV */
  27118. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27119. /** UNSIGNED_INT_5_9_9_9_REV */
  27120. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27121. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27122. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27123. /** nearest is mag = nearest and min = nearest and mip = linear */
  27124. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27125. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27126. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27127. /** Trilinear is mag = linear and min = linear and mip = linear */
  27128. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27129. /** nearest is mag = nearest and min = nearest and mip = linear */
  27130. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27131. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27132. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27133. /** Trilinear is mag = linear and min = linear and mip = linear */
  27134. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27135. /** mag = nearest and min = nearest and mip = nearest */
  27136. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27137. /** mag = nearest and min = linear and mip = nearest */
  27138. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27139. /** mag = nearest and min = linear and mip = linear */
  27140. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27141. /** mag = nearest and min = linear and mip = none */
  27142. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27143. /** mag = nearest and min = nearest and mip = none */
  27144. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27145. /** mag = linear and min = nearest and mip = nearest */
  27146. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27147. /** mag = linear and min = nearest and mip = linear */
  27148. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27149. /** mag = linear and min = linear and mip = none */
  27150. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27151. /** mag = linear and min = nearest and mip = none */
  27152. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27153. /** Explicit coordinates mode */
  27154. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27155. /** Spherical coordinates mode */
  27156. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27157. /** Planar coordinates mode */
  27158. Constants.TEXTURE_PLANAR_MODE = 2;
  27159. /** Cubic coordinates mode */
  27160. Constants.TEXTURE_CUBIC_MODE = 3;
  27161. /** Projection coordinates mode */
  27162. Constants.TEXTURE_PROJECTION_MODE = 4;
  27163. /** Skybox coordinates mode */
  27164. Constants.TEXTURE_SKYBOX_MODE = 5;
  27165. /** Inverse Cubic coordinates mode */
  27166. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27167. /** Equirectangular coordinates mode */
  27168. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27169. /** Equirectangular Fixed coordinates mode */
  27170. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27171. /** Equirectangular Fixed Mirrored coordinates mode */
  27172. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27173. // Texture rescaling mode
  27174. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27175. Constants.SCALEMODE_FLOOR = 1;
  27176. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27177. Constants.SCALEMODE_NEAREST = 2;
  27178. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27179. Constants.SCALEMODE_CEILING = 3;
  27180. /**
  27181. * The dirty texture flag value
  27182. */
  27183. Constants.MATERIAL_TextureDirtyFlag = 1;
  27184. /**
  27185. * The dirty light flag value
  27186. */
  27187. Constants.MATERIAL_LightDirtyFlag = 2;
  27188. /**
  27189. * The dirty fresnel flag value
  27190. */
  27191. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27192. /**
  27193. * The dirty attribute flag value
  27194. */
  27195. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27196. /**
  27197. * The dirty misc flag value
  27198. */
  27199. Constants.MATERIAL_MiscDirtyFlag = 16;
  27200. /**
  27201. * The all dirty flag value
  27202. */
  27203. Constants.MATERIAL_AllDirtyFlag = 31;
  27204. /**
  27205. * Returns the triangle fill mode
  27206. */
  27207. Constants.MATERIAL_TriangleFillMode = 0;
  27208. /**
  27209. * Returns the wireframe mode
  27210. */
  27211. Constants.MATERIAL_WireFrameFillMode = 1;
  27212. /**
  27213. * Returns the point fill mode
  27214. */
  27215. Constants.MATERIAL_PointFillMode = 2;
  27216. /**
  27217. * Returns the point list draw mode
  27218. */
  27219. Constants.MATERIAL_PointListDrawMode = 3;
  27220. /**
  27221. * Returns the line list draw mode
  27222. */
  27223. Constants.MATERIAL_LineListDrawMode = 4;
  27224. /**
  27225. * Returns the line loop draw mode
  27226. */
  27227. Constants.MATERIAL_LineLoopDrawMode = 5;
  27228. /**
  27229. * Returns the line strip draw mode
  27230. */
  27231. Constants.MATERIAL_LineStripDrawMode = 6;
  27232. /**
  27233. * Returns the triangle strip draw mode
  27234. */
  27235. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27236. /**
  27237. * Returns the triangle fan draw mode
  27238. */
  27239. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27240. /**
  27241. * Stores the clock-wise side orientation
  27242. */
  27243. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27244. /**
  27245. * Stores the counter clock-wise side orientation
  27246. */
  27247. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27248. /**
  27249. * Nothing
  27250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27251. */
  27252. Constants.ACTION_NothingTrigger = 0;
  27253. /**
  27254. * On pick
  27255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27256. */
  27257. Constants.ACTION_OnPickTrigger = 1;
  27258. /**
  27259. * On left pick
  27260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27261. */
  27262. Constants.ACTION_OnLeftPickTrigger = 2;
  27263. /**
  27264. * On right pick
  27265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27266. */
  27267. Constants.ACTION_OnRightPickTrigger = 3;
  27268. /**
  27269. * On center pick
  27270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27271. */
  27272. Constants.ACTION_OnCenterPickTrigger = 4;
  27273. /**
  27274. * On pick down
  27275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27276. */
  27277. Constants.ACTION_OnPickDownTrigger = 5;
  27278. /**
  27279. * On double pick
  27280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27281. */
  27282. Constants.ACTION_OnDoublePickTrigger = 6;
  27283. /**
  27284. * On pick up
  27285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27286. */
  27287. Constants.ACTION_OnPickUpTrigger = 7;
  27288. /**
  27289. * On pick out.
  27290. * This trigger will only be raised if you also declared a OnPickDown
  27291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27292. */
  27293. Constants.ACTION_OnPickOutTrigger = 16;
  27294. /**
  27295. * On long press
  27296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27297. */
  27298. Constants.ACTION_OnLongPressTrigger = 8;
  27299. /**
  27300. * On pointer over
  27301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27302. */
  27303. Constants.ACTION_OnPointerOverTrigger = 9;
  27304. /**
  27305. * On pointer out
  27306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27307. */
  27308. Constants.ACTION_OnPointerOutTrigger = 10;
  27309. /**
  27310. * On every frame
  27311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27312. */
  27313. Constants.ACTION_OnEveryFrameTrigger = 11;
  27314. /**
  27315. * On intersection enter
  27316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27317. */
  27318. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27319. /**
  27320. * On intersection exit
  27321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27322. */
  27323. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27324. /**
  27325. * On key down
  27326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27327. */
  27328. Constants.ACTION_OnKeyDownTrigger = 14;
  27329. /**
  27330. * On key up
  27331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27332. */
  27333. Constants.ACTION_OnKeyUpTrigger = 15;
  27334. /**
  27335. * Billboard mode will only apply to Y axis
  27336. */
  27337. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27338. /**
  27339. * Billboard mode will apply to all axes
  27340. */
  27341. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27342. /**
  27343. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27344. */
  27345. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27346. /**
  27347. * Gets or sets base Assets URL
  27348. */
  27349. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27350. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27351. * Test order :
  27352. * Is the bounding sphere outside the frustum ?
  27353. * If not, are the bounding box vertices outside the frustum ?
  27354. * It not, then the cullable object is in the frustum.
  27355. */
  27356. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27357. /** Culling strategy : Bounding Sphere Only.
  27358. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27359. * It's also less accurate than the standard because some not visible objects can still be selected.
  27360. * Test : is the bounding sphere outside the frustum ?
  27361. * If not, then the cullable object is in the frustum.
  27362. */
  27363. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27364. /** Culling strategy : Optimistic Inclusion.
  27365. * This in an inclusion test first, then the standard exclusion test.
  27366. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27367. * 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.
  27368. * Anyway, it's as accurate as the standard strategy.
  27369. * Test :
  27370. * Is the cullable object bounding sphere center in the frustum ?
  27371. * If not, apply the default culling strategy.
  27372. */
  27373. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27374. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27375. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27376. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27377. * 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.
  27378. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27379. * Test :
  27380. * Is the cullable object bounding sphere center in the frustum ?
  27381. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27382. */
  27383. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27384. /**
  27385. * No logging while loading
  27386. */
  27387. Constants.SCENELOADER_NO_LOGGING = 0;
  27388. /**
  27389. * Minimal logging while loading
  27390. */
  27391. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27392. /**
  27393. * Summary logging while loading
  27394. */
  27395. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27396. /**
  27397. * Detailled logging while loading
  27398. */
  27399. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27400. return Constants;
  27401. }());
  27402. /***/ }),
  27403. /***/ "./Engines/engine.ts":
  27404. /*!***************************!*\
  27405. !*** ./Engines/engine.ts ***!
  27406. \***************************/
  27407. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27409. "use strict";
  27410. __webpack_require__.r(__webpack_exports__);
  27411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27415. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27416. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27417. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27418. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27419. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27420. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27421. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27422. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27423. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27424. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27425. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27426. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27427. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27428. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27429. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27430. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27431. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27432. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27433. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  27434. /**
  27435. * Keeps track of all the buffer info used in engine.
  27436. */
  27437. var BufferPointer = /** @class */ (function () {
  27438. function BufferPointer() {
  27439. }
  27440. return BufferPointer;
  27441. }());
  27442. /**
  27443. * Interface for attribute information associated with buffer instanciation
  27444. */
  27445. var InstancingAttributeInfo = /** @class */ (function () {
  27446. function InstancingAttributeInfo() {
  27447. }
  27448. return InstancingAttributeInfo;
  27449. }());
  27450. /**
  27451. * Define options used to create a depth texture
  27452. */
  27453. var DepthTextureCreationOptions = /** @class */ (function () {
  27454. function DepthTextureCreationOptions() {
  27455. }
  27456. return DepthTextureCreationOptions;
  27457. }());
  27458. /**
  27459. * Class used to describe the capabilities of the engine relatively to the current browser
  27460. */
  27461. var EngineCapabilities = /** @class */ (function () {
  27462. function EngineCapabilities() {
  27463. }
  27464. return EngineCapabilities;
  27465. }());
  27466. /**
  27467. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27468. */
  27469. var Engine = /** @class */ (function () {
  27470. /**
  27471. * Creates a new engine
  27472. * @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
  27473. * @param antialias defines enable antialiasing (default: false)
  27474. * @param options defines further options to be sent to the getContext() function
  27475. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27476. */
  27477. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  27478. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  27479. var _this = this;
  27480. // Public members
  27481. /**
  27482. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27483. */
  27484. this.forcePOTTextures = false;
  27485. /**
  27486. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27487. */
  27488. this.isFullscreen = false;
  27489. /**
  27490. * Gets a boolean indicating if the pointer is currently locked
  27491. */
  27492. this.isPointerLock = false;
  27493. /**
  27494. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27495. */
  27496. this.cullBackFaces = true;
  27497. /**
  27498. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27499. */
  27500. this.renderEvenInBackground = true;
  27501. /**
  27502. * Gets or sets a boolean indicating that cache can be kept between frames
  27503. */
  27504. this.preventCacheWipeBetweenFrames = false;
  27505. /**
  27506. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27507. **/
  27508. this.enableOfflineSupport = false;
  27509. /**
  27510. * 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)
  27511. **/
  27512. this.disableManifestCheck = false;
  27513. /**
  27514. * Gets the list of created scenes
  27515. */
  27516. this.scenes = new Array();
  27517. /**
  27518. * Event raised when a new scene is created
  27519. */
  27520. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27521. /**
  27522. * Gets the list of created postprocesses
  27523. */
  27524. this.postProcesses = new Array();
  27525. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27526. this.validateShaderPrograms = false;
  27527. // Observables
  27528. /**
  27529. * Observable event triggered each time the rendering canvas is resized
  27530. */
  27531. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27532. /**
  27533. * Observable event triggered each time the canvas loses focus
  27534. */
  27535. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27536. /**
  27537. * Observable event triggered each time the canvas gains focus
  27538. */
  27539. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27540. /**
  27541. * Observable event triggered each time the canvas receives pointerout event
  27542. */
  27543. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27544. /**
  27545. * Observable event triggered before each texture is initialized
  27546. */
  27547. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27548. //WebVR
  27549. this._vrDisplay = undefined;
  27550. this._vrSupported = false;
  27551. this._vrExclusivePointerMode = false;
  27552. // Uniform buffers list
  27553. /**
  27554. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27555. */
  27556. this.disableUniformBuffers = false;
  27557. /** @hidden */
  27558. this._uniformBuffers = new Array();
  27559. // Observables
  27560. /**
  27561. * Observable raised when the engine begins a new frame
  27562. */
  27563. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27564. /**
  27565. * If set, will be used to request the next animation frame for the render loop
  27566. */
  27567. this.customAnimationFrameRequester = null;
  27568. /**
  27569. * Observable raised when the engine ends the current frame
  27570. */
  27571. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27572. /**
  27573. * Observable raised when the engine is about to compile a shader
  27574. */
  27575. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27576. /**
  27577. * Observable raised when the engine has jsut compiled a shader
  27578. */
  27579. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27580. this._windowIsBackground = false;
  27581. this._webGLVersion = 1.0;
  27582. /** @hidden */
  27583. this._badOS = false;
  27584. /** @hidden */
  27585. this._badDesktopOS = false;
  27586. /**
  27587. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27588. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27589. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27590. */
  27591. this.disableTextureBindingOptimization = false;
  27592. /**
  27593. * Observable signaled when VR display mode changes
  27594. */
  27595. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27596. /**
  27597. * Observable signaled when VR request present is complete
  27598. */
  27599. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27600. /**
  27601. * Observable signaled when VR request present starts
  27602. */
  27603. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27604. this._colorWrite = true;
  27605. /** @hidden */
  27606. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27607. /** @hidden */
  27608. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27609. this._renderingQueueLaunched = false;
  27610. this._activeRenderLoops = new Array();
  27611. // Deterministic lockstepMaxSteps
  27612. this._deterministicLockstep = false;
  27613. this._lockstepMaxSteps = 4;
  27614. // Lost context
  27615. /**
  27616. * Observable signaled when a context lost event is raised
  27617. */
  27618. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27619. /**
  27620. * Observable signaled when a context restored event is raised
  27621. */
  27622. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27623. this._contextWasLost = false;
  27624. this._doNotHandleContextLost = false;
  27625. // FPS
  27626. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  27627. this._fps = 60;
  27628. this._deltaTime = 0;
  27629. /**
  27630. * Turn this value on if you want to pause FPS computation when in background
  27631. */
  27632. this.disablePerformanceMonitorInBackground = false;
  27633. // States
  27634. /** @hidden */
  27635. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  27636. /** @hidden */
  27637. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  27638. /** @hidden */
  27639. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  27640. /** @hidden */
  27641. this._alphaMode = Engine.ALPHA_DISABLE;
  27642. // Cache
  27643. this._internalTexturesCache = new Array();
  27644. /** @hidden */
  27645. this._activeChannel = 0;
  27646. this._currentTextureChannel = -1;
  27647. /** @hidden */
  27648. this._boundTexturesCache = {};
  27649. this._compiledEffects = {};
  27650. this._vertexAttribArraysEnabled = [];
  27651. this._uintIndicesCurrentlySet = false;
  27652. this._currentBoundBuffer = new Array();
  27653. /** @hidden */
  27654. this._currentFramebuffer = null;
  27655. this._currentBufferPointers = new Array();
  27656. this._currentInstanceLocations = new Array();
  27657. this._currentInstanceBuffers = new Array();
  27658. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27659. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27660. this._vaoRecordInProgress = false;
  27661. this._mustWipeVertexAttributes = false;
  27662. this._nextFreeTextureSlots = new Array();
  27663. this._maxSimultaneousTextures = 0;
  27664. this._activeRequests = new Array();
  27665. // Hardware supported Compressed Textures
  27666. this._texturesSupported = new Array();
  27667. /**
  27668. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27669. */
  27670. this.premultipliedAlpha = true;
  27671. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  27672. this._onVRFullScreenTriggered = function () {
  27673. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  27674. //get the old size before we change
  27675. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  27676. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  27677. //get the width and height, change the render size
  27678. var leftEye = _this._vrDisplay.getEyeParameters('left');
  27679. _this.setHardwareScalingLevel(1);
  27680. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  27681. }
  27682. else {
  27683. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  27684. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  27685. }
  27686. };
  27687. this._unpackFlipYCached = null;
  27688. /**
  27689. * In case you are sharing the context with other applications, it might
  27690. * be interested to not cache the unpack flip y state to ensure a consistent
  27691. * value would be set.
  27692. */
  27693. this.enableUnpackFlipYCached = true;
  27694. this._boundUniforms = {};
  27695. // Register promises
  27696. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  27697. var canvas = null;
  27698. Engine.Instances.push(this);
  27699. if (!canvasOrContext) {
  27700. return;
  27701. }
  27702. options = options || {};
  27703. if (canvasOrContext.getContext) {
  27704. canvas = canvasOrContext;
  27705. this._renderingCanvas = canvas;
  27706. if (antialias != null) {
  27707. options.antialias = antialias;
  27708. }
  27709. if (options.deterministicLockstep === undefined) {
  27710. options.deterministicLockstep = false;
  27711. }
  27712. if (options.lockstepMaxSteps === undefined) {
  27713. options.lockstepMaxSteps = 4;
  27714. }
  27715. if (options.preserveDrawingBuffer === undefined) {
  27716. options.preserveDrawingBuffer = false;
  27717. }
  27718. if (options.audioEngine === undefined) {
  27719. options.audioEngine = true;
  27720. }
  27721. if (options.stencil === undefined) {
  27722. options.stencil = true;
  27723. }
  27724. if (options.premultipliedAlpha === false) {
  27725. this.premultipliedAlpha = false;
  27726. }
  27727. this._deterministicLockstep = options.deterministicLockstep;
  27728. this._lockstepMaxSteps = options.lockstepMaxSteps;
  27729. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  27730. // Exceptions
  27731. if (navigator && navigator.userAgent) {
  27732. var ua = navigator.userAgent;
  27733. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  27734. var exception = _a[_i];
  27735. var key = exception.key;
  27736. var targets = exception.targets;
  27737. if (ua.indexOf(key) > -1) {
  27738. if (exception.capture && exception.captureConstraint) {
  27739. var capture = exception.capture;
  27740. var constraint = exception.captureConstraint;
  27741. var regex = new RegExp(capture);
  27742. var matches = regex.exec(ua);
  27743. if (matches && matches.length > 0) {
  27744. var capturedValue = parseInt(matches[matches.length - 1]);
  27745. if (capturedValue >= constraint) {
  27746. continue;
  27747. }
  27748. }
  27749. }
  27750. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  27751. var target = targets_1[_b];
  27752. switch (target) {
  27753. case "uniformBuffer":
  27754. this.disableUniformBuffers = true;
  27755. break;
  27756. case "textureBindingOptimization":
  27757. this.disableTextureBindingOptimization = true;
  27758. break;
  27759. }
  27760. }
  27761. }
  27762. }
  27763. }
  27764. // GL
  27765. if (!options.disableWebGL2Support) {
  27766. try {
  27767. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  27768. if (this._gl) {
  27769. this._webGLVersion = 2.0;
  27770. // Prevent weird browsers to lie :-)
  27771. if (!this._gl.deleteQuery) {
  27772. this._webGLVersion = 1.0;
  27773. }
  27774. }
  27775. }
  27776. catch (e) {
  27777. // Do nothing
  27778. }
  27779. }
  27780. if (!this._gl) {
  27781. if (!canvas) {
  27782. throw new Error("The provided canvas is null or undefined.");
  27783. }
  27784. try {
  27785. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  27786. }
  27787. catch (e) {
  27788. throw new Error("WebGL not supported");
  27789. }
  27790. }
  27791. if (!this._gl) {
  27792. throw new Error("WebGL not supported");
  27793. }
  27794. this._onCanvasFocus = function () {
  27795. _this.onCanvasFocusObservable.notifyObservers(_this);
  27796. };
  27797. this._onCanvasBlur = function () {
  27798. _this.onCanvasBlurObservable.notifyObservers(_this);
  27799. };
  27800. canvas.addEventListener("focus", this._onCanvasFocus);
  27801. canvas.addEventListener("blur", this._onCanvasBlur);
  27802. this._onBlur = function () {
  27803. if (_this.disablePerformanceMonitorInBackground) {
  27804. _this._performanceMonitor.disable();
  27805. }
  27806. _this._windowIsBackground = true;
  27807. };
  27808. this._onFocus = function () {
  27809. if (_this.disablePerformanceMonitorInBackground) {
  27810. _this._performanceMonitor.enable();
  27811. }
  27812. _this._windowIsBackground = false;
  27813. };
  27814. this._onCanvasPointerOut = function (ev) {
  27815. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  27816. };
  27817. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27818. window.addEventListener("blur", this._onBlur);
  27819. window.addEventListener("focus", this._onFocus);
  27820. }
  27821. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  27822. // Context lost
  27823. if (!this._doNotHandleContextLost) {
  27824. this._onContextLost = function (evt) {
  27825. evt.preventDefault();
  27826. _this._contextWasLost = true;
  27827. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  27828. _this.onContextLostObservable.notifyObservers(_this);
  27829. };
  27830. this._onContextRestored = function () {
  27831. // Adding a timeout to avoid race condition at browser level
  27832. setTimeout(function () {
  27833. // Rebuild gl context
  27834. _this._initGLContext();
  27835. // Rebuild effects
  27836. _this._rebuildEffects();
  27837. // Rebuild textures
  27838. _this._rebuildInternalTextures();
  27839. // Rebuild buffers
  27840. _this._rebuildBuffers();
  27841. // Cache
  27842. _this.wipeCaches(true);
  27843. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  27844. _this.onContextRestoredObservable.notifyObservers(_this);
  27845. _this._contextWasLost = false;
  27846. }, 0);
  27847. };
  27848. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  27849. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  27850. }
  27851. if (!options.doNotHandleTouchAction) {
  27852. this._disableTouchAction();
  27853. }
  27854. }
  27855. else {
  27856. this._gl = canvasOrContext;
  27857. this._renderingCanvas = this._gl.canvas;
  27858. if (this._gl.renderbufferStorageMultisample) {
  27859. this._webGLVersion = 2.0;
  27860. }
  27861. var attributes = this._gl.getContextAttributes();
  27862. if (attributes) {
  27863. options.stencil = attributes.stencil;
  27864. }
  27865. }
  27866. // Viewport
  27867. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  27868. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  27869. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  27870. this.resize();
  27871. this._isStencilEnable = options.stencil ? true : false;
  27872. this._initGLContext();
  27873. if (canvas) {
  27874. // Fullscreen
  27875. this._onFullscreenChange = function () {
  27876. if (document.fullscreen !== undefined) {
  27877. _this.isFullscreen = document.fullscreen;
  27878. }
  27879. else if (document.mozFullScreen !== undefined) {
  27880. _this.isFullscreen = document.mozFullScreen;
  27881. }
  27882. else if (document.webkitIsFullScreen !== undefined) {
  27883. _this.isFullscreen = document.webkitIsFullScreen;
  27884. }
  27885. else if (document.msIsFullScreen !== undefined) {
  27886. _this.isFullscreen = document.msIsFullScreen;
  27887. }
  27888. // Pointer lock
  27889. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  27890. canvas.requestPointerLock = canvas.requestPointerLock ||
  27891. canvas.msRequestPointerLock ||
  27892. canvas.mozRequestPointerLock ||
  27893. canvas.webkitRequestPointerLock;
  27894. if (canvas.requestPointerLock) {
  27895. canvas.requestPointerLock();
  27896. }
  27897. }
  27898. };
  27899. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27900. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27901. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27902. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27903. // Pointer lock
  27904. this._onPointerLockChange = function () {
  27905. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27906. document.webkitPointerLockElement === canvas ||
  27907. document.msPointerLockElement === canvas ||
  27908. document.pointerLockElement === canvas);
  27909. };
  27910. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27911. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27912. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27913. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27914. this._onVRDisplayPointerRestricted = function () {
  27915. if (canvas) {
  27916. canvas.requestPointerLock();
  27917. }
  27918. };
  27919. this._onVRDisplayPointerUnrestricted = function () {
  27920. document.exitPointerLock();
  27921. };
  27922. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27923. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27924. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27925. }
  27926. }
  27927. // Create Audio Engine if needed.
  27928. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27929. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27930. }
  27931. // Prepare buffer pointers
  27932. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27933. this._currentBufferPointers[i] = new BufferPointer();
  27934. }
  27935. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27936. // Load WebVR Devices
  27937. if (options.autoEnableWebVR) {
  27938. this.initWebVR();
  27939. }
  27940. // Detect if we are running on a faulty buggy OS.
  27941. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27942. // Detect if we are running on a faulty buggy desktop OS.
  27943. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27944. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27945. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27946. }
  27947. Object.defineProperty(Engine, "Instances", {
  27948. /** Gets the list of created engines */
  27949. get: function () {
  27950. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27951. },
  27952. enumerable: true,
  27953. configurable: true
  27954. });
  27955. Object.defineProperty(Engine, "LastCreatedEngine", {
  27956. /**
  27957. * Gets the latest created engine
  27958. */
  27959. get: function () {
  27960. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27961. },
  27962. enumerable: true,
  27963. configurable: true
  27964. });
  27965. Object.defineProperty(Engine, "LastCreatedScene", {
  27966. /**
  27967. * Gets the latest created scene
  27968. */
  27969. get: function () {
  27970. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27971. },
  27972. enumerable: true,
  27973. configurable: true
  27974. });
  27975. /**
  27976. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27977. * @param flag defines which part of the materials must be marked as dirty
  27978. * @param predicate defines a predicate used to filter which materials should be affected
  27979. */
  27980. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27981. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27982. var engine = Engine.Instances[engineIndex];
  27983. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  27984. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  27985. }
  27986. }
  27987. };
  27988. Object.defineProperty(Engine, "Version", {
  27989. /**
  27990. * Returns the current version of the framework
  27991. */
  27992. get: function () {
  27993. return "4.0.0-alpha.22";
  27994. },
  27995. enumerable: true,
  27996. configurable: true
  27997. });
  27998. Object.defineProperty(Engine.prototype, "description", {
  27999. /**
  28000. * Returns a string describing the current engine
  28001. */
  28002. get: function () {
  28003. var description = "WebGL" + this.webGLVersion;
  28004. if (this._caps.parallelShaderCompile) {
  28005. description += " - Parallel shader compilation";
  28006. }
  28007. return description;
  28008. },
  28009. enumerable: true,
  28010. configurable: true
  28011. });
  28012. Object.defineProperty(Engine, "ShadersRepository", {
  28013. /**
  28014. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28015. */
  28016. get: function () {
  28017. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28018. },
  28019. set: function (value) {
  28020. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28021. },
  28022. enumerable: true,
  28023. configurable: true
  28024. });
  28025. /**
  28026. * Method called to create the default loading screen.
  28027. * This can be overriden in your own app.
  28028. * @param canvas The rendering canvas element
  28029. * @returns The loading screen
  28030. */
  28031. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28032. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28033. };
  28034. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28035. /**
  28036. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28037. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28038. */
  28039. get: function () {
  28040. return this._vrExclusivePointerMode;
  28041. },
  28042. enumerable: true,
  28043. configurable: true
  28044. });
  28045. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28046. /**
  28047. * Gets a boolean indicating that the engine supports uniform buffers
  28048. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28049. */
  28050. get: function () {
  28051. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28052. },
  28053. enumerable: true,
  28054. configurable: true
  28055. });
  28056. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28057. /**
  28058. * Gets a boolean indicating that only power of 2 textures are supported
  28059. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28060. */
  28061. get: function () {
  28062. return this._webGLVersion < 2 || this.forcePOTTextures;
  28063. },
  28064. enumerable: true,
  28065. configurable: true
  28066. });
  28067. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28068. /**
  28069. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28071. */
  28072. get: function () {
  28073. return this._doNotHandleContextLost;
  28074. },
  28075. set: function (value) {
  28076. this._doNotHandleContextLost = value;
  28077. },
  28078. enumerable: true,
  28079. configurable: true
  28080. });
  28081. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28082. /**
  28083. * Gets the performance monitor attached to this engine
  28084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28085. */
  28086. get: function () {
  28087. return this._performanceMonitor;
  28088. },
  28089. enumerable: true,
  28090. configurable: true
  28091. });
  28092. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28093. /**
  28094. * Gets the list of texture formats supported
  28095. */
  28096. get: function () {
  28097. return this._texturesSupported;
  28098. },
  28099. enumerable: true,
  28100. configurable: true
  28101. });
  28102. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28103. /**
  28104. * Gets the list of texture formats in use
  28105. */
  28106. get: function () {
  28107. return this._textureFormatInUse;
  28108. },
  28109. enumerable: true,
  28110. configurable: true
  28111. });
  28112. Object.defineProperty(Engine.prototype, "currentViewport", {
  28113. /**
  28114. * Gets the current viewport
  28115. */
  28116. get: function () {
  28117. return this._cachedViewport;
  28118. },
  28119. enumerable: true,
  28120. configurable: true
  28121. });
  28122. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28123. /**
  28124. * Gets the default empty texture
  28125. */
  28126. get: function () {
  28127. if (!this._emptyTexture) {
  28128. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28129. }
  28130. return this._emptyTexture;
  28131. },
  28132. enumerable: true,
  28133. configurable: true
  28134. });
  28135. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28136. /**
  28137. * Gets the default empty 3D texture
  28138. */
  28139. get: function () {
  28140. if (!this._emptyTexture3D) {
  28141. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28142. }
  28143. return this._emptyTexture3D;
  28144. },
  28145. enumerable: true,
  28146. configurable: true
  28147. });
  28148. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28149. /**
  28150. * Gets the default empty cube texture
  28151. */
  28152. get: function () {
  28153. if (!this._emptyCubeTexture) {
  28154. var faceData = new Uint8Array(4);
  28155. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28156. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28157. }
  28158. return this._emptyCubeTexture;
  28159. },
  28160. enumerable: true,
  28161. configurable: true
  28162. });
  28163. Engine.prototype._disableTouchAction = function () {
  28164. if (!this._renderingCanvas) {
  28165. return;
  28166. }
  28167. this._renderingCanvas.setAttribute("touch-action", "none");
  28168. this._renderingCanvas.style.touchAction = "none";
  28169. this._renderingCanvas.style.msTouchAction = "none";
  28170. };
  28171. Engine.prototype._rebuildInternalTextures = function () {
  28172. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28173. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28174. var internalTexture = currentState_1[_i];
  28175. internalTexture._rebuild();
  28176. }
  28177. };
  28178. Engine.prototype._rebuildEffects = function () {
  28179. for (var key in this._compiledEffects) {
  28180. var effect = this._compiledEffects[key];
  28181. effect._prepareEffect();
  28182. }
  28183. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28184. };
  28185. /**
  28186. * Gets a boolean indicating if all created effects are ready
  28187. * @returns true if all effects are ready
  28188. */
  28189. Engine.prototype.areAllEffectsReady = function () {
  28190. for (var key in this._compiledEffects) {
  28191. var effect = this._compiledEffects[key];
  28192. if (!effect.isReady()) {
  28193. return false;
  28194. }
  28195. }
  28196. return true;
  28197. };
  28198. Engine.prototype._rebuildBuffers = function () {
  28199. // Index / Vertex
  28200. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28201. var scene = _a[_i];
  28202. scene.resetCachedMaterial();
  28203. scene._rebuildGeometries();
  28204. scene._rebuildTextures();
  28205. }
  28206. // Uniforms
  28207. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28208. var uniformBuffer = _c[_b];
  28209. uniformBuffer._rebuild();
  28210. }
  28211. };
  28212. Engine.prototype._initGLContext = function () {
  28213. // Caps
  28214. this._caps = new EngineCapabilities();
  28215. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28216. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28217. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28218. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28219. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28220. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28221. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28222. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28223. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28224. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28225. // Infos
  28226. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28227. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28228. if (rendererInfo != null) {
  28229. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28230. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28231. }
  28232. if (!this._glVendor) {
  28233. this._glVendor = "Unknown vendor";
  28234. }
  28235. if (!this._glRenderer) {
  28236. this._glRenderer = "Unknown renderer";
  28237. }
  28238. // Constants
  28239. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28240. if (this._gl.RGBA16F !== 0x881A) {
  28241. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28242. }
  28243. if (this._gl.RGBA32F !== 0x8814) {
  28244. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28245. }
  28246. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28247. this._gl.DEPTH24_STENCIL8 = 35056;
  28248. }
  28249. // Extensions
  28250. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28251. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28252. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28253. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28254. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28255. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28256. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28257. 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');
  28258. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28259. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28260. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28261. this._caps.highPrecisionShaderSupported = false;
  28262. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28263. if (this._caps.timerQuery) {
  28264. if (this._webGLVersion === 1) {
  28265. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28266. }
  28267. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28268. }
  28269. // Checks if some of the format renders first to allow the use of webgl inspector.
  28270. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28271. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28272. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28273. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28274. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28275. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28276. if (this._webGLVersion > 1) {
  28277. this._gl.HALF_FLOAT_OES = 0x140B;
  28278. }
  28279. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28280. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28281. // Draw buffers
  28282. if (this._webGLVersion > 1) {
  28283. this._caps.drawBuffersExtension = true;
  28284. }
  28285. else {
  28286. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28287. if (drawBuffersExtension !== null) {
  28288. this._caps.drawBuffersExtension = true;
  28289. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28290. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28291. for (var i = 0; i < 16; i++) {
  28292. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28293. }
  28294. }
  28295. else {
  28296. this._caps.drawBuffersExtension = false;
  28297. }
  28298. }
  28299. // Shader compiler threads
  28300. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28301. if (this._caps.parallelShaderCompile) {
  28302. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  28303. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  28304. }
  28305. // Depth Texture
  28306. if (this._webGLVersion > 1) {
  28307. this._caps.depthTextureExtension = true;
  28308. }
  28309. else {
  28310. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28311. if (depthTextureExtension != null) {
  28312. this._caps.depthTextureExtension = true;
  28313. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28314. }
  28315. }
  28316. // Vertex array object
  28317. if (this._webGLVersion > 1) {
  28318. this._caps.vertexArrayObject = true;
  28319. }
  28320. else {
  28321. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28322. if (vertexArrayObjectExtension != null) {
  28323. this._caps.vertexArrayObject = true;
  28324. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28325. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28326. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28327. }
  28328. else {
  28329. this._caps.vertexArrayObject = false;
  28330. }
  28331. }
  28332. // Instances count
  28333. if (this._webGLVersion > 1) {
  28334. this._caps.instancedArrays = true;
  28335. }
  28336. else {
  28337. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28338. if (instanceExtension != null) {
  28339. this._caps.instancedArrays = true;
  28340. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28341. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28342. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28343. }
  28344. else {
  28345. this._caps.instancedArrays = false;
  28346. }
  28347. }
  28348. // Intelligently add supported compressed formats in order to check for.
  28349. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28350. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28351. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28352. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28353. if (this._caps.astc) {
  28354. this.texturesSupported.push('-astc.ktx');
  28355. }
  28356. if (this._caps.s3tc) {
  28357. this.texturesSupported.push('-dxt.ktx');
  28358. }
  28359. if (this._caps.pvrtc) {
  28360. this.texturesSupported.push('-pvrtc.ktx');
  28361. }
  28362. if (this._caps.etc2) {
  28363. this.texturesSupported.push('-etc2.ktx');
  28364. }
  28365. if (this._caps.etc1) {
  28366. this.texturesSupported.push('-etc1.ktx');
  28367. }
  28368. if (this._gl.getShaderPrecisionFormat) {
  28369. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28370. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28371. if (vertex_highp && fragment_highp) {
  28372. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28373. }
  28374. }
  28375. // Depth buffer
  28376. this.setDepthBuffer(true);
  28377. this.setDepthFunctionToLessOrEqual();
  28378. this.setDepthWrite(true);
  28379. // Texture maps
  28380. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28381. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28382. this._nextFreeTextureSlots.push(slot);
  28383. }
  28384. };
  28385. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28386. /**
  28387. * Gets version of the current webGL context
  28388. */
  28389. get: function () {
  28390. return this._webGLVersion;
  28391. },
  28392. enumerable: true,
  28393. configurable: true
  28394. });
  28395. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28396. /**
  28397. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28398. */
  28399. get: function () {
  28400. return this._isStencilEnable;
  28401. },
  28402. enumerable: true,
  28403. configurable: true
  28404. });
  28405. Engine.prototype._prepareWorkingCanvas = function () {
  28406. if (this._workingCanvas) {
  28407. return;
  28408. }
  28409. this._workingCanvas = document.createElement("canvas");
  28410. var context = this._workingCanvas.getContext("2d");
  28411. if (context) {
  28412. this._workingContext = context;
  28413. }
  28414. };
  28415. /**
  28416. * Reset the texture cache to empty state
  28417. */
  28418. Engine.prototype.resetTextureCache = function () {
  28419. for (var key in this._boundTexturesCache) {
  28420. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28421. continue;
  28422. }
  28423. var boundTexture = this._boundTexturesCache[key];
  28424. if (boundTexture) {
  28425. this._removeDesignatedSlot(boundTexture);
  28426. }
  28427. this._boundTexturesCache[key] = null;
  28428. }
  28429. if (!this.disableTextureBindingOptimization) {
  28430. this._nextFreeTextureSlots = [];
  28431. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28432. this._nextFreeTextureSlots.push(slot);
  28433. }
  28434. }
  28435. this._currentTextureChannel = -1;
  28436. };
  28437. /**
  28438. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28440. * @returns true if engine is in deterministic lock step mode
  28441. */
  28442. Engine.prototype.isDeterministicLockStep = function () {
  28443. return this._deterministicLockstep;
  28444. };
  28445. /**
  28446. * Gets the max steps when engine is running in deterministic lock step
  28447. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28448. * @returns the max steps
  28449. */
  28450. Engine.prototype.getLockstepMaxSteps = function () {
  28451. return this._lockstepMaxSteps;
  28452. };
  28453. /**
  28454. * Gets an object containing information about the current webGL context
  28455. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28456. */
  28457. Engine.prototype.getGlInfo = function () {
  28458. return {
  28459. vendor: this._glVendor,
  28460. renderer: this._glRenderer,
  28461. version: this._glVersion
  28462. };
  28463. };
  28464. /**
  28465. * Gets current aspect ratio
  28466. * @param camera defines the camera to use to get the aspect ratio
  28467. * @param useScreen defines if screen size must be used (or the current render target if any)
  28468. * @returns a number defining the aspect ratio
  28469. */
  28470. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  28471. if (useScreen === void 0) { useScreen = false; }
  28472. var viewport = camera.viewport;
  28473. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  28474. };
  28475. /**
  28476. * Gets current screen aspect ratio
  28477. * @returns a number defining the aspect ratio
  28478. */
  28479. Engine.prototype.getScreenAspectRatio = function () {
  28480. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  28481. };
  28482. /**
  28483. * Gets the current render width
  28484. * @param useScreen defines if screen size must be used (or the current render target if any)
  28485. * @returns a number defining the current render width
  28486. */
  28487. Engine.prototype.getRenderWidth = function (useScreen) {
  28488. if (useScreen === void 0) { useScreen = false; }
  28489. if (!useScreen && this._currentRenderTarget) {
  28490. return this._currentRenderTarget.width;
  28491. }
  28492. return this._gl.drawingBufferWidth;
  28493. };
  28494. /**
  28495. * Gets the current render height
  28496. * @param useScreen defines if screen size must be used (or the current render target if any)
  28497. * @returns a number defining the current render height
  28498. */
  28499. Engine.prototype.getRenderHeight = function (useScreen) {
  28500. if (useScreen === void 0) { useScreen = false; }
  28501. if (!useScreen && this._currentRenderTarget) {
  28502. return this._currentRenderTarget.height;
  28503. }
  28504. return this._gl.drawingBufferHeight;
  28505. };
  28506. /**
  28507. * Gets the HTML canvas attached with the current webGL context
  28508. * @returns a HTML canvas
  28509. */
  28510. Engine.prototype.getRenderingCanvas = function () {
  28511. return this._renderingCanvas;
  28512. };
  28513. /**
  28514. * Gets the client rect of the HTML canvas attached with the current webGL context
  28515. * @returns a client rectanglee
  28516. */
  28517. Engine.prototype.getRenderingCanvasClientRect = function () {
  28518. if (!this._renderingCanvas) {
  28519. return null;
  28520. }
  28521. return this._renderingCanvas.getBoundingClientRect();
  28522. };
  28523. /**
  28524. * Defines the hardware scaling level.
  28525. * By default the hardware scaling level is computed from the window device ratio.
  28526. * 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.
  28527. * @param level defines the level to use
  28528. */
  28529. Engine.prototype.setHardwareScalingLevel = function (level) {
  28530. this._hardwareScalingLevel = level;
  28531. this.resize();
  28532. };
  28533. /**
  28534. * Gets the current hardware scaling level.
  28535. * By default the hardware scaling level is computed from the window device ratio.
  28536. * 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.
  28537. * @returns a number indicating the current hardware scaling level
  28538. */
  28539. Engine.prototype.getHardwareScalingLevel = function () {
  28540. return this._hardwareScalingLevel;
  28541. };
  28542. /**
  28543. * Gets the list of loaded textures
  28544. * @returns an array containing all loaded textures
  28545. */
  28546. Engine.prototype.getLoadedTexturesCache = function () {
  28547. return this._internalTexturesCache;
  28548. };
  28549. /**
  28550. * Gets the object containing all engine capabilities
  28551. * @returns the EngineCapabilities object
  28552. */
  28553. Engine.prototype.getCaps = function () {
  28554. return this._caps;
  28555. };
  28556. /**
  28557. * Gets the current depth function
  28558. * @returns a number defining the depth function
  28559. */
  28560. Engine.prototype.getDepthFunction = function () {
  28561. return this._depthCullingState.depthFunc;
  28562. };
  28563. /**
  28564. * Sets the current depth function
  28565. * @param depthFunc defines the function to use
  28566. */
  28567. Engine.prototype.setDepthFunction = function (depthFunc) {
  28568. this._depthCullingState.depthFunc = depthFunc;
  28569. };
  28570. /**
  28571. * Sets the current depth function to GREATER
  28572. */
  28573. Engine.prototype.setDepthFunctionToGreater = function () {
  28574. this._depthCullingState.depthFunc = this._gl.GREATER;
  28575. };
  28576. /**
  28577. * Sets the current depth function to GEQUAL
  28578. */
  28579. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  28580. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  28581. };
  28582. /**
  28583. * Sets the current depth function to LESS
  28584. */
  28585. Engine.prototype.setDepthFunctionToLess = function () {
  28586. this._depthCullingState.depthFunc = this._gl.LESS;
  28587. };
  28588. /**
  28589. * Sets the current depth function to LEQUAL
  28590. */
  28591. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  28592. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  28593. };
  28594. /**
  28595. * Gets a boolean indicating if stencil buffer is enabled
  28596. * @returns the current stencil buffer state
  28597. */
  28598. Engine.prototype.getStencilBuffer = function () {
  28599. return this._stencilState.stencilTest;
  28600. };
  28601. /**
  28602. * Enable or disable the stencil buffer
  28603. * @param enable defines if the stencil buffer must be enabled or disabled
  28604. */
  28605. Engine.prototype.setStencilBuffer = function (enable) {
  28606. this._stencilState.stencilTest = enable;
  28607. };
  28608. /**
  28609. * Gets the current stencil mask
  28610. * @returns a number defining the new stencil mask to use
  28611. */
  28612. Engine.prototype.getStencilMask = function () {
  28613. return this._stencilState.stencilMask;
  28614. };
  28615. /**
  28616. * Sets the current stencil mask
  28617. * @param mask defines the new stencil mask to use
  28618. */
  28619. Engine.prototype.setStencilMask = function (mask) {
  28620. this._stencilState.stencilMask = mask;
  28621. };
  28622. /**
  28623. * Gets the current stencil function
  28624. * @returns a number defining the stencil function to use
  28625. */
  28626. Engine.prototype.getStencilFunction = function () {
  28627. return this._stencilState.stencilFunc;
  28628. };
  28629. /**
  28630. * Gets the current stencil reference value
  28631. * @returns a number defining the stencil reference value to use
  28632. */
  28633. Engine.prototype.getStencilFunctionReference = function () {
  28634. return this._stencilState.stencilFuncRef;
  28635. };
  28636. /**
  28637. * Gets the current stencil mask
  28638. * @returns a number defining the stencil mask to use
  28639. */
  28640. Engine.prototype.getStencilFunctionMask = function () {
  28641. return this._stencilState.stencilFuncMask;
  28642. };
  28643. /**
  28644. * Sets the current stencil function
  28645. * @param stencilFunc defines the new stencil function to use
  28646. */
  28647. Engine.prototype.setStencilFunction = function (stencilFunc) {
  28648. this._stencilState.stencilFunc = stencilFunc;
  28649. };
  28650. /**
  28651. * Sets the current stencil reference
  28652. * @param reference defines the new stencil reference to use
  28653. */
  28654. Engine.prototype.setStencilFunctionReference = function (reference) {
  28655. this._stencilState.stencilFuncRef = reference;
  28656. };
  28657. /**
  28658. * Sets the current stencil mask
  28659. * @param mask defines the new stencil mask to use
  28660. */
  28661. Engine.prototype.setStencilFunctionMask = function (mask) {
  28662. this._stencilState.stencilFuncMask = mask;
  28663. };
  28664. /**
  28665. * Gets the current stencil operation when stencil fails
  28666. * @returns a number defining stencil operation to use when stencil fails
  28667. */
  28668. Engine.prototype.getStencilOperationFail = function () {
  28669. return this._stencilState.stencilOpStencilFail;
  28670. };
  28671. /**
  28672. * Gets the current stencil operation when depth fails
  28673. * @returns a number defining stencil operation to use when depth fails
  28674. */
  28675. Engine.prototype.getStencilOperationDepthFail = function () {
  28676. return this._stencilState.stencilOpDepthFail;
  28677. };
  28678. /**
  28679. * Gets the current stencil operation when stencil passes
  28680. * @returns a number defining stencil operation to use when stencil passes
  28681. */
  28682. Engine.prototype.getStencilOperationPass = function () {
  28683. return this._stencilState.stencilOpStencilDepthPass;
  28684. };
  28685. /**
  28686. * Sets the stencil operation to use when stencil fails
  28687. * @param operation defines the stencil operation to use when stencil fails
  28688. */
  28689. Engine.prototype.setStencilOperationFail = function (operation) {
  28690. this._stencilState.stencilOpStencilFail = operation;
  28691. };
  28692. /**
  28693. * Sets the stencil operation to use when depth fails
  28694. * @param operation defines the stencil operation to use when depth fails
  28695. */
  28696. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  28697. this._stencilState.stencilOpDepthFail = operation;
  28698. };
  28699. /**
  28700. * Sets the stencil operation to use when stencil passes
  28701. * @param operation defines the stencil operation to use when stencil passes
  28702. */
  28703. Engine.prototype.setStencilOperationPass = function (operation) {
  28704. this._stencilState.stencilOpStencilDepthPass = operation;
  28705. };
  28706. /**
  28707. * Sets a boolean indicating if the dithering state is enabled or disabled
  28708. * @param value defines the dithering state
  28709. */
  28710. Engine.prototype.setDitheringState = function (value) {
  28711. if (value) {
  28712. this._gl.enable(this._gl.DITHER);
  28713. }
  28714. else {
  28715. this._gl.disable(this._gl.DITHER);
  28716. }
  28717. };
  28718. /**
  28719. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28720. * @param value defines the rasterizer state
  28721. */
  28722. Engine.prototype.setRasterizerState = function (value) {
  28723. if (value) {
  28724. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  28725. }
  28726. else {
  28727. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  28728. }
  28729. };
  28730. /**
  28731. * stop executing a render loop function and remove it from the execution array
  28732. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28733. */
  28734. Engine.prototype.stopRenderLoop = function (renderFunction) {
  28735. if (!renderFunction) {
  28736. this._activeRenderLoops = [];
  28737. return;
  28738. }
  28739. var index = this._activeRenderLoops.indexOf(renderFunction);
  28740. if (index >= 0) {
  28741. this._activeRenderLoops.splice(index, 1);
  28742. }
  28743. };
  28744. /** @hidden */
  28745. Engine.prototype._renderLoop = function () {
  28746. if (!this._contextWasLost) {
  28747. var shouldRender = true;
  28748. if (!this.renderEvenInBackground && this._windowIsBackground) {
  28749. shouldRender = false;
  28750. }
  28751. if (shouldRender) {
  28752. // Start new frame
  28753. this.beginFrame();
  28754. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  28755. var renderFunction = this._activeRenderLoops[index];
  28756. renderFunction();
  28757. }
  28758. // Present
  28759. this.endFrame();
  28760. }
  28761. }
  28762. if (this._activeRenderLoops.length > 0) {
  28763. // Register new frame
  28764. if (this.customAnimationFrameRequester) {
  28765. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  28766. this._frameHandler = this.customAnimationFrameRequester.requestID;
  28767. }
  28768. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28769. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  28770. }
  28771. else {
  28772. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28773. }
  28774. }
  28775. else {
  28776. this._renderingQueueLaunched = false;
  28777. }
  28778. };
  28779. /**
  28780. * Register and execute a render loop. The engine can have more than one render function
  28781. * @param renderFunction defines the function to continuously execute
  28782. */
  28783. Engine.prototype.runRenderLoop = function (renderFunction) {
  28784. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  28785. return;
  28786. }
  28787. this._activeRenderLoops.push(renderFunction);
  28788. if (!this._renderingQueueLaunched) {
  28789. this._renderingQueueLaunched = true;
  28790. this._bindedRenderFunction = this._renderLoop.bind(this);
  28791. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28792. }
  28793. };
  28794. /**
  28795. * Toggle full screen mode
  28796. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28797. */
  28798. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  28799. if (this.isFullscreen) {
  28800. this.exitFullscreen();
  28801. }
  28802. else {
  28803. this.enterFullscreen(requestPointerLock);
  28804. }
  28805. };
  28806. /**
  28807. * Enters full screen mode
  28808. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28809. */
  28810. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  28811. if (!this.isFullscreen) {
  28812. this._pointerLockRequested = requestPointerLock;
  28813. if (this._renderingCanvas) {
  28814. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  28815. }
  28816. }
  28817. };
  28818. /**
  28819. * Exits full screen mode
  28820. */
  28821. Engine.prototype.exitFullscreen = function () {
  28822. if (this.isFullscreen) {
  28823. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  28824. }
  28825. };
  28826. /**
  28827. * Clear the current render buffer or the current render target (if any is set up)
  28828. * @param color defines the color to use
  28829. * @param backBuffer defines if the back buffer must be cleared
  28830. * @param depth defines if the depth buffer must be cleared
  28831. * @param stencil defines if the stencil buffer must be cleared
  28832. */
  28833. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  28834. if (stencil === void 0) { stencil = false; }
  28835. this.applyStates();
  28836. var mode = 0;
  28837. if (backBuffer && color) {
  28838. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  28839. mode |= this._gl.COLOR_BUFFER_BIT;
  28840. }
  28841. if (depth) {
  28842. this._gl.clearDepth(1.0);
  28843. mode |= this._gl.DEPTH_BUFFER_BIT;
  28844. }
  28845. if (stencil) {
  28846. this._gl.clearStencil(0);
  28847. mode |= this._gl.STENCIL_BUFFER_BIT;
  28848. }
  28849. this._gl.clear(mode);
  28850. };
  28851. /**
  28852. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28853. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28854. * @param y defines the y-coordinate of the corner of the clear rectangle
  28855. * @param width defines the width of the clear rectangle
  28856. * @param height defines the height of the clear rectangle
  28857. * @param clearColor defines the clear color
  28858. */
  28859. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  28860. this.enableScissor(x, y, width, height);
  28861. this.clear(clearColor, true, true, true);
  28862. this.disableScissor();
  28863. };
  28864. /**
  28865. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28866. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28867. * @param y defines the y-coordinate of the corner of the clear rectangle
  28868. * @param width defines the width of the clear rectangle
  28869. * @param height defines the height of the clear rectangle
  28870. */
  28871. Engine.prototype.enableScissor = function (x, y, width, height) {
  28872. var gl = this._gl;
  28873. // Change state
  28874. gl.enable(gl.SCISSOR_TEST);
  28875. gl.scissor(x, y, width, height);
  28876. };
  28877. /**
  28878. * Disable previously set scissor test rectangle
  28879. */
  28880. Engine.prototype.disableScissor = function () {
  28881. var gl = this._gl;
  28882. gl.disable(gl.SCISSOR_TEST);
  28883. };
  28884. /** @hidden */
  28885. Engine.prototype._viewport = function (x, y, width, height) {
  28886. if (x !== this._viewportCached.x ||
  28887. y !== this._viewportCached.y ||
  28888. width !== this._viewportCached.z ||
  28889. height !== this._viewportCached.w) {
  28890. this._viewportCached.x = x;
  28891. this._viewportCached.y = y;
  28892. this._viewportCached.z = width;
  28893. this._viewportCached.w = height;
  28894. this._gl.viewport(x, y, width, height);
  28895. }
  28896. };
  28897. /**
  28898. * Set the WebGL's viewport
  28899. * @param viewport defines the viewport element to be used
  28900. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28901. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28902. */
  28903. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  28904. var width = requiredWidth || this.getRenderWidth();
  28905. var height = requiredHeight || this.getRenderHeight();
  28906. var x = viewport.x || 0;
  28907. var y = viewport.y || 0;
  28908. this._cachedViewport = viewport;
  28909. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  28910. };
  28911. /**
  28912. * Directly set the WebGL Viewport
  28913. * @param x defines the x coordinate of the viewport (in screen space)
  28914. * @param y defines the y coordinate of the viewport (in screen space)
  28915. * @param width defines the width of the viewport (in screen space)
  28916. * @param height defines the height of the viewport (in screen space)
  28917. * @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
  28918. */
  28919. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28920. var currentViewport = this._cachedViewport;
  28921. this._cachedViewport = null;
  28922. this._viewport(x, y, width, height);
  28923. return currentViewport;
  28924. };
  28925. /**
  28926. * Begin a new frame
  28927. */
  28928. Engine.prototype.beginFrame = function () {
  28929. this.onBeginFrameObservable.notifyObservers(this);
  28930. this._measureFps();
  28931. };
  28932. /**
  28933. * Enf the current frame
  28934. */
  28935. Engine.prototype.endFrame = function () {
  28936. // Force a flush in case we are using a bad OS.
  28937. if (this._badOS) {
  28938. this.flushFramebuffer();
  28939. }
  28940. // Submit frame to the vr device, if enabled
  28941. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28942. // TODO: We should only submit the frame if we read frameData successfully.
  28943. this._vrDisplay.submitFrame();
  28944. }
  28945. this.onEndFrameObservable.notifyObservers(this);
  28946. };
  28947. /**
  28948. * Resize the view according to the canvas' size
  28949. */
  28950. Engine.prototype.resize = function () {
  28951. // We're not resizing the size of the canvas while in VR mode & presenting
  28952. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28953. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28954. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28955. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28956. }
  28957. };
  28958. /**
  28959. * Force a specific size of the canvas
  28960. * @param width defines the new canvas' width
  28961. * @param height defines the new canvas' height
  28962. */
  28963. Engine.prototype.setSize = function (width, height) {
  28964. if (!this._renderingCanvas) {
  28965. return;
  28966. }
  28967. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28968. return;
  28969. }
  28970. this._renderingCanvas.width = width;
  28971. this._renderingCanvas.height = height;
  28972. for (var index = 0; index < this.scenes.length; index++) {
  28973. var scene = this.scenes[index];
  28974. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28975. var cam = scene.cameras[camIndex];
  28976. cam._currentRenderId = 0;
  28977. }
  28978. }
  28979. if (this.onResizeObservable.hasObservers) {
  28980. this.onResizeObservable.notifyObservers(this);
  28981. }
  28982. };
  28983. // WebVR functions
  28984. /**
  28985. * Gets a boolean indicating if a webVR device was detected
  28986. * @returns true if a webVR device was detected
  28987. */
  28988. Engine.prototype.isVRDevicePresent = function () {
  28989. return !!this._vrDisplay;
  28990. };
  28991. /**
  28992. * Gets the current webVR device
  28993. * @returns the current webVR device (or null)
  28994. */
  28995. Engine.prototype.getVRDevice = function () {
  28996. return this._vrDisplay;
  28997. };
  28998. /**
  28999. * Initializes a webVR display and starts listening to display change events
  29000. * The onVRDisplayChangedObservable will be notified upon these changes
  29001. * @returns The onVRDisplayChangedObservable
  29002. */
  29003. Engine.prototype.initWebVR = function () {
  29004. this.initWebVRAsync();
  29005. return this.onVRDisplayChangedObservable;
  29006. };
  29007. /**
  29008. * Initializes a webVR display and starts listening to display change events
  29009. * The onVRDisplayChangedObservable will be notified upon these changes
  29010. * @returns A promise containing a VRDisplay and if vr is supported
  29011. */
  29012. Engine.prototype.initWebVRAsync = function () {
  29013. var _this = this;
  29014. var notifyObservers = function () {
  29015. var eventArgs = {
  29016. vrDisplay: _this._vrDisplay,
  29017. vrSupported: _this._vrSupported
  29018. };
  29019. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29020. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29021. };
  29022. if (!this._onVrDisplayConnect) {
  29023. this._onVrDisplayConnect = function (event) {
  29024. _this._vrDisplay = event.display;
  29025. notifyObservers();
  29026. };
  29027. this._onVrDisplayDisconnect = function () {
  29028. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29029. _this._vrDisplay = undefined;
  29030. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29031. notifyObservers();
  29032. };
  29033. this._onVrDisplayPresentChange = function () {
  29034. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29035. };
  29036. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29037. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29038. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29039. }
  29040. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29041. this._webVRInitPromise.then(notifyObservers);
  29042. return this._webVRInitPromise;
  29043. };
  29044. /**
  29045. * Call this function to switch to webVR mode
  29046. * Will do nothing if webVR is not supported or if there is no webVR device
  29047. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29048. */
  29049. Engine.prototype.enableVR = function () {
  29050. var _this = this;
  29051. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29052. var onResolved = function () {
  29053. _this.onVRRequestPresentComplete.notifyObservers(true);
  29054. _this._onVRFullScreenTriggered();
  29055. };
  29056. var onRejected = function () {
  29057. _this.onVRRequestPresentComplete.notifyObservers(false);
  29058. };
  29059. this.onVRRequestPresentStart.notifyObservers(this);
  29060. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29061. }
  29062. };
  29063. /**
  29064. * Call this function to leave webVR mode
  29065. * Will do nothing if webVR is not supported or if there is no webVR device
  29066. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29067. */
  29068. Engine.prototype.disableVR = function () {
  29069. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29070. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29071. }
  29072. };
  29073. Engine.prototype._getVRDisplaysAsync = function () {
  29074. var _this = this;
  29075. return new Promise(function (res) {
  29076. if (navigator.getVRDisplays) {
  29077. navigator.getVRDisplays().then(function (devices) {
  29078. _this._vrSupported = true;
  29079. // note that devices may actually be an empty array. This is fine;
  29080. // we expect this._vrDisplay to be undefined in this case.
  29081. _this._vrDisplay = devices[0];
  29082. res({
  29083. vrDisplay: _this._vrDisplay,
  29084. vrSupported: _this._vrSupported
  29085. });
  29086. });
  29087. }
  29088. else {
  29089. _this._vrDisplay = undefined;
  29090. _this._vrSupported = false;
  29091. res({
  29092. vrDisplay: _this._vrDisplay,
  29093. vrSupported: _this._vrSupported
  29094. });
  29095. }
  29096. });
  29097. };
  29098. /**
  29099. * Binds the frame buffer to the specified texture.
  29100. * @param texture The texture to render to or null for the default canvas
  29101. * @param faceIndex The face of the texture to render to in case of cube texture
  29102. * @param requiredWidth The width of the target to render to
  29103. * @param requiredHeight The height of the target to render to
  29104. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29105. * @param depthStencilTexture The depth stencil texture to use to render
  29106. * @param lodLevel defines le lod level to bind to the frame buffer
  29107. */
  29108. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29109. if (lodLevel === void 0) { lodLevel = 0; }
  29110. if (this._currentRenderTarget) {
  29111. this.unBindFramebuffer(this._currentRenderTarget);
  29112. }
  29113. this._currentRenderTarget = texture;
  29114. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29115. var gl = this._gl;
  29116. if (texture.isCube) {
  29117. if (faceIndex === undefined) {
  29118. faceIndex = 0;
  29119. }
  29120. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29121. if (depthStencilTexture) {
  29122. if (depthStencilTexture._generateStencilBuffer) {
  29123. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29124. }
  29125. else {
  29126. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29127. }
  29128. }
  29129. }
  29130. if (this._cachedViewport && !forceFullscreenViewport) {
  29131. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29132. }
  29133. else {
  29134. if (!requiredWidth) {
  29135. requiredWidth = texture.width;
  29136. if (lodLevel) {
  29137. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29138. }
  29139. }
  29140. if (!requiredHeight) {
  29141. requiredHeight = texture.height;
  29142. if (lodLevel) {
  29143. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29144. }
  29145. }
  29146. this._viewport(0, 0, requiredWidth, requiredHeight);
  29147. }
  29148. this.wipeCaches();
  29149. };
  29150. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29151. if (this._currentFramebuffer !== framebuffer) {
  29152. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29153. this._currentFramebuffer = framebuffer;
  29154. }
  29155. };
  29156. /**
  29157. * Unbind the current render target texture from the webGL context
  29158. * @param texture defines the render target texture to unbind
  29159. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29160. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29161. */
  29162. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29163. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29164. this._currentRenderTarget = null;
  29165. // If MSAA, we need to bitblt back to main texture
  29166. var gl = this._gl;
  29167. if (texture._MSAAFramebuffer) {
  29168. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29169. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29170. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29171. }
  29172. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29173. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29174. gl.generateMipmap(gl.TEXTURE_2D);
  29175. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29176. }
  29177. if (onBeforeUnbind) {
  29178. if (texture._MSAAFramebuffer) {
  29179. // Bind the correct framebuffer
  29180. this.bindUnboundFramebuffer(texture._framebuffer);
  29181. }
  29182. onBeforeUnbind();
  29183. }
  29184. this.bindUnboundFramebuffer(null);
  29185. };
  29186. /**
  29187. * Unbind a list of render target textures from the webGL context
  29188. * This is used only when drawBuffer extension or webGL2 are active
  29189. * @param textures defines the render target textures to unbind
  29190. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29191. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29192. */
  29193. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29194. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29195. this._currentRenderTarget = null;
  29196. // If MSAA, we need to bitblt back to main texture
  29197. var gl = this._gl;
  29198. if (textures[0]._MSAAFramebuffer) {
  29199. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29200. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29201. var attachments = textures[0]._attachments;
  29202. if (!attachments) {
  29203. attachments = new Array(textures.length);
  29204. textures[0]._attachments = attachments;
  29205. }
  29206. for (var i = 0; i < textures.length; i++) {
  29207. var texture = textures[i];
  29208. for (var j = 0; j < attachments.length; j++) {
  29209. attachments[j] = gl.NONE;
  29210. }
  29211. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29212. gl.readBuffer(attachments[i]);
  29213. gl.drawBuffers(attachments);
  29214. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29215. }
  29216. for (var i = 0; i < attachments.length; i++) {
  29217. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29218. }
  29219. gl.drawBuffers(attachments);
  29220. }
  29221. for (var i = 0; i < textures.length; i++) {
  29222. var texture = textures[i];
  29223. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29224. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29225. gl.generateMipmap(gl.TEXTURE_2D);
  29226. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29227. }
  29228. }
  29229. if (onBeforeUnbind) {
  29230. if (textures[0]._MSAAFramebuffer) {
  29231. // Bind the correct framebuffer
  29232. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29233. }
  29234. onBeforeUnbind();
  29235. }
  29236. this.bindUnboundFramebuffer(null);
  29237. };
  29238. /**
  29239. * Force the mipmap generation for the given render target texture
  29240. * @param texture defines the render target texture to use
  29241. */
  29242. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29243. if (texture.generateMipMaps) {
  29244. var gl = this._gl;
  29245. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29246. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29247. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29248. }
  29249. };
  29250. /**
  29251. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29252. */
  29253. Engine.prototype.flushFramebuffer = function () {
  29254. this._gl.flush();
  29255. };
  29256. /**
  29257. * Unbind the current render target and bind the default framebuffer
  29258. */
  29259. Engine.prototype.restoreDefaultFramebuffer = function () {
  29260. if (this._currentRenderTarget) {
  29261. this.unBindFramebuffer(this._currentRenderTarget);
  29262. }
  29263. else {
  29264. this.bindUnboundFramebuffer(null);
  29265. }
  29266. if (this._cachedViewport) {
  29267. this.setViewport(this._cachedViewport);
  29268. }
  29269. this.wipeCaches();
  29270. };
  29271. // UBOs
  29272. /**
  29273. * Create an uniform buffer
  29274. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29275. * @param elements defines the content of the uniform buffer
  29276. * @returns the webGL uniform buffer
  29277. */
  29278. Engine.prototype.createUniformBuffer = function (elements) {
  29279. var ubo = this._gl.createBuffer();
  29280. if (!ubo) {
  29281. throw new Error("Unable to create uniform buffer");
  29282. }
  29283. this.bindUniformBuffer(ubo);
  29284. if (elements instanceof Float32Array) {
  29285. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29286. }
  29287. else {
  29288. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29289. }
  29290. this.bindUniformBuffer(null);
  29291. ubo.references = 1;
  29292. return ubo;
  29293. };
  29294. /**
  29295. * Create a dynamic uniform buffer
  29296. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29297. * @param elements defines the content of the uniform buffer
  29298. * @returns the webGL uniform buffer
  29299. */
  29300. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29301. var ubo = this._gl.createBuffer();
  29302. if (!ubo) {
  29303. throw new Error("Unable to create dynamic uniform buffer");
  29304. }
  29305. this.bindUniformBuffer(ubo);
  29306. if (elements instanceof Float32Array) {
  29307. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29308. }
  29309. else {
  29310. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29311. }
  29312. this.bindUniformBuffer(null);
  29313. ubo.references = 1;
  29314. return ubo;
  29315. };
  29316. /**
  29317. * Update an existing uniform buffer
  29318. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29319. * @param uniformBuffer defines the target uniform buffer
  29320. * @param elements defines the content to update
  29321. * @param offset defines the offset in the uniform buffer where update should start
  29322. * @param count defines the size of the data to update
  29323. */
  29324. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29325. this.bindUniformBuffer(uniformBuffer);
  29326. if (offset === undefined) {
  29327. offset = 0;
  29328. }
  29329. if (count === undefined) {
  29330. if (elements instanceof Float32Array) {
  29331. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29332. }
  29333. else {
  29334. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29335. }
  29336. }
  29337. else {
  29338. if (elements instanceof Float32Array) {
  29339. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29340. }
  29341. else {
  29342. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29343. }
  29344. }
  29345. this.bindUniformBuffer(null);
  29346. };
  29347. // VBOs
  29348. Engine.prototype._resetVertexBufferBinding = function () {
  29349. this.bindArrayBuffer(null);
  29350. this._cachedVertexBuffers = null;
  29351. };
  29352. /**
  29353. * Creates a vertex buffer
  29354. * @param data the data for the vertex buffer
  29355. * @returns the new WebGL static buffer
  29356. */
  29357. Engine.prototype.createVertexBuffer = function (data) {
  29358. var vbo = this._gl.createBuffer();
  29359. if (!vbo) {
  29360. throw new Error("Unable to create vertex buffer");
  29361. }
  29362. this.bindArrayBuffer(vbo);
  29363. if (data instanceof Array) {
  29364. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29365. }
  29366. else {
  29367. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29368. }
  29369. this._resetVertexBufferBinding();
  29370. vbo.references = 1;
  29371. return vbo;
  29372. };
  29373. /**
  29374. * Creates a dynamic vertex buffer
  29375. * @param data the data for the dynamic vertex buffer
  29376. * @returns the new WebGL dynamic buffer
  29377. */
  29378. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29379. var vbo = this._gl.createBuffer();
  29380. if (!vbo) {
  29381. throw new Error("Unable to create dynamic vertex buffer");
  29382. }
  29383. this.bindArrayBuffer(vbo);
  29384. if (data instanceof Array) {
  29385. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29386. }
  29387. else {
  29388. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29389. }
  29390. this._resetVertexBufferBinding();
  29391. vbo.references = 1;
  29392. return vbo;
  29393. };
  29394. /**
  29395. * Update a dynamic index buffer
  29396. * @param indexBuffer defines the target index buffer
  29397. * @param indices defines the data to update
  29398. * @param offset defines the offset in the target index buffer where update should start
  29399. */
  29400. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29401. if (offset === void 0) { offset = 0; }
  29402. // Force cache update
  29403. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29404. this.bindIndexBuffer(indexBuffer);
  29405. var arrayBuffer;
  29406. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29407. arrayBuffer = indices;
  29408. }
  29409. else {
  29410. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29411. }
  29412. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29413. this._resetIndexBufferBinding();
  29414. };
  29415. /**
  29416. * Updates a dynamic vertex buffer.
  29417. * @param vertexBuffer the vertex buffer to update
  29418. * @param data the data used to update the vertex buffer
  29419. * @param byteOffset the byte offset of the data
  29420. * @param byteLength the byte length of the data
  29421. */
  29422. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29423. this.bindArrayBuffer(vertexBuffer);
  29424. if (byteOffset === undefined) {
  29425. byteOffset = 0;
  29426. }
  29427. if (byteLength === undefined) {
  29428. if (data instanceof Array) {
  29429. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  29430. }
  29431. else {
  29432. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  29433. }
  29434. }
  29435. else {
  29436. if (data instanceof Array) {
  29437. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  29438. }
  29439. else {
  29440. if (data instanceof ArrayBuffer) {
  29441. data = new Uint8Array(data, byteOffset, byteLength);
  29442. }
  29443. else {
  29444. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  29445. }
  29446. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29447. }
  29448. }
  29449. this._resetVertexBufferBinding();
  29450. };
  29451. Engine.prototype._resetIndexBufferBinding = function () {
  29452. this.bindIndexBuffer(null);
  29453. this._cachedIndexBuffer = null;
  29454. };
  29455. /**
  29456. * Creates a new index buffer
  29457. * @param indices defines the content of the index buffer
  29458. * @param updatable defines if the index buffer must be updatable
  29459. * @returns a new webGL buffer
  29460. */
  29461. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  29462. var vbo = this._gl.createBuffer();
  29463. if (!vbo) {
  29464. throw new Error("Unable to create index buffer");
  29465. }
  29466. this.bindIndexBuffer(vbo);
  29467. // Check for 32 bits indices
  29468. var arrayBuffer;
  29469. var need32Bits = false;
  29470. if (indices instanceof Uint16Array) {
  29471. arrayBuffer = indices;
  29472. }
  29473. else {
  29474. //check 32 bit support
  29475. if (this._caps.uintIndices) {
  29476. if (indices instanceof Uint32Array) {
  29477. arrayBuffer = indices;
  29478. need32Bits = true;
  29479. }
  29480. else {
  29481. //number[] or Int32Array, check if 32 bit is necessary
  29482. for (var index = 0; index < indices.length; index++) {
  29483. if (indices[index] > 65535) {
  29484. need32Bits = true;
  29485. break;
  29486. }
  29487. }
  29488. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29489. }
  29490. }
  29491. else {
  29492. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  29493. arrayBuffer = new Uint16Array(indices);
  29494. }
  29495. }
  29496. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  29497. this._resetIndexBufferBinding();
  29498. vbo.references = 1;
  29499. vbo.is32Bits = need32Bits;
  29500. return vbo;
  29501. };
  29502. /**
  29503. * Bind a webGL buffer to the webGL context
  29504. * @param buffer defines the buffer to bind
  29505. */
  29506. Engine.prototype.bindArrayBuffer = function (buffer) {
  29507. if (!this._vaoRecordInProgress) {
  29508. this._unbindVertexArrayObject();
  29509. }
  29510. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  29511. };
  29512. /**
  29513. * Bind an uniform buffer to the current webGL context
  29514. * @param buffer defines the buffer to bind
  29515. */
  29516. Engine.prototype.bindUniformBuffer = function (buffer) {
  29517. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  29518. };
  29519. /**
  29520. * Bind a buffer to the current webGL context at a given location
  29521. * @param buffer defines the buffer to bind
  29522. * @param location defines the index where to bind the buffer
  29523. */
  29524. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  29525. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  29526. };
  29527. /**
  29528. * Bind a specific block at a given index in a specific shader program
  29529. * @param shaderProgram defines the shader program
  29530. * @param blockName defines the block name
  29531. * @param index defines the index where to bind the block
  29532. */
  29533. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  29534. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  29535. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  29536. };
  29537. Engine.prototype.bindIndexBuffer = function (buffer) {
  29538. if (!this._vaoRecordInProgress) {
  29539. this._unbindVertexArrayObject();
  29540. }
  29541. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  29542. };
  29543. Engine.prototype.bindBuffer = function (buffer, target) {
  29544. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  29545. this._gl.bindBuffer(target, buffer);
  29546. this._currentBoundBuffer[target] = buffer;
  29547. }
  29548. };
  29549. /**
  29550. * update the bound buffer with the given data
  29551. * @param data defines the data to update
  29552. */
  29553. Engine.prototype.updateArrayBuffer = function (data) {
  29554. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29555. };
  29556. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  29557. var pointer = this._currentBufferPointers[indx];
  29558. var changed = false;
  29559. if (!pointer.active) {
  29560. changed = true;
  29561. pointer.active = true;
  29562. pointer.index = indx;
  29563. pointer.size = size;
  29564. pointer.type = type;
  29565. pointer.normalized = normalized;
  29566. pointer.stride = stride;
  29567. pointer.offset = offset;
  29568. pointer.buffer = buffer;
  29569. }
  29570. else {
  29571. if (pointer.buffer !== buffer) {
  29572. pointer.buffer = buffer;
  29573. changed = true;
  29574. }
  29575. if (pointer.size !== size) {
  29576. pointer.size = size;
  29577. changed = true;
  29578. }
  29579. if (pointer.type !== type) {
  29580. pointer.type = type;
  29581. changed = true;
  29582. }
  29583. if (pointer.normalized !== normalized) {
  29584. pointer.normalized = normalized;
  29585. changed = true;
  29586. }
  29587. if (pointer.stride !== stride) {
  29588. pointer.stride = stride;
  29589. changed = true;
  29590. }
  29591. if (pointer.offset !== offset) {
  29592. pointer.offset = offset;
  29593. changed = true;
  29594. }
  29595. }
  29596. if (changed || this._vaoRecordInProgress) {
  29597. this.bindArrayBuffer(buffer);
  29598. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  29599. }
  29600. };
  29601. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  29602. if (indexBuffer == null) {
  29603. return;
  29604. }
  29605. if (this._cachedIndexBuffer !== indexBuffer) {
  29606. this._cachedIndexBuffer = indexBuffer;
  29607. this.bindIndexBuffer(indexBuffer);
  29608. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  29609. }
  29610. };
  29611. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  29612. var attributes = effect.getAttributesNames();
  29613. if (!this._vaoRecordInProgress) {
  29614. this._unbindVertexArrayObject();
  29615. }
  29616. this.unbindAllAttributes();
  29617. for (var index = 0; index < attributes.length; index++) {
  29618. var order = effect.getAttributeLocation(index);
  29619. if (order >= 0) {
  29620. var vertexBuffer = vertexBuffers[attributes[index]];
  29621. if (!vertexBuffer) {
  29622. continue;
  29623. }
  29624. this._gl.enableVertexAttribArray(order);
  29625. if (!this._vaoRecordInProgress) {
  29626. this._vertexAttribArraysEnabled[order] = true;
  29627. }
  29628. var buffer = vertexBuffer.getBuffer();
  29629. if (buffer) {
  29630. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  29631. if (vertexBuffer.getIsInstanced()) {
  29632. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  29633. if (!this._vaoRecordInProgress) {
  29634. this._currentInstanceLocations.push(order);
  29635. this._currentInstanceBuffers.push(buffer);
  29636. }
  29637. }
  29638. }
  29639. }
  29640. }
  29641. };
  29642. /**
  29643. * Records a vertex array object
  29644. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29645. * @param vertexBuffers defines the list of vertex buffers to store
  29646. * @param indexBuffer defines the index buffer to store
  29647. * @param effect defines the effect to store
  29648. * @returns the new vertex array object
  29649. */
  29650. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  29651. var vao = this._gl.createVertexArray();
  29652. this._vaoRecordInProgress = true;
  29653. this._gl.bindVertexArray(vao);
  29654. this._mustWipeVertexAttributes = true;
  29655. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29656. this.bindIndexBuffer(indexBuffer);
  29657. this._vaoRecordInProgress = false;
  29658. this._gl.bindVertexArray(null);
  29659. return vao;
  29660. };
  29661. /**
  29662. * Bind a specific vertex array object
  29663. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29664. * @param vertexArrayObject defines the vertex array object to bind
  29665. * @param indexBuffer defines the index buffer to bind
  29666. */
  29667. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  29668. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  29669. this._cachedVertexArrayObject = vertexArrayObject;
  29670. this._gl.bindVertexArray(vertexArrayObject);
  29671. this._cachedVertexBuffers = null;
  29672. this._cachedIndexBuffer = null;
  29673. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  29674. this._mustWipeVertexAttributes = true;
  29675. }
  29676. };
  29677. /**
  29678. * Bind webGl buffers directly to the webGL context
  29679. * @param vertexBuffer defines the vertex buffer to bind
  29680. * @param indexBuffer defines the index buffer to bind
  29681. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29682. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29683. * @param effect defines the effect associated with the vertex buffer
  29684. */
  29685. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  29686. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  29687. this._cachedVertexBuffers = vertexBuffer;
  29688. this._cachedEffectForVertexBuffers = effect;
  29689. var attributesCount = effect.getAttributesCount();
  29690. this._unbindVertexArrayObject();
  29691. this.unbindAllAttributes();
  29692. var offset = 0;
  29693. for (var index = 0; index < attributesCount; index++) {
  29694. if (index < vertexDeclaration.length) {
  29695. var order = effect.getAttributeLocation(index);
  29696. if (order >= 0) {
  29697. this._gl.enableVertexAttribArray(order);
  29698. this._vertexAttribArraysEnabled[order] = true;
  29699. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  29700. }
  29701. offset += vertexDeclaration[index] * 4;
  29702. }
  29703. }
  29704. }
  29705. this._bindIndexBufferWithCache(indexBuffer);
  29706. };
  29707. Engine.prototype._unbindVertexArrayObject = function () {
  29708. if (!this._cachedVertexArrayObject) {
  29709. return;
  29710. }
  29711. this._cachedVertexArrayObject = null;
  29712. this._gl.bindVertexArray(null);
  29713. };
  29714. /**
  29715. * Bind a list of vertex buffers to the webGL context
  29716. * @param vertexBuffers defines the list of vertex buffers to bind
  29717. * @param indexBuffer defines the index buffer to bind
  29718. * @param effect defines the effect associated with the vertex buffers
  29719. */
  29720. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  29721. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  29722. this._cachedVertexBuffers = vertexBuffers;
  29723. this._cachedEffectForVertexBuffers = effect;
  29724. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29725. }
  29726. this._bindIndexBufferWithCache(indexBuffer);
  29727. };
  29728. /**
  29729. * Unbind all instance attributes
  29730. */
  29731. Engine.prototype.unbindInstanceAttributes = function () {
  29732. var boundBuffer;
  29733. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  29734. var instancesBuffer = this._currentInstanceBuffers[i];
  29735. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  29736. boundBuffer = instancesBuffer;
  29737. this.bindArrayBuffer(instancesBuffer);
  29738. }
  29739. var offsetLocation = this._currentInstanceLocations[i];
  29740. this._gl.vertexAttribDivisor(offsetLocation, 0);
  29741. }
  29742. this._currentInstanceBuffers.length = 0;
  29743. this._currentInstanceLocations.length = 0;
  29744. };
  29745. /**
  29746. * Release and free the memory of a vertex array object
  29747. * @param vao defines the vertex array object to delete
  29748. */
  29749. Engine.prototype.releaseVertexArrayObject = function (vao) {
  29750. this._gl.deleteVertexArray(vao);
  29751. };
  29752. /** @hidden */
  29753. Engine.prototype._releaseBuffer = function (buffer) {
  29754. buffer.references--;
  29755. if (buffer.references === 0) {
  29756. this._gl.deleteBuffer(buffer);
  29757. return true;
  29758. }
  29759. return false;
  29760. };
  29761. /**
  29762. * Creates a webGL buffer to use with instanciation
  29763. * @param capacity defines the size of the buffer
  29764. * @returns the webGL buffer
  29765. */
  29766. Engine.prototype.createInstancesBuffer = function (capacity) {
  29767. var buffer = this._gl.createBuffer();
  29768. if (!buffer) {
  29769. throw new Error("Unable to create instance buffer");
  29770. }
  29771. buffer.capacity = capacity;
  29772. this.bindArrayBuffer(buffer);
  29773. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  29774. return buffer;
  29775. };
  29776. /**
  29777. * Delete a webGL buffer used with instanciation
  29778. * @param buffer defines the webGL buffer to delete
  29779. */
  29780. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  29781. this._gl.deleteBuffer(buffer);
  29782. };
  29783. /**
  29784. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29785. * @param instancesBuffer defines the webGL buffer to update and bind
  29786. * @param data defines the data to store in the buffer
  29787. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29788. */
  29789. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  29790. this.bindArrayBuffer(instancesBuffer);
  29791. if (data) {
  29792. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29793. }
  29794. if (offsetLocations[0].index !== undefined) {
  29795. var stride = 0;
  29796. for (var i = 0; i < offsetLocations.length; i++) {
  29797. var ai = offsetLocations[i];
  29798. stride += ai.attributeSize * 4;
  29799. }
  29800. for (var i = 0; i < offsetLocations.length; i++) {
  29801. var ai = offsetLocations[i];
  29802. if (!this._vertexAttribArraysEnabled[ai.index]) {
  29803. this._gl.enableVertexAttribArray(ai.index);
  29804. this._vertexAttribArraysEnabled[ai.index] = true;
  29805. }
  29806. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  29807. this._gl.vertexAttribDivisor(ai.index, 1);
  29808. this._currentInstanceLocations.push(ai.index);
  29809. this._currentInstanceBuffers.push(instancesBuffer);
  29810. }
  29811. }
  29812. else {
  29813. for (var index = 0; index < 4; index++) {
  29814. var offsetLocation = offsetLocations[index];
  29815. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  29816. this._gl.enableVertexAttribArray(offsetLocation);
  29817. this._vertexAttribArraysEnabled[offsetLocation] = true;
  29818. }
  29819. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  29820. this._gl.vertexAttribDivisor(offsetLocation, 1);
  29821. this._currentInstanceLocations.push(offsetLocation);
  29822. this._currentInstanceBuffers.push(instancesBuffer);
  29823. }
  29824. }
  29825. };
  29826. /**
  29827. * Apply all cached states (depth, culling, stencil and alpha)
  29828. */
  29829. Engine.prototype.applyStates = function () {
  29830. this._depthCullingState.apply(this._gl);
  29831. this._stencilState.apply(this._gl);
  29832. this._alphaState.apply(this._gl);
  29833. };
  29834. /**
  29835. * Send a draw order
  29836. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29837. * @param indexStart defines the starting index
  29838. * @param indexCount defines the number of index to draw
  29839. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29840. */
  29841. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  29842. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  29843. };
  29844. /**
  29845. * Draw a list of points
  29846. * @param verticesStart defines the index of first vertex to draw
  29847. * @param verticesCount defines the count of vertices to draw
  29848. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29849. */
  29850. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  29851. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  29852. };
  29853. /**
  29854. * Draw a list of unindexed primitives
  29855. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29856. * @param verticesStart defines the index of first vertex to draw
  29857. * @param verticesCount defines the count of vertices to draw
  29858. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29859. */
  29860. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  29861. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  29862. };
  29863. /**
  29864. * Draw a list of indexed primitives
  29865. * @param fillMode defines the primitive to use
  29866. * @param indexStart defines the starting index
  29867. * @param indexCount defines the number of index to draw
  29868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29869. */
  29870. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  29871. // Apply states
  29872. this.applyStates();
  29873. this._drawCalls.addCount(1, false);
  29874. // Render
  29875. var drawMode = this._drawMode(fillMode);
  29876. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  29877. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  29878. if (instancesCount) {
  29879. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  29880. }
  29881. else {
  29882. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  29883. }
  29884. };
  29885. /**
  29886. * Draw a list of unindexed primitives
  29887. * @param fillMode defines the primitive to use
  29888. * @param verticesStart defines the index of first vertex to draw
  29889. * @param verticesCount defines the count of vertices to draw
  29890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29891. */
  29892. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  29893. // Apply states
  29894. this.applyStates();
  29895. this._drawCalls.addCount(1, false);
  29896. var drawMode = this._drawMode(fillMode);
  29897. if (instancesCount) {
  29898. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  29899. }
  29900. else {
  29901. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  29902. }
  29903. };
  29904. Engine.prototype._drawMode = function (fillMode) {
  29905. switch (fillMode) {
  29906. // Triangle views
  29907. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  29908. return this._gl.TRIANGLES;
  29909. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  29910. return this._gl.POINTS;
  29911. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  29912. return this._gl.LINES;
  29913. // Draw modes
  29914. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  29915. return this._gl.POINTS;
  29916. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29917. return this._gl.LINES;
  29918. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29919. return this._gl.LINE_LOOP;
  29920. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29921. return this._gl.LINE_STRIP;
  29922. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29923. return this._gl.TRIANGLE_STRIP;
  29924. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29925. return this._gl.TRIANGLE_FAN;
  29926. default:
  29927. return this._gl.TRIANGLES;
  29928. }
  29929. };
  29930. // Shaders
  29931. /** @hidden */
  29932. Engine.prototype._releaseEffect = function (effect) {
  29933. if (this._compiledEffects[effect._key]) {
  29934. delete this._compiledEffects[effect._key];
  29935. this._deleteProgram(effect.getProgram());
  29936. }
  29937. };
  29938. /** @hidden */
  29939. Engine.prototype._deleteProgram = function (program) {
  29940. if (program) {
  29941. program.__SPECTOR_rebuildProgram = null;
  29942. if (program.transformFeedback) {
  29943. this.deleteTransformFeedback(program.transformFeedback);
  29944. program.transformFeedback = null;
  29945. }
  29946. this._gl.deleteProgram(program);
  29947. }
  29948. };
  29949. /**
  29950. * Create a new effect (used to store vertex/fragment shaders)
  29951. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29952. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29953. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29954. * @param samplers defines an array of string used to represent textures
  29955. * @param defines defines the string containing the defines to use to compile the shaders
  29956. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29957. * @param onCompiled defines a function to call when the effect creation is successful
  29958. * @param onError defines a function to call when the effect creation has failed
  29959. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29960. * @returns the new Effect
  29961. */
  29962. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29963. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29964. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29965. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29966. if (this._compiledEffects[name]) {
  29967. var compiledEffect = this._compiledEffects[name];
  29968. if (onCompiled && compiledEffect.isReady()) {
  29969. onCompiled(compiledEffect);
  29970. }
  29971. return compiledEffect;
  29972. }
  29973. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29974. effect._key = name;
  29975. this._compiledEffects[name] = effect;
  29976. return effect;
  29977. };
  29978. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  29979. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  29980. };
  29981. Engine.prototype._compileRawShader = function (source, type) {
  29982. var gl = this._gl;
  29983. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  29984. if (!shader) {
  29985. throw new Error("Something went wrong while compile the shader.");
  29986. }
  29987. gl.shaderSource(shader, source);
  29988. gl.compileShader(shader);
  29989. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  29990. var log = gl.getShaderInfoLog(shader);
  29991. if (log) {
  29992. throw new Error(log);
  29993. }
  29994. }
  29995. return shader;
  29996. };
  29997. /**
  29998. * Directly creates a webGL program
  29999. * @param vertexCode defines the vertex shader code to use
  30000. * @param fragmentCode defines the fragment shader code to use
  30001. * @param context defines the webGL context to use (if not set, the current one will be used)
  30002. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30003. * @returns the new webGL program
  30004. */
  30005. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30006. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30007. context = context || this._gl;
  30008. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30009. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30010. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30011. };
  30012. /**
  30013. * Creates a webGL program
  30014. * @param vertexCode defines the vertex shader code to use
  30015. * @param fragmentCode defines the fragment shader code to use
  30016. * @param defines defines the string containing the defines to use to compile the shaders
  30017. * @param context defines the webGL context to use (if not set, the current one will be used)
  30018. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30019. * @returns the new webGL program
  30020. */
  30021. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30022. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30023. context = context || this._gl;
  30024. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30025. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30026. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30027. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30028. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30029. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30030. return program;
  30031. };
  30032. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30033. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30034. var shaderProgram = context.createProgram();
  30035. if (!shaderProgram) {
  30036. throw new Error("Unable to create program");
  30037. }
  30038. context.attachShader(shaderProgram, vertexShader);
  30039. context.attachShader(shaderProgram, fragmentShader);
  30040. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30041. var transformFeedback = this.createTransformFeedback();
  30042. this.bindTransformFeedback(transformFeedback);
  30043. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30044. shaderProgram.transformFeedback = transformFeedback;
  30045. }
  30046. context.linkProgram(shaderProgram);
  30047. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30048. this.bindTransformFeedback(null);
  30049. }
  30050. shaderProgram.context = context;
  30051. shaderProgram.vertexShader = vertexShader;
  30052. shaderProgram.fragmentShader = fragmentShader;
  30053. if (!this._caps.parallelShaderCompile) {
  30054. this._finalizeProgram(shaderProgram);
  30055. }
  30056. else {
  30057. shaderProgram.isParallelCompiled = true;
  30058. }
  30059. return shaderProgram;
  30060. };
  30061. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30062. var context = shaderProgram.context;
  30063. var vertexShader = shaderProgram.vertexShader;
  30064. var fragmentShader = shaderProgram.fragmentShader;
  30065. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30066. if (!linked) {
  30067. var error = context.getProgramInfoLog(shaderProgram);
  30068. if (error) {
  30069. throw new Error(error);
  30070. }
  30071. }
  30072. if (this.validateShaderPrograms) {
  30073. context.validateProgram(shaderProgram);
  30074. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30075. if (!validated) {
  30076. var error = context.getProgramInfoLog(shaderProgram);
  30077. if (error) {
  30078. throw new Error(error);
  30079. }
  30080. }
  30081. }
  30082. context.deleteShader(vertexShader);
  30083. context.deleteShader(fragmentShader);
  30084. shaderProgram.context = undefined;
  30085. shaderProgram.vertexShader = undefined;
  30086. shaderProgram.fragmentShader = undefined;
  30087. if (shaderProgram.onCompiled) {
  30088. shaderProgram.onCompiled();
  30089. shaderProgram.onCompiled = undefined;
  30090. }
  30091. };
  30092. /** @hidden */
  30093. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30094. if (!shaderProgram.isParallelCompiled) {
  30095. return true;
  30096. }
  30097. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30098. this._finalizeProgram(shaderProgram);
  30099. return true;
  30100. }
  30101. return false;
  30102. };
  30103. /** @hidden */
  30104. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30105. if (!shaderProgram.isParallelCompiled) {
  30106. action();
  30107. return;
  30108. }
  30109. shaderProgram.onCompiled = action;
  30110. };
  30111. /**
  30112. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30113. * @param shaderProgram defines the webGL program to use
  30114. * @param uniformsNames defines the list of uniform names
  30115. * @returns an array of webGL uniform locations
  30116. */
  30117. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30118. var results = new Array();
  30119. for (var index = 0; index < uniformsNames.length; index++) {
  30120. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30121. }
  30122. return results;
  30123. };
  30124. /**
  30125. * Gets the lsit of active attributes for a given webGL program
  30126. * @param shaderProgram defines the webGL program to use
  30127. * @param attributesNames defines the list of attribute names to get
  30128. * @returns an array of indices indicating the offset of each attribute
  30129. */
  30130. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30131. var results = [];
  30132. for (var index = 0; index < attributesNames.length; index++) {
  30133. try {
  30134. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30135. }
  30136. catch (e) {
  30137. results.push(-1);
  30138. }
  30139. }
  30140. return results;
  30141. };
  30142. /**
  30143. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30144. * @param effect defines the effect to activate
  30145. */
  30146. Engine.prototype.enableEffect = function (effect) {
  30147. if (!effect || effect === this._currentEffect) {
  30148. return;
  30149. }
  30150. // Use program
  30151. this.bindSamplers(effect);
  30152. this._currentEffect = effect;
  30153. if (effect.onBind) {
  30154. effect.onBind(effect);
  30155. }
  30156. if (effect._onBindObservable) {
  30157. effect._onBindObservable.notifyObservers(effect);
  30158. }
  30159. };
  30160. /**
  30161. * Set the value of an uniform to an array of int32
  30162. * @param uniform defines the webGL uniform location where to store the value
  30163. * @param array defines the array of int32 to store
  30164. */
  30165. Engine.prototype.setIntArray = function (uniform, array) {
  30166. if (!uniform) {
  30167. return;
  30168. }
  30169. this._gl.uniform1iv(uniform, array);
  30170. };
  30171. /**
  30172. * Set the value of an uniform to an array of int32 (stored as vec2)
  30173. * @param uniform defines the webGL uniform location where to store the value
  30174. * @param array defines the array of int32 to store
  30175. */
  30176. Engine.prototype.setIntArray2 = function (uniform, array) {
  30177. if (!uniform || array.length % 2 !== 0) {
  30178. return;
  30179. }
  30180. this._gl.uniform2iv(uniform, array);
  30181. };
  30182. /**
  30183. * Set the value of an uniform to an array of int32 (stored as vec3)
  30184. * @param uniform defines the webGL uniform location where to store the value
  30185. * @param array defines the array of int32 to store
  30186. */
  30187. Engine.prototype.setIntArray3 = function (uniform, array) {
  30188. if (!uniform || array.length % 3 !== 0) {
  30189. return;
  30190. }
  30191. this._gl.uniform3iv(uniform, array);
  30192. };
  30193. /**
  30194. * Set the value of an uniform to an array of int32 (stored as vec4)
  30195. * @param uniform defines the webGL uniform location where to store the value
  30196. * @param array defines the array of int32 to store
  30197. */
  30198. Engine.prototype.setIntArray4 = function (uniform, array) {
  30199. if (!uniform || array.length % 4 !== 0) {
  30200. return;
  30201. }
  30202. this._gl.uniform4iv(uniform, array);
  30203. };
  30204. /**
  30205. * Set the value of an uniform to an array of float32
  30206. * @param uniform defines the webGL uniform location where to store the value
  30207. * @param array defines the array of float32 to store
  30208. */
  30209. Engine.prototype.setFloatArray = function (uniform, array) {
  30210. if (!uniform) {
  30211. return;
  30212. }
  30213. this._gl.uniform1fv(uniform, array);
  30214. };
  30215. /**
  30216. * Set the value of an uniform to an array of float32 (stored as vec2)
  30217. * @param uniform defines the webGL uniform location where to store the value
  30218. * @param array defines the array of float32 to store
  30219. */
  30220. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30221. if (!uniform || array.length % 2 !== 0) {
  30222. return;
  30223. }
  30224. this._gl.uniform2fv(uniform, array);
  30225. };
  30226. /**
  30227. * Set the value of an uniform to an array of float32 (stored as vec3)
  30228. * @param uniform defines the webGL uniform location where to store the value
  30229. * @param array defines the array of float32 to store
  30230. */
  30231. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30232. if (!uniform || array.length % 3 !== 0) {
  30233. return;
  30234. }
  30235. this._gl.uniform3fv(uniform, array);
  30236. };
  30237. /**
  30238. * Set the value of an uniform to an array of float32 (stored as vec4)
  30239. * @param uniform defines the webGL uniform location where to store the value
  30240. * @param array defines the array of float32 to store
  30241. */
  30242. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30243. if (!uniform || array.length % 4 !== 0) {
  30244. return;
  30245. }
  30246. this._gl.uniform4fv(uniform, array);
  30247. };
  30248. /**
  30249. * Set the value of an uniform to an array of number
  30250. * @param uniform defines the webGL uniform location where to store the value
  30251. * @param array defines the array of number to store
  30252. */
  30253. Engine.prototype.setArray = function (uniform, array) {
  30254. if (!uniform) {
  30255. return;
  30256. }
  30257. this._gl.uniform1fv(uniform, array);
  30258. };
  30259. /**
  30260. * Set the value of an uniform to an array of number (stored as vec2)
  30261. * @param uniform defines the webGL uniform location where to store the value
  30262. * @param array defines the array of number to store
  30263. */
  30264. Engine.prototype.setArray2 = function (uniform, array) {
  30265. if (!uniform || array.length % 2 !== 0) {
  30266. return;
  30267. }
  30268. this._gl.uniform2fv(uniform, array);
  30269. };
  30270. /**
  30271. * Set the value of an uniform to an array of number (stored as vec3)
  30272. * @param uniform defines the webGL uniform location where to store the value
  30273. * @param array defines the array of number to store
  30274. */
  30275. Engine.prototype.setArray3 = function (uniform, array) {
  30276. if (!uniform || array.length % 3 !== 0) {
  30277. return;
  30278. }
  30279. this._gl.uniform3fv(uniform, array);
  30280. };
  30281. /**
  30282. * Set the value of an uniform to an array of number (stored as vec4)
  30283. * @param uniform defines the webGL uniform location where to store the value
  30284. * @param array defines the array of number to store
  30285. */
  30286. Engine.prototype.setArray4 = function (uniform, array) {
  30287. if (!uniform || array.length % 4 !== 0) {
  30288. return;
  30289. }
  30290. this._gl.uniform4fv(uniform, array);
  30291. };
  30292. /**
  30293. * Set the value of an uniform to an array of float32 (stored as matrices)
  30294. * @param uniform defines the webGL uniform location where to store the value
  30295. * @param matrices defines the array of float32 to store
  30296. */
  30297. Engine.prototype.setMatrices = function (uniform, matrices) {
  30298. if (!uniform) {
  30299. return;
  30300. }
  30301. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30302. };
  30303. /**
  30304. * Set the value of an uniform to a matrix
  30305. * @param uniform defines the webGL uniform location where to store the value
  30306. * @param matrix defines the matrix to store
  30307. */
  30308. Engine.prototype.setMatrix = function (uniform, matrix) {
  30309. if (!uniform) {
  30310. return;
  30311. }
  30312. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30313. };
  30314. /**
  30315. * Set the value of an uniform to a matrix (3x3)
  30316. * @param uniform defines the webGL uniform location where to store the value
  30317. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30318. */
  30319. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30320. if (!uniform) {
  30321. return;
  30322. }
  30323. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30324. };
  30325. /**
  30326. * Set the value of an uniform to a matrix (2x2)
  30327. * @param uniform defines the webGL uniform location where to store the value
  30328. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30329. */
  30330. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30331. if (!uniform) {
  30332. return;
  30333. }
  30334. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30335. };
  30336. /**
  30337. * Set the value of an uniform to a number (int)
  30338. * @param uniform defines the webGL uniform location where to store the value
  30339. * @param value defines the int number to store
  30340. */
  30341. Engine.prototype.setInt = function (uniform, value) {
  30342. if (!uniform) {
  30343. return;
  30344. }
  30345. this._gl.uniform1i(uniform, value);
  30346. };
  30347. /**
  30348. * Set the value of an uniform to a number (float)
  30349. * @param uniform defines the webGL uniform location where to store the value
  30350. * @param value defines the float number to store
  30351. */
  30352. Engine.prototype.setFloat = function (uniform, value) {
  30353. if (!uniform) {
  30354. return;
  30355. }
  30356. this._gl.uniform1f(uniform, value);
  30357. };
  30358. /**
  30359. * Set the value of an uniform to a vec2
  30360. * @param uniform defines the webGL uniform location where to store the value
  30361. * @param x defines the 1st component of the value
  30362. * @param y defines the 2nd component of the value
  30363. */
  30364. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30365. if (!uniform) {
  30366. return;
  30367. }
  30368. this._gl.uniform2f(uniform, x, y);
  30369. };
  30370. /**
  30371. * Set the value of an uniform to a vec3
  30372. * @param uniform defines the webGL uniform location where to store the value
  30373. * @param x defines the 1st component of the value
  30374. * @param y defines the 2nd component of the value
  30375. * @param z defines the 3rd component of the value
  30376. */
  30377. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30378. if (!uniform) {
  30379. return;
  30380. }
  30381. this._gl.uniform3f(uniform, x, y, z);
  30382. };
  30383. /**
  30384. * Set the value of an uniform to a boolean
  30385. * @param uniform defines the webGL uniform location where to store the value
  30386. * @param bool defines the boolean to store
  30387. */
  30388. Engine.prototype.setBool = function (uniform, bool) {
  30389. if (!uniform) {
  30390. return;
  30391. }
  30392. this._gl.uniform1i(uniform, bool);
  30393. };
  30394. /**
  30395. * Set the value of an uniform to a vec4
  30396. * @param uniform defines the webGL uniform location where to store the value
  30397. * @param x defines the 1st component of the value
  30398. * @param y defines the 2nd component of the value
  30399. * @param z defines the 3rd component of the value
  30400. * @param w defines the 4th component of the value
  30401. */
  30402. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30403. if (!uniform) {
  30404. return;
  30405. }
  30406. this._gl.uniform4f(uniform, x, y, z, w);
  30407. };
  30408. /**
  30409. * Set the value of an uniform to a Color3
  30410. * @param uniform defines the webGL uniform location where to store the value
  30411. * @param color3 defines the color to store
  30412. */
  30413. Engine.prototype.setColor3 = function (uniform, color3) {
  30414. if (!uniform) {
  30415. return;
  30416. }
  30417. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30418. };
  30419. /**
  30420. * Set the value of an uniform to a Color3 and an alpha value
  30421. * @param uniform defines the webGL uniform location where to store the value
  30422. * @param color3 defines the color to store
  30423. * @param alpha defines the alpha component to store
  30424. */
  30425. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  30426. if (!uniform) {
  30427. return;
  30428. }
  30429. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  30430. };
  30431. /**
  30432. * Sets a Color4 on a uniform variable
  30433. * @param uniform defines the uniform location
  30434. * @param color4 defines the value to be set
  30435. */
  30436. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  30437. if (!uniform) {
  30438. return;
  30439. }
  30440. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  30441. };
  30442. // States
  30443. /**
  30444. * Set various states to the webGL context
  30445. * @param culling defines backface culling state
  30446. * @param zOffset defines the value to apply to zOffset (0 by default)
  30447. * @param force defines if states must be applied even if cache is up to date
  30448. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30449. */
  30450. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  30451. if (zOffset === void 0) { zOffset = 0; }
  30452. if (reverseSide === void 0) { reverseSide = false; }
  30453. // Culling
  30454. if (this._depthCullingState.cull !== culling || force) {
  30455. this._depthCullingState.cull = culling;
  30456. }
  30457. // Cull face
  30458. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  30459. if (this._depthCullingState.cullFace !== cullFace || force) {
  30460. this._depthCullingState.cullFace = cullFace;
  30461. }
  30462. // Z offset
  30463. this.setZOffset(zOffset);
  30464. // Front face
  30465. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  30466. if (this._depthCullingState.frontFace !== frontFace || force) {
  30467. this._depthCullingState.frontFace = frontFace;
  30468. }
  30469. };
  30470. /**
  30471. * Set the z offset to apply to current rendering
  30472. * @param value defines the offset to apply
  30473. */
  30474. Engine.prototype.setZOffset = function (value) {
  30475. this._depthCullingState.zOffset = value;
  30476. };
  30477. /**
  30478. * Gets the current value of the zOffset
  30479. * @returns the current zOffset state
  30480. */
  30481. Engine.prototype.getZOffset = function () {
  30482. return this._depthCullingState.zOffset;
  30483. };
  30484. /**
  30485. * Enable or disable depth buffering
  30486. * @param enable defines the state to set
  30487. */
  30488. Engine.prototype.setDepthBuffer = function (enable) {
  30489. this._depthCullingState.depthTest = enable;
  30490. };
  30491. /**
  30492. * Gets a boolean indicating if depth writing is enabled
  30493. * @returns the current depth writing state
  30494. */
  30495. Engine.prototype.getDepthWrite = function () {
  30496. return this._depthCullingState.depthMask;
  30497. };
  30498. /**
  30499. * Enable or disable depth writing
  30500. * @param enable defines the state to set
  30501. */
  30502. Engine.prototype.setDepthWrite = function (enable) {
  30503. this._depthCullingState.depthMask = enable;
  30504. };
  30505. /**
  30506. * Enable or disable color writing
  30507. * @param enable defines the state to set
  30508. */
  30509. Engine.prototype.setColorWrite = function (enable) {
  30510. this._gl.colorMask(enable, enable, enable, enable);
  30511. this._colorWrite = enable;
  30512. };
  30513. /**
  30514. * Gets a boolean indicating if color writing is enabled
  30515. * @returns the current color writing state
  30516. */
  30517. Engine.prototype.getColorWrite = function () {
  30518. return this._colorWrite;
  30519. };
  30520. /**
  30521. * Sets alpha constants used by some alpha blending modes
  30522. * @param r defines the red component
  30523. * @param g defines the green component
  30524. * @param b defines the blue component
  30525. * @param a defines the alpha component
  30526. */
  30527. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  30528. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  30529. };
  30530. /**
  30531. * Sets the current alpha mode
  30532. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30533. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30534. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30535. */
  30536. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  30537. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  30538. if (this._alphaMode === mode) {
  30539. return;
  30540. }
  30541. switch (mode) {
  30542. case Engine.ALPHA_DISABLE:
  30543. this._alphaState.alphaBlend = false;
  30544. break;
  30545. case Engine.ALPHA_PREMULTIPLIED:
  30546. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30547. this._alphaState.alphaBlend = true;
  30548. break;
  30549. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  30550. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30551. this._alphaState.alphaBlend = true;
  30552. break;
  30553. case Engine.ALPHA_COMBINE:
  30554. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30555. this._alphaState.alphaBlend = true;
  30556. break;
  30557. case Engine.ALPHA_ONEONE:
  30558. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30559. this._alphaState.alphaBlend = true;
  30560. break;
  30561. case Engine.ALPHA_ADD:
  30562. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30563. this._alphaState.alphaBlend = true;
  30564. break;
  30565. case Engine.ALPHA_SUBTRACT:
  30566. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30567. this._alphaState.alphaBlend = true;
  30568. break;
  30569. case Engine.ALPHA_MULTIPLY:
  30570. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  30571. this._alphaState.alphaBlend = true;
  30572. break;
  30573. case Engine.ALPHA_MAXIMIZED:
  30574. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30575. this._alphaState.alphaBlend = true;
  30576. break;
  30577. case Engine.ALPHA_INTERPOLATE:
  30578. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  30579. this._alphaState.alphaBlend = true;
  30580. break;
  30581. case Engine.ALPHA_SCREENMODE:
  30582. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30583. this._alphaState.alphaBlend = true;
  30584. break;
  30585. }
  30586. if (!noDepthWriteChange) {
  30587. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  30588. }
  30589. this._alphaMode = mode;
  30590. };
  30591. /**
  30592. * Gets the current alpha mode
  30593. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30594. * @returns the current alpha mode
  30595. */
  30596. Engine.prototype.getAlphaMode = function () {
  30597. return this._alphaMode;
  30598. };
  30599. // Textures
  30600. /**
  30601. * Clears the list of texture accessible through engine.
  30602. * This can help preventing texture load conflict due to name collision.
  30603. */
  30604. Engine.prototype.clearInternalTexturesCache = function () {
  30605. this._internalTexturesCache = [];
  30606. };
  30607. /**
  30608. * Force the entire cache to be cleared
  30609. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30610. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30611. */
  30612. Engine.prototype.wipeCaches = function (bruteForce) {
  30613. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  30614. return;
  30615. }
  30616. this._currentEffect = null;
  30617. this._viewportCached.x = 0;
  30618. this._viewportCached.y = 0;
  30619. this._viewportCached.z = 0;
  30620. this._viewportCached.w = 0;
  30621. if (bruteForce) {
  30622. this.resetTextureCache();
  30623. this._currentProgram = null;
  30624. this._stencilState.reset();
  30625. this._depthCullingState.reset();
  30626. this.setDepthFunctionToLessOrEqual();
  30627. this._alphaState.reset();
  30628. this._unpackFlipYCached = null;
  30629. }
  30630. this._resetVertexBufferBinding();
  30631. this._cachedIndexBuffer = null;
  30632. this._cachedEffectForVertexBuffers = null;
  30633. this._unbindVertexArrayObject();
  30634. this.bindIndexBuffer(null);
  30635. };
  30636. /**
  30637. * Set the compressed texture format to use, based on the formats you have, and the formats
  30638. * supported by the hardware / browser.
  30639. *
  30640. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30641. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30642. * to API arguments needed to compressed textures. This puts the burden on the container
  30643. * generator to house the arcane code for determining these for current & future formats.
  30644. *
  30645. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30646. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30647. *
  30648. * Note: The result of this call is not taken into account when a texture is base64.
  30649. *
  30650. * @param formatsAvailable defines the list of those format families you have created
  30651. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30652. *
  30653. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30654. * @returns The extension selected.
  30655. */
  30656. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  30657. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  30658. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  30659. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  30660. return this._textureFormatInUse = this._texturesSupported[i];
  30661. }
  30662. }
  30663. }
  30664. // actively set format to nothing, to allow this to be called more than once
  30665. // and possibly fail the 2nd time
  30666. this._textureFormatInUse = null;
  30667. return null;
  30668. };
  30669. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  30670. var gl = this._gl;
  30671. var magFilter = gl.NEAREST;
  30672. var minFilter = gl.NEAREST;
  30673. switch (samplingMode) {
  30674. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  30675. magFilter = gl.LINEAR;
  30676. if (generateMipMaps) {
  30677. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30678. }
  30679. else {
  30680. minFilter = gl.LINEAR;
  30681. }
  30682. break;
  30683. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  30684. magFilter = gl.LINEAR;
  30685. if (generateMipMaps) {
  30686. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30687. }
  30688. else {
  30689. minFilter = gl.LINEAR;
  30690. }
  30691. break;
  30692. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  30693. magFilter = gl.NEAREST;
  30694. if (generateMipMaps) {
  30695. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30696. }
  30697. else {
  30698. minFilter = gl.NEAREST;
  30699. }
  30700. break;
  30701. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  30702. magFilter = gl.NEAREST;
  30703. if (generateMipMaps) {
  30704. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30705. }
  30706. else {
  30707. minFilter = gl.NEAREST;
  30708. }
  30709. break;
  30710. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  30711. magFilter = gl.NEAREST;
  30712. if (generateMipMaps) {
  30713. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30714. }
  30715. else {
  30716. minFilter = gl.LINEAR;
  30717. }
  30718. break;
  30719. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  30720. magFilter = gl.NEAREST;
  30721. if (generateMipMaps) {
  30722. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30723. }
  30724. else {
  30725. minFilter = gl.LINEAR;
  30726. }
  30727. break;
  30728. case Engine.TEXTURE_NEAREST_LINEAR:
  30729. magFilter = gl.NEAREST;
  30730. minFilter = gl.LINEAR;
  30731. break;
  30732. case Engine.TEXTURE_NEAREST_NEAREST:
  30733. magFilter = gl.NEAREST;
  30734. minFilter = gl.NEAREST;
  30735. break;
  30736. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  30737. magFilter = gl.LINEAR;
  30738. if (generateMipMaps) {
  30739. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30740. }
  30741. else {
  30742. minFilter = gl.NEAREST;
  30743. }
  30744. break;
  30745. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  30746. magFilter = gl.LINEAR;
  30747. if (generateMipMaps) {
  30748. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30749. }
  30750. else {
  30751. minFilter = gl.NEAREST;
  30752. }
  30753. break;
  30754. case Engine.TEXTURE_LINEAR_LINEAR:
  30755. magFilter = gl.LINEAR;
  30756. minFilter = gl.LINEAR;
  30757. break;
  30758. case Engine.TEXTURE_LINEAR_NEAREST:
  30759. magFilter = gl.LINEAR;
  30760. minFilter = gl.NEAREST;
  30761. break;
  30762. }
  30763. return {
  30764. min: minFilter,
  30765. mag: magFilter
  30766. };
  30767. };
  30768. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  30769. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  30770. var img;
  30771. var onload = function () {
  30772. loadedImages[index] = img;
  30773. loadedImages._internalCount++;
  30774. if (scene) {
  30775. scene._removePendingData(img);
  30776. }
  30777. if (loadedImages._internalCount === 6) {
  30778. onfinish(loadedImages);
  30779. }
  30780. };
  30781. var onerror = function (message, exception) {
  30782. if (scene) {
  30783. scene._removePendingData(img);
  30784. }
  30785. if (onErrorCallBack) {
  30786. onErrorCallBack(message, exception);
  30787. }
  30788. };
  30789. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  30790. if (scene) {
  30791. scene._addPendingData(img);
  30792. }
  30793. };
  30794. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  30795. if (onError === void 0) { onError = null; }
  30796. var loadedImages = [];
  30797. loadedImages._internalCount = 0;
  30798. for (var index = 0; index < 6; index++) {
  30799. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  30800. }
  30801. };
  30802. /** @hidden */
  30803. Engine.prototype._createTexture = function () {
  30804. var texture = this._gl.createTexture();
  30805. if (!texture) {
  30806. throw new Error("Unable to create texture");
  30807. }
  30808. return texture;
  30809. };
  30810. /**
  30811. * Usually called from Texture.ts.
  30812. * Passed information to create a WebGLTexture
  30813. * @param urlArg defines a value which contains one of the following:
  30814. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30815. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30816. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30817. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30818. * @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)
  30819. * @param scene needed for loading to the correct scene
  30820. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30821. * @param onLoad optional callback to be called upon successful completion
  30822. * @param onError optional callback to be called upon failure
  30823. * @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
  30824. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30825. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30826. * @param forcedExtension defines the extension to use to pick the right loader
  30827. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30828. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30829. */
  30830. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  30831. var _this = this;
  30832. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  30833. if (onLoad === void 0) { onLoad = null; }
  30834. if (onError === void 0) { onError = null; }
  30835. if (buffer === void 0) { buffer = null; }
  30836. if (fallback === void 0) { fallback = null; }
  30837. if (format === void 0) { format = null; }
  30838. if (forcedExtension === void 0) { forcedExtension = null; }
  30839. if (excludeLoaders === void 0) { excludeLoaders = []; }
  30840. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  30841. var fromData = url.substr(0, 5) === "data:";
  30842. var fromBlob = url.substr(0, 5) === "blob:";
  30843. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  30844. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  30845. // establish the file extension, if possible
  30846. var lastDot = url.lastIndexOf('.');
  30847. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  30848. var loader = null;
  30849. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  30850. var availableLoader = _a[_i];
  30851. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  30852. loader = availableLoader;
  30853. break;
  30854. }
  30855. }
  30856. if (loader) {
  30857. url = loader.transformUrl(url, this._textureFormatInUse);
  30858. }
  30859. if (scene) {
  30860. scene._addPendingData(texture);
  30861. }
  30862. texture.url = url;
  30863. texture.generateMipMaps = !noMipmap;
  30864. texture.samplingMode = samplingMode;
  30865. texture.invertY = invertY;
  30866. if (!this._doNotHandleContextLost) {
  30867. // Keep a link to the buffer only if we plan to handle context lost
  30868. texture._buffer = buffer;
  30869. }
  30870. var onLoadObserver = null;
  30871. if (onLoad && !fallback) {
  30872. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  30873. }
  30874. if (!fallback) {
  30875. this._internalTexturesCache.push(texture);
  30876. }
  30877. var onInternalError = function (message, exception) {
  30878. if (scene) {
  30879. scene._removePendingData(texture);
  30880. }
  30881. var customFallback = false;
  30882. if (loader) {
  30883. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  30884. if (fallbackUrl) {
  30885. // Add Back
  30886. customFallback = true;
  30887. excludeLoaders.push(loader);
  30888. _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");
  30889. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  30890. }
  30891. }
  30892. if (!customFallback) {
  30893. if (onLoadObserver) {
  30894. texture.onLoadedObservable.remove(onLoadObserver);
  30895. }
  30896. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  30897. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  30898. }
  30899. }
  30900. if (onError) {
  30901. onError(message || "Unknown error", exception);
  30902. }
  30903. };
  30904. // processing for non-image formats
  30905. if (loader) {
  30906. var callback = function (data) {
  30907. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  30908. if (loadFailed) {
  30909. onInternalError("TextureLoader failed to load data");
  30910. }
  30911. else {
  30912. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  30913. done();
  30914. return false;
  30915. }, samplingMode);
  30916. }
  30917. });
  30918. };
  30919. if (!buffer) {
  30920. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30921. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30922. });
  30923. }
  30924. else {
  30925. callback(buffer);
  30926. }
  30927. }
  30928. else {
  30929. var onload = function (img) {
  30930. if (fromBlob && !_this._doNotHandleContextLost) {
  30931. // We need to store the image if we need to rebuild the texture
  30932. // in case of a webgl context lost
  30933. texture._buffer = img;
  30934. }
  30935. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30936. var gl = _this._gl;
  30937. var isPot = (img.width === potWidth && img.height === potHeight);
  30938. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30939. if (isPot) {
  30940. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30941. return false;
  30942. }
  30943. var maxTextureSize = _this._caps.maxTextureSize;
  30944. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30945. _this._prepareWorkingCanvas();
  30946. if (!_this._workingCanvas || !_this._workingContext) {
  30947. return false;
  30948. }
  30949. _this._workingCanvas.width = potWidth;
  30950. _this._workingCanvas.height = potHeight;
  30951. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30952. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30953. texture.width = potWidth;
  30954. texture.height = potHeight;
  30955. return false;
  30956. }
  30957. else {
  30958. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30959. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30960. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30961. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30962. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30963. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30964. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30965. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30966. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30967. _this._releaseTexture(source_1);
  30968. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30969. continuationCallback();
  30970. });
  30971. }
  30972. return true;
  30973. }, samplingMode);
  30974. };
  30975. if (!fromData || isBase64) {
  30976. if (buffer instanceof HTMLImageElement) {
  30977. onload(buffer);
  30978. }
  30979. else {
  30980. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  30981. }
  30982. }
  30983. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  30984. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  30985. }
  30986. else {
  30987. onload(buffer);
  30988. }
  30989. }
  30990. return texture;
  30991. };
  30992. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  30993. var _this = this;
  30994. var rtt = this.createRenderTargetTexture({
  30995. width: destination.width,
  30996. height: destination.height,
  30997. }, {
  30998. generateMipMaps: false,
  30999. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31000. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31001. generateDepthBuffer: false,
  31002. generateStencilBuffer: false
  31003. });
  31004. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31005. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31006. }
  31007. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31008. _this._rescalePostProcess.onApply = function (effect) {
  31009. effect._bindTexture("textureSampler", source);
  31010. };
  31011. var hostingScene = scene;
  31012. if (!hostingScene) {
  31013. hostingScene = _this.scenes[_this.scenes.length - 1];
  31014. }
  31015. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31016. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31017. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31018. _this.unBindFramebuffer(rtt);
  31019. _this._releaseTexture(rtt);
  31020. if (onComplete) {
  31021. onComplete();
  31022. }
  31023. });
  31024. };
  31025. /**
  31026. * Update a raw texture
  31027. * @param texture defines the texture to update
  31028. * @param data defines the data to store in the texture
  31029. * @param format defines the format of the data
  31030. * @param invertY defines if data must be stored with Y axis inverted
  31031. * @param compression defines the compression used (null by default)
  31032. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31033. */
  31034. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31035. if (compression === void 0) { compression = null; }
  31036. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31037. if (!texture) {
  31038. return;
  31039. }
  31040. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31041. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31042. // babylon's internalFormat but gl's texImage2D format
  31043. var internalFormat = this._getInternalFormat(format);
  31044. var textureType = this._getWebGLTextureType(type);
  31045. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31046. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31047. if (!this._doNotHandleContextLost) {
  31048. texture._bufferView = data;
  31049. texture.format = format;
  31050. texture.type = type;
  31051. texture.invertY = invertY;
  31052. texture._compression = compression;
  31053. }
  31054. if (texture.width % 4 !== 0) {
  31055. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31056. }
  31057. if (compression && data) {
  31058. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31059. }
  31060. else {
  31061. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31062. }
  31063. if (texture.generateMipMaps) {
  31064. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31065. }
  31066. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31067. // this.resetTextureCache();
  31068. texture.isReady = true;
  31069. };
  31070. /**
  31071. * Creates a raw texture
  31072. * @param data defines the data to store in the texture
  31073. * @param width defines the width of the texture
  31074. * @param height defines the height of the texture
  31075. * @param format defines the format of the data
  31076. * @param generateMipMaps defines if the engine should generate the mip levels
  31077. * @param invertY defines if data must be stored with Y axis inverted
  31078. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31079. * @param compression defines the compression used (null by default)
  31080. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31081. * @returns the raw texture inside an InternalTexture
  31082. */
  31083. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31084. if (compression === void 0) { compression = null; }
  31085. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31086. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31087. texture.baseWidth = width;
  31088. texture.baseHeight = height;
  31089. texture.width = width;
  31090. texture.height = height;
  31091. texture.format = format;
  31092. texture.generateMipMaps = generateMipMaps;
  31093. texture.samplingMode = samplingMode;
  31094. texture.invertY = invertY;
  31095. texture._compression = compression;
  31096. texture.type = type;
  31097. if (!this._doNotHandleContextLost) {
  31098. texture._bufferView = data;
  31099. }
  31100. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31101. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31102. // Filters
  31103. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31104. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31105. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31106. if (generateMipMaps) {
  31107. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31108. }
  31109. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31110. this._internalTexturesCache.push(texture);
  31111. return texture;
  31112. };
  31113. /** @hidden */
  31114. Engine.prototype._unpackFlipY = function (value) {
  31115. if (this._unpackFlipYCached !== value) {
  31116. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31117. if (this.enableUnpackFlipYCached) {
  31118. this._unpackFlipYCached = value;
  31119. }
  31120. }
  31121. };
  31122. /** @hidden */
  31123. Engine.prototype._getUnpackAlignement = function () {
  31124. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31125. };
  31126. /**
  31127. * Creates a dynamic texture
  31128. * @param width defines the width of the texture
  31129. * @param height defines the height of the texture
  31130. * @param generateMipMaps defines if the engine should generate the mip levels
  31131. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31132. * @returns the dynamic texture inside an InternalTexture
  31133. */
  31134. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31135. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31136. texture.baseWidth = width;
  31137. texture.baseHeight = height;
  31138. if (generateMipMaps) {
  31139. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31140. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31141. }
  31142. // this.resetTextureCache();
  31143. texture.width = width;
  31144. texture.height = height;
  31145. texture.isReady = false;
  31146. texture.generateMipMaps = generateMipMaps;
  31147. texture.samplingMode = samplingMode;
  31148. this.updateTextureSamplingMode(samplingMode, texture);
  31149. this._internalTexturesCache.push(texture);
  31150. return texture;
  31151. };
  31152. /**
  31153. * Update the sampling mode of a given texture
  31154. * @param samplingMode defines the required sampling mode
  31155. * @param texture defines the texture to update
  31156. */
  31157. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31158. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31159. if (texture.isCube) {
  31160. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31161. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31162. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31163. }
  31164. else if (texture.is3D) {
  31165. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31166. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31167. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31168. }
  31169. else {
  31170. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31171. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31172. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31173. }
  31174. texture.samplingMode = samplingMode;
  31175. };
  31176. /**
  31177. * Update the content of a dynamic texture
  31178. * @param texture defines the texture to update
  31179. * @param canvas defines the canvas containing the source
  31180. * @param invertY defines if data must be stored with Y axis inverted
  31181. * @param premulAlpha defines if alpha is stored as premultiplied
  31182. * @param format defines the format of the data
  31183. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31184. */
  31185. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31186. if (premulAlpha === void 0) { premulAlpha = false; }
  31187. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31188. if (!texture) {
  31189. return;
  31190. }
  31191. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31192. this._unpackFlipY(invertY);
  31193. if (premulAlpha) {
  31194. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31195. }
  31196. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31197. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31198. if (texture.generateMipMaps) {
  31199. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31200. }
  31201. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31202. if (premulAlpha) {
  31203. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31204. }
  31205. texture.isReady = true;
  31206. };
  31207. /**
  31208. * Update a video texture
  31209. * @param texture defines the texture to update
  31210. * @param video defines the video element to use
  31211. * @param invertY defines if data must be stored with Y axis inverted
  31212. */
  31213. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31214. if (!texture || texture._isDisabled) {
  31215. return;
  31216. }
  31217. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31218. this._unpackFlipY(!invertY); // Video are upside down by default
  31219. try {
  31220. // Testing video texture support
  31221. if (this._videoTextureSupported === undefined) {
  31222. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31223. if (this._gl.getError() !== 0) {
  31224. this._videoTextureSupported = false;
  31225. }
  31226. else {
  31227. this._videoTextureSupported = true;
  31228. }
  31229. }
  31230. // Copy video through the current working canvas if video texture is not supported
  31231. if (!this._videoTextureSupported) {
  31232. if (!texture._workingCanvas) {
  31233. texture._workingCanvas = document.createElement("canvas");
  31234. var context = texture._workingCanvas.getContext("2d");
  31235. if (!context) {
  31236. throw new Error("Unable to get 2d context");
  31237. }
  31238. texture._workingContext = context;
  31239. texture._workingCanvas.width = texture.width;
  31240. texture._workingCanvas.height = texture.height;
  31241. }
  31242. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31243. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31244. }
  31245. else {
  31246. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31247. }
  31248. if (texture.generateMipMaps) {
  31249. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31250. }
  31251. if (!wasPreviouslyBound) {
  31252. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31253. }
  31254. // this.resetTextureCache();
  31255. texture.isReady = true;
  31256. }
  31257. catch (ex) {
  31258. // Something unexpected
  31259. // Let's disable the texture
  31260. texture._isDisabled = true;
  31261. }
  31262. };
  31263. /**
  31264. * Updates a depth texture Comparison Mode and Function.
  31265. * If the comparison Function is equal to 0, the mode will be set to none.
  31266. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31267. * @param texture The texture to set the comparison function for
  31268. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31269. */
  31270. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31271. if (this.webGLVersion === 1) {
  31272. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31273. return;
  31274. }
  31275. var gl = this._gl;
  31276. if (texture.isCube) {
  31277. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31278. if (comparisonFunction === 0) {
  31279. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31280. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31281. }
  31282. else {
  31283. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31284. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31285. }
  31286. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31287. }
  31288. else {
  31289. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31290. if (comparisonFunction === 0) {
  31291. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31292. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31293. }
  31294. else {
  31295. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31296. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31297. }
  31298. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31299. }
  31300. texture._comparisonFunction = comparisonFunction;
  31301. };
  31302. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31303. var width = size.width || size;
  31304. var height = size.height || size;
  31305. internalTexture.baseWidth = width;
  31306. internalTexture.baseHeight = height;
  31307. internalTexture.width = width;
  31308. internalTexture.height = height;
  31309. internalTexture.isReady = true;
  31310. internalTexture.samples = 1;
  31311. internalTexture.generateMipMaps = false;
  31312. internalTexture._generateDepthBuffer = true;
  31313. internalTexture._generateStencilBuffer = generateStencil;
  31314. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31315. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31316. internalTexture._comparisonFunction = comparisonFunction;
  31317. var gl = this._gl;
  31318. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31319. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31320. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31321. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31322. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31323. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31324. if (comparisonFunction === 0) {
  31325. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31326. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31327. }
  31328. else {
  31329. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31330. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31331. }
  31332. };
  31333. /**
  31334. * Creates a depth stencil texture.
  31335. * This is only available in WebGL 2 or with the depth texture extension available.
  31336. * @param size The size of face edge in the texture.
  31337. * @param options The options defining the texture.
  31338. * @returns The texture
  31339. */
  31340. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31341. if (options.isCube) {
  31342. var width = size.width || size;
  31343. return this._createDepthStencilCubeTexture(width, options);
  31344. }
  31345. else {
  31346. return this._createDepthStencilTexture(size, options);
  31347. }
  31348. };
  31349. /**
  31350. * Creates a depth stencil texture.
  31351. * This is only available in WebGL 2 or with the depth texture extension available.
  31352. * @param size The size of face edge in the texture.
  31353. * @param options The options defining the texture.
  31354. * @returns The texture
  31355. */
  31356. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31357. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31358. if (!this._caps.depthTextureExtension) {
  31359. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31360. return internalTexture;
  31361. }
  31362. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31363. var gl = this._gl;
  31364. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31365. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31366. if (this.webGLVersion > 1) {
  31367. if (internalOptions.generateStencil) {
  31368. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31369. }
  31370. else {
  31371. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31372. }
  31373. }
  31374. else {
  31375. if (internalOptions.generateStencil) {
  31376. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31377. }
  31378. else {
  31379. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31380. }
  31381. }
  31382. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31383. return internalTexture;
  31384. };
  31385. /**
  31386. * Creates a depth stencil cube texture.
  31387. * This is only available in WebGL 2.
  31388. * @param size The size of face edge in the cube texture.
  31389. * @param options The options defining the cube texture.
  31390. * @returns The cube texture
  31391. */
  31392. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31393. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31394. internalTexture.isCube = true;
  31395. if (this.webGLVersion === 1) {
  31396. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31397. return internalTexture;
  31398. }
  31399. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31400. var gl = this._gl;
  31401. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31402. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31403. // Create the depth/stencil buffer
  31404. for (var face = 0; face < 6; face++) {
  31405. if (internalOptions.generateStencil) {
  31406. 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);
  31407. }
  31408. else {
  31409. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31410. }
  31411. }
  31412. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31413. return internalTexture;
  31414. };
  31415. /**
  31416. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31417. * @param renderTarget The render target to set the frame buffer for
  31418. */
  31419. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31420. // Create the framebuffer
  31421. var internalTexture = renderTarget.getInternalTexture();
  31422. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31423. return;
  31424. }
  31425. var gl = this._gl;
  31426. var depthStencilTexture = renderTarget.depthStencilTexture;
  31427. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  31428. if (depthStencilTexture.isCube) {
  31429. if (depthStencilTexture._generateStencilBuffer) {
  31430. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31431. }
  31432. else {
  31433. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31434. }
  31435. }
  31436. else {
  31437. if (depthStencilTexture._generateStencilBuffer) {
  31438. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31439. }
  31440. else {
  31441. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31442. }
  31443. }
  31444. this.bindUnboundFramebuffer(null);
  31445. };
  31446. /**
  31447. * Creates a new render target texture
  31448. * @param size defines the size of the texture
  31449. * @param options defines the options used to create the texture
  31450. * @returns a new render target texture stored in an InternalTexture
  31451. */
  31452. Engine.prototype.createRenderTargetTexture = function (size, options) {
  31453. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  31454. if (options !== undefined && typeof options === "object") {
  31455. fullOptions.generateMipMaps = options.generateMipMaps;
  31456. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31457. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  31458. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  31459. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  31460. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  31461. }
  31462. else {
  31463. fullOptions.generateMipMaps = options;
  31464. fullOptions.generateDepthBuffer = true;
  31465. fullOptions.generateStencilBuffer = false;
  31466. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31467. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31468. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  31469. }
  31470. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31471. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31472. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31473. }
  31474. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31475. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31476. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31477. }
  31478. var gl = this._gl;
  31479. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31480. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31481. var width = size.width || size;
  31482. var height = size.height || size;
  31483. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  31484. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31485. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31486. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31487. }
  31488. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31489. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31490. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31491. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31492. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  31493. // Create the framebuffer
  31494. var currentFrameBuffer = this._currentFramebuffer;
  31495. var framebuffer = gl.createFramebuffer();
  31496. this.bindUnboundFramebuffer(framebuffer);
  31497. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31498. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  31499. if (fullOptions.generateMipMaps) {
  31500. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31501. }
  31502. // Unbind
  31503. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31504. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31505. this.bindUnboundFramebuffer(currentFrameBuffer);
  31506. texture._framebuffer = framebuffer;
  31507. texture.baseWidth = width;
  31508. texture.baseHeight = height;
  31509. texture.width = width;
  31510. texture.height = height;
  31511. texture.isReady = true;
  31512. texture.samples = 1;
  31513. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  31514. texture.samplingMode = fullOptions.samplingMode;
  31515. texture.type = fullOptions.type;
  31516. texture.format = fullOptions.format;
  31517. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31518. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  31519. // this.resetTextureCache();
  31520. this._internalTexturesCache.push(texture);
  31521. return texture;
  31522. };
  31523. /**
  31524. * Create a multi render target texture
  31525. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  31526. * @param size defines the size of the texture
  31527. * @param options defines the creation options
  31528. * @returns the cube texture as an InternalTexture
  31529. */
  31530. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  31531. var generateMipMaps = false;
  31532. var generateDepthBuffer = true;
  31533. var generateStencilBuffer = false;
  31534. var generateDepthTexture = false;
  31535. var textureCount = 1;
  31536. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  31537. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31538. var types = new Array();
  31539. var samplingModes = new Array();
  31540. if (options !== undefined) {
  31541. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  31542. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31543. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  31544. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  31545. textureCount = options.textureCount || 1;
  31546. if (options.types) {
  31547. types = options.types;
  31548. }
  31549. if (options.samplingModes) {
  31550. samplingModes = options.samplingModes;
  31551. }
  31552. }
  31553. var gl = this._gl;
  31554. // Create the framebuffer
  31555. var framebuffer = gl.createFramebuffer();
  31556. this.bindUnboundFramebuffer(framebuffer);
  31557. var width = size.width || size;
  31558. var height = size.height || size;
  31559. var textures = [];
  31560. var attachments = [];
  31561. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  31562. for (var i = 0; i < textureCount; i++) {
  31563. var samplingMode = samplingModes[i] || defaultSamplingMode;
  31564. var type = types[i] || defaultType;
  31565. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31566. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31567. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31568. }
  31569. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31570. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31571. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31572. }
  31573. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31574. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31575. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31576. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31577. }
  31578. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31579. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31580. textures.push(texture);
  31581. attachments.push(attachment);
  31582. gl.activeTexture(gl["TEXTURE" + i]);
  31583. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  31584. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31585. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31586. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31587. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31588. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  31589. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31590. if (generateMipMaps) {
  31591. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31592. }
  31593. // Unbind
  31594. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31595. texture._framebuffer = framebuffer;
  31596. texture._depthStencilBuffer = depthStencilBuffer;
  31597. texture.baseWidth = width;
  31598. texture.baseHeight = height;
  31599. texture.width = width;
  31600. texture.height = height;
  31601. texture.isReady = true;
  31602. texture.samples = 1;
  31603. texture.generateMipMaps = generateMipMaps;
  31604. texture.samplingMode = samplingMode;
  31605. texture.type = type;
  31606. texture._generateDepthBuffer = generateDepthBuffer;
  31607. texture._generateStencilBuffer = generateStencilBuffer;
  31608. texture._attachments = attachments;
  31609. this._internalTexturesCache.push(texture);
  31610. }
  31611. if (generateDepthTexture && this._caps.depthTextureExtension) {
  31612. // Depth texture
  31613. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31614. gl.activeTexture(gl.TEXTURE0);
  31615. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  31616. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  31617. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  31618. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31619. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31620. 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);
  31621. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  31622. depthTexture._framebuffer = framebuffer;
  31623. depthTexture.baseWidth = width;
  31624. depthTexture.baseHeight = height;
  31625. depthTexture.width = width;
  31626. depthTexture.height = height;
  31627. depthTexture.isReady = true;
  31628. depthTexture.samples = 1;
  31629. depthTexture.generateMipMaps = generateMipMaps;
  31630. depthTexture.samplingMode = gl.NEAREST;
  31631. depthTexture._generateDepthBuffer = generateDepthBuffer;
  31632. depthTexture._generateStencilBuffer = generateStencilBuffer;
  31633. textures.push(depthTexture);
  31634. this._internalTexturesCache.push(depthTexture);
  31635. }
  31636. gl.drawBuffers(attachments);
  31637. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31638. this.bindUnboundFramebuffer(null);
  31639. this.resetTextureCache();
  31640. return textures;
  31641. };
  31642. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  31643. if (samples === void 0) { samples = 1; }
  31644. var depthStencilBuffer = null;
  31645. var gl = this._gl;
  31646. // Create the depth/stencil buffer
  31647. if (generateStencilBuffer) {
  31648. depthStencilBuffer = gl.createRenderbuffer();
  31649. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31650. if (samples > 1) {
  31651. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  31652. }
  31653. else {
  31654. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  31655. }
  31656. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31657. }
  31658. else if (generateDepthBuffer) {
  31659. depthStencilBuffer = gl.createRenderbuffer();
  31660. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31661. if (samples > 1) {
  31662. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  31663. }
  31664. else {
  31665. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  31666. }
  31667. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31668. }
  31669. return depthStencilBuffer;
  31670. };
  31671. /**
  31672. * Updates the sample count of a render target texture
  31673. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31674. * @param texture defines the texture to update
  31675. * @param samples defines the sample count to set
  31676. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31677. */
  31678. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  31679. if (this.webGLVersion < 2 || !texture) {
  31680. return 1;
  31681. }
  31682. if (texture.samples === samples) {
  31683. return samples;
  31684. }
  31685. var gl = this._gl;
  31686. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31687. // Dispose previous render buffers
  31688. if (texture._depthStencilBuffer) {
  31689. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31690. texture._depthStencilBuffer = null;
  31691. }
  31692. if (texture._MSAAFramebuffer) {
  31693. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31694. texture._MSAAFramebuffer = null;
  31695. }
  31696. if (texture._MSAARenderBuffer) {
  31697. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31698. texture._MSAARenderBuffer = null;
  31699. }
  31700. if (samples > 1) {
  31701. var framebuffer = gl.createFramebuffer();
  31702. if (!framebuffer) {
  31703. throw new Error("Unable to create multi sampled framebuffer");
  31704. }
  31705. texture._MSAAFramebuffer = framebuffer;
  31706. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  31707. var colorRenderbuffer = gl.createRenderbuffer();
  31708. if (!colorRenderbuffer) {
  31709. throw new Error("Unable to create multi sampled framebuffer");
  31710. }
  31711. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31712. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31713. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  31714. texture._MSAARenderBuffer = colorRenderbuffer;
  31715. }
  31716. else {
  31717. this.bindUnboundFramebuffer(texture._framebuffer);
  31718. }
  31719. texture.samples = samples;
  31720. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  31721. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31722. this.bindUnboundFramebuffer(null);
  31723. return samples;
  31724. };
  31725. /**
  31726. * Update the sample count for a given multiple render target texture
  31727. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31728. * @param textures defines the textures to update
  31729. * @param samples defines the sample count to set
  31730. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31731. */
  31732. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  31733. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  31734. return 1;
  31735. }
  31736. if (textures[0].samples === samples) {
  31737. return samples;
  31738. }
  31739. var gl = this._gl;
  31740. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31741. // Dispose previous render buffers
  31742. if (textures[0]._depthStencilBuffer) {
  31743. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  31744. textures[0]._depthStencilBuffer = null;
  31745. }
  31746. if (textures[0]._MSAAFramebuffer) {
  31747. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  31748. textures[0]._MSAAFramebuffer = null;
  31749. }
  31750. for (var i = 0; i < textures.length; i++) {
  31751. if (textures[i]._MSAARenderBuffer) {
  31752. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  31753. textures[i]._MSAARenderBuffer = null;
  31754. }
  31755. }
  31756. if (samples > 1) {
  31757. var framebuffer = gl.createFramebuffer();
  31758. if (!framebuffer) {
  31759. throw new Error("Unable to create multi sampled framebuffer");
  31760. }
  31761. this.bindUnboundFramebuffer(framebuffer);
  31762. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  31763. var attachments = [];
  31764. for (var i = 0; i < textures.length; i++) {
  31765. var texture = textures[i];
  31766. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31767. var colorRenderbuffer = gl.createRenderbuffer();
  31768. if (!colorRenderbuffer) {
  31769. throw new Error("Unable to create multi sampled framebuffer");
  31770. }
  31771. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31772. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31773. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  31774. texture._MSAAFramebuffer = framebuffer;
  31775. texture._MSAARenderBuffer = colorRenderbuffer;
  31776. texture.samples = samples;
  31777. texture._depthStencilBuffer = depthStencilBuffer;
  31778. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31779. attachments.push(attachment);
  31780. }
  31781. gl.drawBuffers(attachments);
  31782. }
  31783. else {
  31784. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  31785. }
  31786. this.bindUnboundFramebuffer(null);
  31787. return samples;
  31788. };
  31789. /** @hidden */
  31790. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  31791. if (faceIndex === void 0) { faceIndex = 0; }
  31792. if (lod === void 0) { lod = 0; }
  31793. var gl = this._gl;
  31794. var target = gl.TEXTURE_2D;
  31795. if (texture.isCube) {
  31796. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31797. }
  31798. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  31799. };
  31800. /** @hidden */
  31801. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  31802. if (faceIndex === void 0) { faceIndex = 0; }
  31803. if (lod === void 0) { lod = 0; }
  31804. var gl = this._gl;
  31805. var textureType = this._getWebGLTextureType(texture.type);
  31806. var format = this._getInternalFormat(texture.format);
  31807. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31808. this._unpackFlipY(texture.invertY);
  31809. var target = gl.TEXTURE_2D;
  31810. if (texture.isCube) {
  31811. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31812. }
  31813. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  31814. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  31815. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  31816. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  31817. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  31818. };
  31819. /** @hidden */
  31820. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  31821. if (faceIndex === void 0) { faceIndex = 0; }
  31822. if (lod === void 0) { lod = 0; }
  31823. var gl = this._gl;
  31824. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31825. this._bindTextureDirectly(bindTarget, texture, true);
  31826. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  31827. this._bindTextureDirectly(bindTarget, null, true);
  31828. };
  31829. /** @hidden */
  31830. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  31831. if (faceIndex === void 0) { faceIndex = 0; }
  31832. if (lod === void 0) { lod = 0; }
  31833. var gl = this._gl;
  31834. var textureType = this._getWebGLTextureType(texture.type);
  31835. var format = this._getInternalFormat(texture.format);
  31836. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31837. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31838. this._bindTextureDirectly(bindTarget, texture, true);
  31839. this._unpackFlipY(texture.invertY);
  31840. var target = gl.TEXTURE_2D;
  31841. if (texture.isCube) {
  31842. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31843. }
  31844. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  31845. this._bindTextureDirectly(bindTarget, null, true);
  31846. };
  31847. /**
  31848. * Creates a new render target cube texture
  31849. * @param size defines the size of the texture
  31850. * @param options defines the options used to create the texture
  31851. * @returns a new render target cube texture stored in an InternalTexture
  31852. */
  31853. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  31854. 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);
  31855. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  31856. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31857. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31858. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31859. }
  31860. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31861. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31862. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31863. }
  31864. var gl = this._gl;
  31865. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31866. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31867. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  31868. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31869. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31870. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  31871. }
  31872. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31873. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31874. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31875. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31876. for (var face = 0; face < 6; face++) {
  31877. 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);
  31878. }
  31879. // Create the framebuffer
  31880. var framebuffer = gl.createFramebuffer();
  31881. this.bindUnboundFramebuffer(framebuffer);
  31882. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  31883. // MipMaps
  31884. if (fullOptions.generateMipMaps) {
  31885. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31886. }
  31887. // Unbind
  31888. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31889. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31890. this.bindUnboundFramebuffer(null);
  31891. texture._framebuffer = framebuffer;
  31892. texture.width = size;
  31893. texture.height = size;
  31894. texture.isReady = true;
  31895. texture.isCube = true;
  31896. texture.samples = 1;
  31897. texture.generateMipMaps = fullOptions.generateMipMaps;
  31898. texture.samplingMode = fullOptions.samplingMode;
  31899. texture.type = fullOptions.type;
  31900. texture.format = fullOptions.format;
  31901. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31902. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  31903. this._internalTexturesCache.push(texture);
  31904. return texture;
  31905. };
  31906. /**
  31907. * Creates a cube texture
  31908. * @param rootUrl defines the url where the files to load is located
  31909. * @param scene defines the current scene
  31910. * @param files defines the list of files to load (1 per face)
  31911. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31912. * @param onLoad defines an optional callback raised when the texture is loaded
  31913. * @param onError defines an optional callback raised if there is an issue to load the texture
  31914. * @param format defines the format of the data
  31915. * @param forcedExtension defines the extension to use to pick the right loader
  31916. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31917. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31918. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31919. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31920. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31921. * @returns the cube texture as an InternalTexture
  31922. */
  31923. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31924. var _this = this;
  31925. if (onLoad === void 0) { onLoad = null; }
  31926. if (onError === void 0) { onError = null; }
  31927. if (forcedExtension === void 0) { forcedExtension = null; }
  31928. if (createPolynomials === void 0) { createPolynomials = false; }
  31929. if (lodScale === void 0) { lodScale = 0; }
  31930. if (lodOffset === void 0) { lodOffset = 0; }
  31931. if (fallback === void 0) { fallback = null; }
  31932. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31933. var gl = this._gl;
  31934. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31935. texture.isCube = true;
  31936. texture.url = rootUrl;
  31937. texture.generateMipMaps = !noMipmap;
  31938. texture._lodGenerationScale = lodScale;
  31939. texture._lodGenerationOffset = lodOffset;
  31940. if (!this._doNotHandleContextLost) {
  31941. texture._extension = forcedExtension;
  31942. texture._files = files;
  31943. }
  31944. var lastDot = rootUrl.lastIndexOf('.');
  31945. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31946. var loader = null;
  31947. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31948. var availableLoader = _a[_i];
  31949. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31950. loader = availableLoader;
  31951. break;
  31952. }
  31953. }
  31954. var onInternalError = function (request, exception) {
  31955. if (loader) {
  31956. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31957. _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");
  31958. if (fallbackUrl) {
  31959. excludeLoaders.push(loader);
  31960. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31961. return;
  31962. }
  31963. }
  31964. if (onError && request) {
  31965. onError(request.status + " " + request.statusText, exception);
  31966. }
  31967. };
  31968. if (loader) {
  31969. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31970. var onloaddata = function (data) {
  31971. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31972. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31973. };
  31974. if (files && files.length === 6) {
  31975. if (loader.supportCascades) {
  31976. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31977. }
  31978. else if (onError) {
  31979. onError("Textures type does not support cascades.");
  31980. }
  31981. }
  31982. else {
  31983. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  31984. }
  31985. }
  31986. else {
  31987. if (!files) {
  31988. throw new Error("Cannot load cubemap because files were not defined");
  31989. }
  31990. this._cascadeLoadImgs(scene, function (imgs) {
  31991. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  31992. var height = width;
  31993. _this._prepareWorkingCanvas();
  31994. if (!_this._workingCanvas || !_this._workingContext) {
  31995. return;
  31996. }
  31997. _this._workingCanvas.width = width;
  31998. _this._workingCanvas.height = height;
  31999. var faces = [
  32000. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32001. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32002. ];
  32003. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32004. _this._unpackFlipY(false);
  32005. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32006. for (var index = 0; index < faces.length; index++) {
  32007. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32008. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32009. }
  32010. if (!noMipmap) {
  32011. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32012. }
  32013. _this._setCubeMapTextureParams(!noMipmap);
  32014. texture.width = width;
  32015. texture.height = height;
  32016. texture.isReady = true;
  32017. if (format) {
  32018. texture.format = format;
  32019. }
  32020. texture.onLoadedObservable.notifyObservers(texture);
  32021. texture.onLoadedObservable.clear();
  32022. if (onLoad) {
  32023. onLoad();
  32024. }
  32025. }, files, onError);
  32026. }
  32027. this._internalTexturesCache.push(texture);
  32028. return texture;
  32029. };
  32030. /**
  32031. * @hidden
  32032. */
  32033. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32034. var gl = this._gl;
  32035. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32036. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32037. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32038. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32039. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32040. // this.resetTextureCache();
  32041. };
  32042. /**
  32043. * Update a raw cube texture
  32044. * @param texture defines the texture to udpdate
  32045. * @param data defines the data to store
  32046. * @param format defines the data format
  32047. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32048. * @param invertY defines if data must be stored with Y axis inverted
  32049. * @param compression defines the compression used (null by default)
  32050. * @param level defines which level of the texture to update
  32051. */
  32052. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32053. if (compression === void 0) { compression = null; }
  32054. if (level === void 0) { level = 0; }
  32055. texture._bufferViewArray = data;
  32056. texture.format = format;
  32057. texture.type = type;
  32058. texture.invertY = invertY;
  32059. texture._compression = compression;
  32060. var gl = this._gl;
  32061. var textureType = this._getWebGLTextureType(type);
  32062. var internalFormat = this._getInternalFormat(format);
  32063. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32064. var needConversion = false;
  32065. if (internalFormat === gl.RGB) {
  32066. internalFormat = gl.RGBA;
  32067. needConversion = true;
  32068. }
  32069. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32070. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32071. if (texture.width % 4 !== 0) {
  32072. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32073. }
  32074. // Data are known to be in +X +Y +Z -X -Y -Z
  32075. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32076. var faceData = data[faceIndex];
  32077. if (compression) {
  32078. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32079. }
  32080. else {
  32081. if (needConversion) {
  32082. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32083. }
  32084. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32085. }
  32086. }
  32087. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32088. if (isPot && texture.generateMipMaps && level === 0) {
  32089. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32090. }
  32091. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32092. // this.resetTextureCache();
  32093. texture.isReady = true;
  32094. };
  32095. /**
  32096. * Creates a new raw cube texture
  32097. * @param data defines the array of data to use to create each face
  32098. * @param size defines the size of the textures
  32099. * @param format defines the format of the data
  32100. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32101. * @param generateMipMaps defines if the engine should generate the mip levels
  32102. * @param invertY defines if data must be stored with Y axis inverted
  32103. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32104. * @param compression defines the compression used (null by default)
  32105. * @returns the cube texture as an InternalTexture
  32106. */
  32107. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32108. if (compression === void 0) { compression = null; }
  32109. var gl = this._gl;
  32110. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32111. texture.isCube = true;
  32112. texture.format = format;
  32113. texture.type = type;
  32114. if (!this._doNotHandleContextLost) {
  32115. texture._bufferViewArray = data;
  32116. }
  32117. var textureType = this._getWebGLTextureType(type);
  32118. var internalFormat = this._getInternalFormat(format);
  32119. if (internalFormat === gl.RGB) {
  32120. internalFormat = gl.RGBA;
  32121. }
  32122. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32123. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32124. generateMipMaps = false;
  32125. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32126. _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.");
  32127. }
  32128. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32129. generateMipMaps = false;
  32130. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32131. _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.");
  32132. }
  32133. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32134. generateMipMaps = false;
  32135. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32136. }
  32137. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32138. generateMipMaps = false;
  32139. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32140. }
  32141. var width = size;
  32142. var height = width;
  32143. texture.width = width;
  32144. texture.height = height;
  32145. // Double check on POT to generate Mips.
  32146. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32147. if (!isPot) {
  32148. generateMipMaps = false;
  32149. }
  32150. // Upload data if needed. The texture won't be ready until then.
  32151. if (data) {
  32152. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32153. }
  32154. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32155. // Filters
  32156. if (data && generateMipMaps) {
  32157. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32158. }
  32159. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32160. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32161. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32162. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32163. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32164. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32165. texture.generateMipMaps = generateMipMaps;
  32166. return texture;
  32167. };
  32168. /**
  32169. * Creates a new raw cube texture from a specified url
  32170. * @param url defines the url where the data is located
  32171. * @param scene defines the current scene
  32172. * @param size defines the size of the textures
  32173. * @param format defines the format of the data
  32174. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32175. * @param noMipmap defines if the engine should avoid generating the mip levels
  32176. * @param callback defines a callback used to extract texture data from loaded data
  32177. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32178. * @param onLoad defines a callback called when texture is loaded
  32179. * @param onError defines a callback called if there is an error
  32180. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32181. * @param invertY defines if data must be stored with Y axis inverted
  32182. * @returns the cube texture as an InternalTexture
  32183. */
  32184. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32185. var _this = this;
  32186. if (onLoad === void 0) { onLoad = null; }
  32187. if (onError === void 0) { onError = null; }
  32188. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32189. if (invertY === void 0) { invertY = false; }
  32190. var gl = this._gl;
  32191. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32192. scene._addPendingData(texture);
  32193. texture.url = url;
  32194. this._internalTexturesCache.push(texture);
  32195. var onerror = function (request, exception) {
  32196. scene._removePendingData(texture);
  32197. if (onError && request) {
  32198. onError(request.status + " " + request.statusText, exception);
  32199. }
  32200. };
  32201. var internalCallback = function (data) {
  32202. var width = texture.width;
  32203. var faceDataArrays = callback(data);
  32204. if (!faceDataArrays) {
  32205. return;
  32206. }
  32207. if (mipmapGenerator) {
  32208. var textureType = _this._getWebGLTextureType(type);
  32209. var internalFormat = _this._getInternalFormat(format);
  32210. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32211. var needConversion = false;
  32212. if (internalFormat === gl.RGB) {
  32213. internalFormat = gl.RGBA;
  32214. needConversion = true;
  32215. }
  32216. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32217. _this._unpackFlipY(false);
  32218. var mipData = mipmapGenerator(faceDataArrays);
  32219. for (var level = 0; level < mipData.length; level++) {
  32220. var mipSize = width >> level;
  32221. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32222. var mipFaceData = mipData[level][faceIndex];
  32223. if (needConversion) {
  32224. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32225. }
  32226. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32227. }
  32228. }
  32229. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32230. }
  32231. else {
  32232. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32233. }
  32234. texture.isReady = true;
  32235. // this.resetTextureCache();
  32236. scene._removePendingData(texture);
  32237. if (onLoad) {
  32238. onLoad();
  32239. }
  32240. };
  32241. this._loadFile(url, function (data) {
  32242. internalCallback(data);
  32243. }, undefined, scene.offlineProvider, true, onerror);
  32244. return texture;
  32245. };
  32246. /**
  32247. * Update a raw 3D texture
  32248. * @param texture defines the texture to update
  32249. * @param data defines the data to store
  32250. * @param format defines the data format
  32251. * @param invertY defines if data must be stored with Y axis inverted
  32252. * @param compression defines the used compression (can be null)
  32253. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32254. */
  32255. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32256. if (compression === void 0) { compression = null; }
  32257. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32258. var internalType = this._getWebGLTextureType(textureType);
  32259. var internalFormat = this._getInternalFormat(format);
  32260. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32261. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32262. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32263. if (!this._doNotHandleContextLost) {
  32264. texture._bufferView = data;
  32265. texture.format = format;
  32266. texture.invertY = invertY;
  32267. texture._compression = compression;
  32268. }
  32269. if (texture.width % 4 !== 0) {
  32270. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32271. }
  32272. if (compression && data) {
  32273. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32274. }
  32275. else {
  32276. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32277. }
  32278. if (texture.generateMipMaps) {
  32279. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32280. }
  32281. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32282. // this.resetTextureCache();
  32283. texture.isReady = true;
  32284. };
  32285. /**
  32286. * Creates a new raw 3D texture
  32287. * @param data defines the data used to create the texture
  32288. * @param width defines the width of the texture
  32289. * @param height defines the height of the texture
  32290. * @param depth defines the depth of the texture
  32291. * @param format defines the format of the texture
  32292. * @param generateMipMaps defines if the engine must generate mip levels
  32293. * @param invertY defines if data must be stored with Y axis inverted
  32294. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32295. * @param compression defines the compressed used (can be null)
  32296. * @param textureType defines the compressed used (can be null)
  32297. * @returns a new raw 3D texture (stored in an InternalTexture)
  32298. */
  32299. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32300. if (compression === void 0) { compression = null; }
  32301. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32302. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32303. texture.baseWidth = width;
  32304. texture.baseHeight = height;
  32305. texture.baseDepth = depth;
  32306. texture.width = width;
  32307. texture.height = height;
  32308. texture.depth = depth;
  32309. texture.format = format;
  32310. texture.type = textureType;
  32311. texture.generateMipMaps = generateMipMaps;
  32312. texture.samplingMode = samplingMode;
  32313. texture.is3D = true;
  32314. if (!this._doNotHandleContextLost) {
  32315. texture._bufferView = data;
  32316. }
  32317. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32318. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32319. // Filters
  32320. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32321. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32322. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32323. if (generateMipMaps) {
  32324. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32325. }
  32326. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32327. this._internalTexturesCache.push(texture);
  32328. return texture;
  32329. };
  32330. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32331. var gl = this._gl;
  32332. if (!gl) {
  32333. return;
  32334. }
  32335. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32336. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32337. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32338. if (!noMipmap && !isCompressed) {
  32339. gl.generateMipmap(gl.TEXTURE_2D);
  32340. }
  32341. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32342. // this.resetTextureCache();
  32343. if (scene) {
  32344. scene._removePendingData(texture);
  32345. }
  32346. texture.onLoadedObservable.notifyObservers(texture);
  32347. texture.onLoadedObservable.clear();
  32348. };
  32349. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32350. var _this = this;
  32351. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32352. var maxTextureSize = this.getCaps().maxTextureSize;
  32353. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32354. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32355. var gl = this._gl;
  32356. if (!gl) {
  32357. return;
  32358. }
  32359. if (!texture._webGLTexture) {
  32360. // this.resetTextureCache();
  32361. if (scene) {
  32362. scene._removePendingData(texture);
  32363. }
  32364. return;
  32365. }
  32366. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32367. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32368. texture.baseWidth = width;
  32369. texture.baseHeight = height;
  32370. texture.width = potWidth;
  32371. texture.height = potHeight;
  32372. texture.isReady = true;
  32373. if (processFunction(potWidth, potHeight, function () {
  32374. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32375. })) {
  32376. // Returning as texture needs extra async steps
  32377. return;
  32378. }
  32379. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32380. };
  32381. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32382. // Create new RGBA data container.
  32383. var rgbaData;
  32384. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32385. rgbaData = new Float32Array(width * height * 4);
  32386. }
  32387. else {
  32388. rgbaData = new Uint32Array(width * height * 4);
  32389. }
  32390. // Convert each pixel.
  32391. for (var x = 0; x < width; x++) {
  32392. for (var y = 0; y < height; y++) {
  32393. var index = (y * width + x) * 3;
  32394. var newIndex = (y * width + x) * 4;
  32395. // Map Old Value to new value.
  32396. rgbaData[newIndex + 0] = rgbData[index + 0];
  32397. rgbaData[newIndex + 1] = rgbData[index + 1];
  32398. rgbaData[newIndex + 2] = rgbData[index + 2];
  32399. // Add fully opaque alpha channel.
  32400. rgbaData[newIndex + 3] = 1;
  32401. }
  32402. }
  32403. return rgbaData;
  32404. };
  32405. /** @hidden */
  32406. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32407. var gl = this._gl;
  32408. if (texture._framebuffer) {
  32409. gl.deleteFramebuffer(texture._framebuffer);
  32410. texture._framebuffer = null;
  32411. }
  32412. if (texture._depthStencilBuffer) {
  32413. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32414. texture._depthStencilBuffer = null;
  32415. }
  32416. if (texture._MSAAFramebuffer) {
  32417. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32418. texture._MSAAFramebuffer = null;
  32419. }
  32420. if (texture._MSAARenderBuffer) {
  32421. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32422. texture._MSAARenderBuffer = null;
  32423. }
  32424. };
  32425. /** @hidden */
  32426. Engine.prototype._releaseTexture = function (texture) {
  32427. var gl = this._gl;
  32428. this._releaseFramebufferObjects(texture);
  32429. gl.deleteTexture(texture._webGLTexture);
  32430. // Unbind channels
  32431. this.unbindAllTextures();
  32432. var index = this._internalTexturesCache.indexOf(texture);
  32433. if (index !== -1) {
  32434. this._internalTexturesCache.splice(index, 1);
  32435. }
  32436. // Integrated fixed lod samplers.
  32437. if (texture._lodTextureHigh) {
  32438. texture._lodTextureHigh.dispose();
  32439. }
  32440. if (texture._lodTextureMid) {
  32441. texture._lodTextureMid.dispose();
  32442. }
  32443. if (texture._lodTextureLow) {
  32444. texture._lodTextureLow.dispose();
  32445. }
  32446. // Set output texture of post process to null if the texture has been released/disposed
  32447. this.scenes.forEach(function (scene) {
  32448. scene.postProcesses.forEach(function (postProcess) {
  32449. if (postProcess._outputTexture == texture) {
  32450. postProcess._outputTexture = null;
  32451. }
  32452. });
  32453. scene.cameras.forEach(function (camera) {
  32454. camera._postProcesses.forEach(function (postProcess) {
  32455. if (postProcess) {
  32456. if (postProcess._outputTexture == texture) {
  32457. postProcess._outputTexture = null;
  32458. }
  32459. }
  32460. });
  32461. });
  32462. });
  32463. };
  32464. Engine.prototype.setProgram = function (program) {
  32465. if (this._currentProgram !== program) {
  32466. this._gl.useProgram(program);
  32467. this._currentProgram = program;
  32468. }
  32469. };
  32470. /**
  32471. * Binds an effect to the webGL context
  32472. * @param effect defines the effect to bind
  32473. */
  32474. Engine.prototype.bindSamplers = function (effect) {
  32475. this.setProgram(effect.getProgram());
  32476. var samplers = effect.getSamplers();
  32477. for (var index = 0; index < samplers.length; index++) {
  32478. var uniform = effect.getUniform(samplers[index]);
  32479. if (uniform) {
  32480. this._boundUniforms[index] = uniform;
  32481. }
  32482. }
  32483. this._currentEffect = null;
  32484. };
  32485. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  32486. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  32487. return;
  32488. }
  32489. // Remove
  32490. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32491. // Bind last to it
  32492. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  32493. // Bind to dummy
  32494. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  32495. };
  32496. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  32497. if (!internalTexture) {
  32498. return -1;
  32499. }
  32500. internalTexture._initialSlot = channel;
  32501. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  32502. if (channel !== internalTexture._designatedSlot) {
  32503. this._textureCollisions.addCount(1, false);
  32504. }
  32505. }
  32506. else {
  32507. if (channel !== internalTexture._designatedSlot) {
  32508. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  32509. return internalTexture._designatedSlot;
  32510. }
  32511. else {
  32512. // No slot for this texture, let's pick a new one (if we find a free slot)
  32513. if (this._nextFreeTextureSlots.length) {
  32514. return this._nextFreeTextureSlots[0];
  32515. }
  32516. // We need to recycle the oldest bound texture, sorry.
  32517. this._textureCollisions.addCount(1, false);
  32518. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  32519. }
  32520. }
  32521. }
  32522. return channel;
  32523. };
  32524. Engine.prototype._linkTrackers = function (previous, next) {
  32525. previous.next = next;
  32526. next.previous = previous;
  32527. };
  32528. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  32529. var currentSlot = internalTexture._designatedSlot;
  32530. if (currentSlot === -1) {
  32531. return -1;
  32532. }
  32533. internalTexture._designatedSlot = -1;
  32534. if (this.disableTextureBindingOptimization) {
  32535. return -1;
  32536. }
  32537. // Remove from bound list
  32538. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32539. // Free the slot
  32540. this._boundTexturesCache[currentSlot] = null;
  32541. this._nextFreeTextureSlots.push(currentSlot);
  32542. return currentSlot;
  32543. };
  32544. Engine.prototype._activateCurrentTexture = function () {
  32545. if (this._currentTextureChannel !== this._activeChannel) {
  32546. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  32547. this._currentTextureChannel = this._activeChannel;
  32548. }
  32549. };
  32550. /** @hidden */
  32551. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  32552. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  32553. if (force === void 0) { force = false; }
  32554. var wasPreviouslyBound = false;
  32555. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  32556. this._activeChannel = texture._designatedSlot;
  32557. }
  32558. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  32559. var isTextureForRendering = texture && texture._initialSlot > -1;
  32560. if (currentTextureBound !== texture || force) {
  32561. if (currentTextureBound) {
  32562. this._removeDesignatedSlot(currentTextureBound);
  32563. }
  32564. this._activateCurrentTexture();
  32565. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  32566. this._boundTexturesCache[this._activeChannel] = texture;
  32567. if (texture) {
  32568. if (!this.disableTextureBindingOptimization) {
  32569. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  32570. if (slotIndex > -1) {
  32571. this._nextFreeTextureSlots.splice(slotIndex, 1);
  32572. }
  32573. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  32574. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  32575. }
  32576. texture._designatedSlot = this._activeChannel;
  32577. }
  32578. }
  32579. else if (forTextureDataUpdate) {
  32580. wasPreviouslyBound = true;
  32581. this._activateCurrentTexture();
  32582. }
  32583. if (isTextureForRendering && !forTextureDataUpdate) {
  32584. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  32585. }
  32586. return wasPreviouslyBound;
  32587. };
  32588. /** @hidden */
  32589. Engine.prototype._bindTexture = function (channel, texture) {
  32590. if (channel < 0) {
  32591. return;
  32592. }
  32593. if (texture) {
  32594. channel = this._getCorrectTextureChannel(channel, texture);
  32595. }
  32596. this._activeChannel = channel;
  32597. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  32598. };
  32599. /**
  32600. * Sets a texture to the webGL context from a postprocess
  32601. * @param channel defines the channel to use
  32602. * @param postProcess defines the source postprocess
  32603. */
  32604. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  32605. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  32606. };
  32607. /**
  32608. * Binds the output of the passed in post process to the texture channel specified
  32609. * @param channel The channel the texture should be bound to
  32610. * @param postProcess The post process which's output should be bound
  32611. */
  32612. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  32613. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  32614. };
  32615. /**
  32616. * Unbind all textures from the webGL context
  32617. */
  32618. Engine.prototype.unbindAllTextures = function () {
  32619. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  32620. this._activeChannel = channel;
  32621. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32622. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32623. if (this.webGLVersion > 1) {
  32624. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32625. }
  32626. }
  32627. };
  32628. /**
  32629. * Sets a texture to the according uniform.
  32630. * @param channel The texture channel
  32631. * @param uniform The uniform to set
  32632. * @param texture The texture to apply
  32633. */
  32634. Engine.prototype.setTexture = function (channel, uniform, texture) {
  32635. if (channel < 0) {
  32636. return;
  32637. }
  32638. if (uniform) {
  32639. this._boundUniforms[channel] = uniform;
  32640. }
  32641. this._setTexture(channel, texture);
  32642. };
  32643. /**
  32644. * Sets a depth stencil texture from a render target to the according uniform.
  32645. * @param channel The texture channel
  32646. * @param uniform The uniform to set
  32647. * @param texture The render target texture containing the depth stencil texture to apply
  32648. */
  32649. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  32650. if (channel < 0) {
  32651. return;
  32652. }
  32653. if (uniform) {
  32654. this._boundUniforms[channel] = uniform;
  32655. }
  32656. if (!texture || !texture.depthStencilTexture) {
  32657. this._setTexture(channel, null);
  32658. }
  32659. else {
  32660. this._setTexture(channel, texture, false, true);
  32661. }
  32662. };
  32663. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  32664. var uniform = this._boundUniforms[sourceSlot];
  32665. if (uniform._currentState === destination) {
  32666. return;
  32667. }
  32668. this._gl.uniform1i(uniform, destination);
  32669. uniform._currentState = destination;
  32670. };
  32671. Engine.prototype._getTextureWrapMode = function (mode) {
  32672. switch (mode) {
  32673. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  32674. return this._gl.REPEAT;
  32675. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  32676. return this._gl.CLAMP_TO_EDGE;
  32677. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  32678. return this._gl.MIRRORED_REPEAT;
  32679. }
  32680. return this._gl.REPEAT;
  32681. };
  32682. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  32683. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  32684. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  32685. // Not ready?
  32686. if (!texture) {
  32687. if (this._boundTexturesCache[channel] != null) {
  32688. this._activeChannel = channel;
  32689. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32690. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32691. if (this.webGLVersion > 1) {
  32692. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32693. }
  32694. }
  32695. return false;
  32696. }
  32697. // Video
  32698. if (texture.video) {
  32699. this._activeChannel = channel;
  32700. texture.update();
  32701. }
  32702. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  32703. texture.delayLoad();
  32704. return false;
  32705. }
  32706. var internalTexture;
  32707. if (depthStencilTexture) {
  32708. internalTexture = texture.depthStencilTexture;
  32709. }
  32710. else if (texture.isReady()) {
  32711. internalTexture = texture.getInternalTexture();
  32712. }
  32713. else if (texture.isCube) {
  32714. internalTexture = this.emptyCubeTexture;
  32715. }
  32716. else if (texture.is3D) {
  32717. internalTexture = this.emptyTexture3D;
  32718. }
  32719. else {
  32720. internalTexture = this.emptyTexture;
  32721. }
  32722. if (!isPartOfTextureArray) {
  32723. channel = this._getCorrectTextureChannel(channel, internalTexture);
  32724. }
  32725. var needToBind = true;
  32726. if (this._boundTexturesCache[channel] === internalTexture) {
  32727. this._moveBoundTextureOnTop(internalTexture);
  32728. if (!isPartOfTextureArray) {
  32729. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  32730. }
  32731. needToBind = false;
  32732. }
  32733. this._activeChannel = channel;
  32734. if (internalTexture && internalTexture.is3D) {
  32735. if (needToBind) {
  32736. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  32737. }
  32738. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32739. internalTexture._cachedWrapU = texture.wrapU;
  32740. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32741. }
  32742. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32743. internalTexture._cachedWrapV = texture.wrapV;
  32744. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32745. }
  32746. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  32747. internalTexture._cachedWrapR = texture.wrapR;
  32748. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  32749. }
  32750. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  32751. }
  32752. else if (internalTexture && internalTexture.isCube) {
  32753. if (needToBind) {
  32754. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  32755. }
  32756. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  32757. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  32758. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  32759. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  32760. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  32761. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  32762. }
  32763. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  32764. }
  32765. else {
  32766. if (needToBind) {
  32767. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  32768. }
  32769. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32770. internalTexture._cachedWrapU = texture.wrapU;
  32771. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32772. }
  32773. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32774. internalTexture._cachedWrapV = texture.wrapV;
  32775. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32776. }
  32777. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  32778. }
  32779. return true;
  32780. };
  32781. /**
  32782. * Sets an array of texture to the webGL context
  32783. * @param channel defines the channel where the texture array must be set
  32784. * @param uniform defines the associated uniform location
  32785. * @param textures defines the array of textures to bind
  32786. */
  32787. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  32788. if (channel < 0 || !uniform) {
  32789. return;
  32790. }
  32791. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  32792. this._textureUnits = new Int32Array(textures.length);
  32793. }
  32794. for (var i = 0; i < textures.length; i++) {
  32795. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  32796. }
  32797. this._gl.uniform1iv(uniform, this._textureUnits);
  32798. for (var index = 0; index < textures.length; index++) {
  32799. this._setTexture(this._textureUnits[index], textures[index], true);
  32800. }
  32801. };
  32802. /** @hidden */
  32803. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  32804. var internalTexture = texture.getInternalTexture();
  32805. if (!internalTexture) {
  32806. return;
  32807. }
  32808. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  32809. var value = texture.anisotropicFilteringLevel;
  32810. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  32811. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  32812. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  32813. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  32814. }
  32815. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  32816. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  32817. internalTexture._cachedAnisotropicFilteringLevel = value;
  32818. }
  32819. };
  32820. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  32821. this._bindTextureDirectly(target, texture, true, true);
  32822. this._gl.texParameterf(target, parameter, value);
  32823. };
  32824. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  32825. if (texture) {
  32826. this._bindTextureDirectly(target, texture, true, true);
  32827. }
  32828. this._gl.texParameteri(target, parameter, value);
  32829. };
  32830. /**
  32831. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32832. * @param x defines the x coordinate of the rectangle where pixels must be read
  32833. * @param y defines the y coordinate of the rectangle where pixels must be read
  32834. * @param width defines the width of the rectangle where pixels must be read
  32835. * @param height defines the height of the rectangle where pixels must be read
  32836. * @returns a Uint8Array containing RGBA colors
  32837. */
  32838. Engine.prototype.readPixels = function (x, y, width, height) {
  32839. var data = new Uint8Array(height * width * 4);
  32840. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  32841. return data;
  32842. };
  32843. /**
  32844. * Add an externaly attached data from its key.
  32845. * This method call will fail and return false, if such key already exists.
  32846. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32847. * @param key the unique key that identifies the data
  32848. * @param data the data object to associate to the key for this Engine instance
  32849. * @return true if no such key were already present and the data was added successfully, false otherwise
  32850. */
  32851. Engine.prototype.addExternalData = function (key, data) {
  32852. if (!this._externalData) {
  32853. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32854. }
  32855. return this._externalData.add(key, data);
  32856. };
  32857. /**
  32858. * Get an externaly attached data from its key
  32859. * @param key the unique key that identifies the data
  32860. * @return the associated data, if present (can be null), or undefined if not present
  32861. */
  32862. Engine.prototype.getExternalData = function (key) {
  32863. if (!this._externalData) {
  32864. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32865. }
  32866. return this._externalData.get(key);
  32867. };
  32868. /**
  32869. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32870. * @param key the unique key that identifies the data
  32871. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32872. * @return the associated data, can be null if the factory returned null.
  32873. */
  32874. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  32875. if (!this._externalData) {
  32876. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32877. }
  32878. return this._externalData.getOrAddWithFactory(key, factory);
  32879. };
  32880. /**
  32881. * Remove an externaly attached data from the Engine instance
  32882. * @param key the unique key that identifies the data
  32883. * @return true if the data was successfully removed, false if it doesn't exist
  32884. */
  32885. Engine.prototype.removeExternalData = function (key) {
  32886. if (!this._externalData) {
  32887. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32888. }
  32889. return this._externalData.remove(key);
  32890. };
  32891. /**
  32892. * Unbind all vertex attributes from the webGL context
  32893. */
  32894. Engine.prototype.unbindAllAttributes = function () {
  32895. if (this._mustWipeVertexAttributes) {
  32896. this._mustWipeVertexAttributes = false;
  32897. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  32898. this._gl.disableVertexAttribArray(i);
  32899. this._vertexAttribArraysEnabled[i] = false;
  32900. this._currentBufferPointers[i].active = false;
  32901. }
  32902. return;
  32903. }
  32904. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  32905. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  32906. continue;
  32907. }
  32908. this._gl.disableVertexAttribArray(i);
  32909. this._vertexAttribArraysEnabled[i] = false;
  32910. this._currentBufferPointers[i].active = false;
  32911. }
  32912. };
  32913. /**
  32914. * 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
  32915. */
  32916. Engine.prototype.releaseEffects = function () {
  32917. for (var name in this._compiledEffects) {
  32918. this._deleteProgram(this._compiledEffects[name]._program);
  32919. }
  32920. this._compiledEffects = {};
  32921. };
  32922. /**
  32923. * Dispose and release all associated resources
  32924. */
  32925. Engine.prototype.dispose = function () {
  32926. this.hideLoadingUI();
  32927. this.stopRenderLoop();
  32928. this.onNewSceneAddedObservable.clear();
  32929. // Release postProcesses
  32930. while (this.postProcesses.length) {
  32931. this.postProcesses[0].dispose();
  32932. }
  32933. // Empty texture
  32934. if (this._emptyTexture) {
  32935. this._releaseTexture(this._emptyTexture);
  32936. this._emptyTexture = null;
  32937. }
  32938. if (this._emptyCubeTexture) {
  32939. this._releaseTexture(this._emptyCubeTexture);
  32940. this._emptyCubeTexture = null;
  32941. }
  32942. // Rescale PP
  32943. if (this._rescalePostProcess) {
  32944. this._rescalePostProcess.dispose();
  32945. }
  32946. // Release scenes
  32947. while (this.scenes.length) {
  32948. this.scenes[0].dispose();
  32949. }
  32950. // Release audio engine
  32951. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32952. Engine.audioEngine.dispose();
  32953. }
  32954. // Release effects
  32955. this.releaseEffects();
  32956. // Unbind
  32957. this.unbindAllAttributes();
  32958. this._boundUniforms = [];
  32959. if (this._dummyFramebuffer) {
  32960. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32961. }
  32962. //WebVR
  32963. this.disableVR();
  32964. // Events
  32965. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32966. window.removeEventListener("blur", this._onBlur);
  32967. window.removeEventListener("focus", this._onFocus);
  32968. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32969. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32970. if (this._renderingCanvas) {
  32971. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32972. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32973. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32974. if (!this._doNotHandleContextLost) {
  32975. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32976. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32977. }
  32978. }
  32979. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  32980. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  32981. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  32982. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  32983. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  32984. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  32985. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  32986. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  32987. if (this._onVrDisplayConnect) {
  32988. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  32989. if (this._onVrDisplayDisconnect) {
  32990. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  32991. }
  32992. if (this._onVrDisplayPresentChange) {
  32993. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  32994. }
  32995. this._onVrDisplayConnect = null;
  32996. this._onVrDisplayDisconnect = null;
  32997. }
  32998. }
  32999. // Remove from Instances
  33000. var index = Engine.Instances.indexOf(this);
  33001. if (index >= 0) {
  33002. Engine.Instances.splice(index, 1);
  33003. }
  33004. this._workingCanvas = null;
  33005. this._workingContext = null;
  33006. this._currentBufferPointers = [];
  33007. this._renderingCanvas = null;
  33008. this._currentProgram = null;
  33009. this._bindedRenderFunction = null;
  33010. this.onResizeObservable.clear();
  33011. this.onCanvasBlurObservable.clear();
  33012. this.onCanvasFocusObservable.clear();
  33013. this.onCanvasPointerOutObservable.clear();
  33014. this.onBeginFrameObservable.clear();
  33015. this.onEndFrameObservable.clear();
  33016. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33017. // Abort active requests
  33018. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33019. var request = _a[_i];
  33020. request.abort();
  33021. }
  33022. };
  33023. // Loading screen
  33024. /**
  33025. * Display the loading screen
  33026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33027. */
  33028. Engine.prototype.displayLoadingUI = function () {
  33029. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33030. return;
  33031. }
  33032. var loadingScreen = this.loadingScreen;
  33033. if (loadingScreen) {
  33034. loadingScreen.displayLoadingUI();
  33035. }
  33036. };
  33037. /**
  33038. * Hide the loading screen
  33039. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33040. */
  33041. Engine.prototype.hideLoadingUI = function () {
  33042. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33043. return;
  33044. }
  33045. var loadingScreen = this.loadingScreen;
  33046. if (loadingScreen) {
  33047. loadingScreen.hideLoadingUI();
  33048. }
  33049. };
  33050. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33051. /**
  33052. * Gets the current loading screen object
  33053. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33054. */
  33055. get: function () {
  33056. if (!this._loadingScreen && this._renderingCanvas) {
  33057. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33058. }
  33059. return this._loadingScreen;
  33060. },
  33061. /**
  33062. * Sets the current loading screen object
  33063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33064. */
  33065. set: function (loadingScreen) {
  33066. this._loadingScreen = loadingScreen;
  33067. },
  33068. enumerable: true,
  33069. configurable: true
  33070. });
  33071. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33072. /**
  33073. * Sets the current loading screen text
  33074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33075. */
  33076. set: function (text) {
  33077. this.loadingScreen.loadingUIText = text;
  33078. },
  33079. enumerable: true,
  33080. configurable: true
  33081. });
  33082. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33083. /**
  33084. * Sets the current loading screen background color
  33085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33086. */
  33087. set: function (color) {
  33088. this.loadingScreen.loadingUIBackgroundColor = color;
  33089. },
  33090. enumerable: true,
  33091. configurable: true
  33092. });
  33093. /**
  33094. * Attach a new callback raised when context lost event is fired
  33095. * @param callback defines the callback to call
  33096. */
  33097. Engine.prototype.attachContextLostEvent = function (callback) {
  33098. if (this._renderingCanvas) {
  33099. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33100. }
  33101. };
  33102. /**
  33103. * Attach a new callback raised when context restored event is fired
  33104. * @param callback defines the callback to call
  33105. */
  33106. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33107. if (this._renderingCanvas) {
  33108. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33109. }
  33110. };
  33111. /**
  33112. * Gets the source code of the vertex shader associated with a specific webGL program
  33113. * @param program defines the program to use
  33114. * @returns a string containing the source code of the vertex shader associated with the program
  33115. */
  33116. Engine.prototype.getVertexShaderSource = function (program) {
  33117. var shaders = this._gl.getAttachedShaders(program);
  33118. if (!shaders) {
  33119. return null;
  33120. }
  33121. return this._gl.getShaderSource(shaders[0]);
  33122. };
  33123. /**
  33124. * Gets the source code of the fragment shader associated with a specific webGL program
  33125. * @param program defines the program to use
  33126. * @returns a string containing the source code of the fragment shader associated with the program
  33127. */
  33128. Engine.prototype.getFragmentShaderSource = function (program) {
  33129. var shaders = this._gl.getAttachedShaders(program);
  33130. if (!shaders) {
  33131. return null;
  33132. }
  33133. return this._gl.getShaderSource(shaders[1]);
  33134. };
  33135. /**
  33136. * Get the current error code of the webGL context
  33137. * @returns the error code
  33138. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33139. */
  33140. Engine.prototype.getError = function () {
  33141. return this._gl.getError();
  33142. };
  33143. // FPS
  33144. /**
  33145. * Gets the current framerate
  33146. * @returns a number representing the framerate
  33147. */
  33148. Engine.prototype.getFps = function () {
  33149. return this._fps;
  33150. };
  33151. /**
  33152. * Gets the time spent between current and previous frame
  33153. * @returns a number representing the delta time in ms
  33154. */
  33155. Engine.prototype.getDeltaTime = function () {
  33156. return this._deltaTime;
  33157. };
  33158. Engine.prototype._measureFps = function () {
  33159. this._performanceMonitor.sampleFrame();
  33160. this._fps = this._performanceMonitor.averageFPS;
  33161. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33162. };
  33163. /** @hidden */
  33164. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33165. if (faceIndex === void 0) { faceIndex = -1; }
  33166. if (level === void 0) { level = 0; }
  33167. if (buffer === void 0) { buffer = null; }
  33168. var gl = this._gl;
  33169. if (!this._dummyFramebuffer) {
  33170. var dummy = gl.createFramebuffer();
  33171. if (!dummy) {
  33172. throw new Error("Unable to create dummy framebuffer");
  33173. }
  33174. this._dummyFramebuffer = dummy;
  33175. }
  33176. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33177. if (faceIndex > -1) {
  33178. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33179. }
  33180. else {
  33181. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33182. }
  33183. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33184. switch (readType) {
  33185. case gl.UNSIGNED_BYTE:
  33186. if (!buffer) {
  33187. buffer = new Uint8Array(4 * width * height);
  33188. }
  33189. readType = gl.UNSIGNED_BYTE;
  33190. break;
  33191. default:
  33192. if (!buffer) {
  33193. buffer = new Float32Array(4 * width * height);
  33194. }
  33195. readType = gl.FLOAT;
  33196. break;
  33197. }
  33198. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33199. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33200. return buffer;
  33201. };
  33202. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33203. if (this._webGLVersion > 1) {
  33204. return this._caps.colorBufferFloat;
  33205. }
  33206. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33207. };
  33208. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33209. if (this._webGLVersion > 1) {
  33210. return this._caps.colorBufferFloat;
  33211. }
  33212. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33213. };
  33214. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33215. Engine.prototype._canRenderToFramebuffer = function (type) {
  33216. var gl = this._gl;
  33217. //clear existing errors
  33218. while (gl.getError() !== gl.NO_ERROR) { }
  33219. var successful = true;
  33220. var texture = gl.createTexture();
  33221. gl.bindTexture(gl.TEXTURE_2D, texture);
  33222. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33223. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33224. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33225. var fb = gl.createFramebuffer();
  33226. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33227. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33228. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33229. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33230. successful = successful && (gl.getError() === gl.NO_ERROR);
  33231. //try render by clearing frame buffer's color buffer
  33232. if (successful) {
  33233. gl.clear(gl.COLOR_BUFFER_BIT);
  33234. successful = successful && (gl.getError() === gl.NO_ERROR);
  33235. }
  33236. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33237. if (successful) {
  33238. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33239. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33240. var readFormat = gl.RGBA;
  33241. var readType = gl.UNSIGNED_BYTE;
  33242. var buffer = new Uint8Array(4);
  33243. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33244. successful = successful && (gl.getError() === gl.NO_ERROR);
  33245. }
  33246. //clean up
  33247. gl.deleteTexture(texture);
  33248. gl.deleteFramebuffer(fb);
  33249. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33250. //clear accumulated errors
  33251. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33252. return successful;
  33253. };
  33254. /** @hidden */
  33255. Engine.prototype._getWebGLTextureType = function (type) {
  33256. if (this._webGLVersion === 1) {
  33257. switch (type) {
  33258. case Engine.TEXTURETYPE_FLOAT:
  33259. return this._gl.FLOAT;
  33260. case Engine.TEXTURETYPE_HALF_FLOAT:
  33261. return this._gl.HALF_FLOAT_OES;
  33262. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33263. return this._gl.UNSIGNED_BYTE;
  33264. }
  33265. return this._gl.UNSIGNED_BYTE;
  33266. }
  33267. switch (type) {
  33268. case Engine.TEXTURETYPE_BYTE:
  33269. return this._gl.BYTE;
  33270. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33271. return this._gl.UNSIGNED_BYTE;
  33272. case Engine.TEXTURETYPE_SHORT:
  33273. return this._gl.SHORT;
  33274. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33275. return this._gl.UNSIGNED_SHORT;
  33276. case Engine.TEXTURETYPE_INT:
  33277. return this._gl.INT;
  33278. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33279. return this._gl.UNSIGNED_INT;
  33280. case Engine.TEXTURETYPE_FLOAT:
  33281. return this._gl.FLOAT;
  33282. case Engine.TEXTURETYPE_HALF_FLOAT:
  33283. return this._gl.HALF_FLOAT;
  33284. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33285. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33286. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33287. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33288. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33289. return this._gl.UNSIGNED_SHORT_5_6_5;
  33290. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33291. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33292. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33293. return this._gl.UNSIGNED_INT_24_8;
  33294. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33295. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33296. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33297. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33298. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33299. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33300. }
  33301. return this._gl.UNSIGNED_BYTE;
  33302. };
  33303. Engine.prototype._getInternalFormat = function (format) {
  33304. var internalFormat = this._gl.RGBA;
  33305. switch (format) {
  33306. case Engine.TEXTUREFORMAT_ALPHA:
  33307. internalFormat = this._gl.ALPHA;
  33308. break;
  33309. case Engine.TEXTUREFORMAT_LUMINANCE:
  33310. internalFormat = this._gl.LUMINANCE;
  33311. break;
  33312. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33313. internalFormat = this._gl.LUMINANCE_ALPHA;
  33314. break;
  33315. case Engine.TEXTUREFORMAT_RED:
  33316. internalFormat = this._gl.RED;
  33317. break;
  33318. case Engine.TEXTUREFORMAT_RG:
  33319. internalFormat = this._gl.RG;
  33320. break;
  33321. case Engine.TEXTUREFORMAT_RGB:
  33322. internalFormat = this._gl.RGB;
  33323. break;
  33324. case Engine.TEXTUREFORMAT_RGBA:
  33325. internalFormat = this._gl.RGBA;
  33326. break;
  33327. }
  33328. if (this._webGLVersion > 1) {
  33329. switch (format) {
  33330. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33331. internalFormat = this._gl.RED_INTEGER;
  33332. break;
  33333. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33334. internalFormat = this._gl.RG_INTEGER;
  33335. break;
  33336. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33337. internalFormat = this._gl.RGB_INTEGER;
  33338. break;
  33339. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33340. internalFormat = this._gl.RGBA_INTEGER;
  33341. break;
  33342. }
  33343. }
  33344. return internalFormat;
  33345. };
  33346. /** @hidden */
  33347. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33348. if (this._webGLVersion === 1) {
  33349. if (format !== undefined) {
  33350. switch (format) {
  33351. case Engine.TEXTUREFORMAT_ALPHA:
  33352. return this._gl.ALPHA;
  33353. case Engine.TEXTUREFORMAT_LUMINANCE:
  33354. return this._gl.LUMINANCE;
  33355. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33356. return this._gl.LUMINANCE_ALPHA;
  33357. }
  33358. }
  33359. return this._gl.RGBA;
  33360. }
  33361. switch (type) {
  33362. case Engine.TEXTURETYPE_BYTE:
  33363. switch (format) {
  33364. case Engine.TEXTUREFORMAT_RED:
  33365. return this._gl.R8_SNORM;
  33366. case Engine.TEXTUREFORMAT_RG:
  33367. return this._gl.RG8_SNORM;
  33368. case Engine.TEXTUREFORMAT_RGB:
  33369. return this._gl.RGB8_SNORM;
  33370. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33371. return this._gl.R8I;
  33372. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33373. return this._gl.RG8I;
  33374. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33375. return this._gl.RGB8I;
  33376. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33377. return this._gl.RGBA8I;
  33378. default:
  33379. return this._gl.RGBA8_SNORM;
  33380. }
  33381. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33382. switch (format) {
  33383. case Engine.TEXTUREFORMAT_RED:
  33384. return this._gl.R8;
  33385. case Engine.TEXTUREFORMAT_RG:
  33386. return this._gl.RG8;
  33387. case Engine.TEXTUREFORMAT_RGB:
  33388. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33389. case Engine.TEXTUREFORMAT_RGBA:
  33390. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33391. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33392. return this._gl.R8UI;
  33393. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33394. return this._gl.RG8UI;
  33395. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33396. return this._gl.RGB8UI;
  33397. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33398. return this._gl.RGBA8UI;
  33399. default:
  33400. return this._gl.RGBA8;
  33401. }
  33402. case Engine.TEXTURETYPE_SHORT:
  33403. switch (format) {
  33404. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33405. return this._gl.R16I;
  33406. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33407. return this._gl.RG16I;
  33408. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33409. return this._gl.RGB16I;
  33410. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33411. return this._gl.RGBA16I;
  33412. default:
  33413. return this._gl.RGBA16I;
  33414. }
  33415. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33416. switch (format) {
  33417. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33418. return this._gl.R16UI;
  33419. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33420. return this._gl.RG16UI;
  33421. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33422. return this._gl.RGB16UI;
  33423. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33424. return this._gl.RGBA16UI;
  33425. default:
  33426. return this._gl.RGBA16UI;
  33427. }
  33428. case Engine.TEXTURETYPE_INT:
  33429. switch (format) {
  33430. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33431. return this._gl.R32I;
  33432. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33433. return this._gl.RG32I;
  33434. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33435. return this._gl.RGB32I;
  33436. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33437. return this._gl.RGBA32I;
  33438. default:
  33439. return this._gl.RGBA32I;
  33440. }
  33441. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33442. switch (format) {
  33443. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33444. return this._gl.R32UI;
  33445. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33446. return this._gl.RG32UI;
  33447. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33448. return this._gl.RGB32UI;
  33449. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33450. return this._gl.RGBA32UI;
  33451. default:
  33452. return this._gl.RGBA32UI;
  33453. }
  33454. case Engine.TEXTURETYPE_FLOAT:
  33455. switch (format) {
  33456. case Engine.TEXTUREFORMAT_RED:
  33457. return this._gl.R32F; // By default. Other possibility is R16F.
  33458. case Engine.TEXTUREFORMAT_RG:
  33459. return this._gl.RG32F; // By default. Other possibility is RG16F.
  33460. case Engine.TEXTUREFORMAT_RGB:
  33461. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  33462. case Engine.TEXTUREFORMAT_RGBA:
  33463. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  33464. default:
  33465. return this._gl.RGBA32F;
  33466. }
  33467. case Engine.TEXTURETYPE_HALF_FLOAT:
  33468. switch (format) {
  33469. case Engine.TEXTUREFORMAT_RED:
  33470. return this._gl.R16F;
  33471. case Engine.TEXTUREFORMAT_RG:
  33472. return this._gl.RG16F;
  33473. case Engine.TEXTUREFORMAT_RGB:
  33474. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  33475. case Engine.TEXTUREFORMAT_RGBA:
  33476. return this._gl.RGBA16F;
  33477. default:
  33478. return this._gl.RGBA16F;
  33479. }
  33480. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33481. return this._gl.RGB565;
  33482. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33483. return this._gl.R11F_G11F_B10F;
  33484. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33485. return this._gl.RGB9_E5;
  33486. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33487. return this._gl.RGBA4;
  33488. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33489. return this._gl.RGB5_A1;
  33490. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33491. switch (format) {
  33492. case Engine.TEXTUREFORMAT_RGBA:
  33493. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  33494. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33495. return this._gl.RGB10_A2UI;
  33496. default:
  33497. return this._gl.RGB10_A2;
  33498. }
  33499. }
  33500. return this._gl.RGBA8;
  33501. };
  33502. /** @hidden */
  33503. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  33504. if (type === Engine.TEXTURETYPE_FLOAT) {
  33505. return this._gl.RGBA32F;
  33506. }
  33507. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  33508. return this._gl.RGBA16F;
  33509. }
  33510. return this._gl.RGBA8;
  33511. };
  33512. /** @hidden */
  33513. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  33514. var _this = this;
  33515. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  33516. this._activeRequests.push(request);
  33517. request.onCompleteObservable.add(function (request) {
  33518. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  33519. });
  33520. return request;
  33521. };
  33522. /** @hidden */
  33523. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  33524. var _this = this;
  33525. return new Promise(function (resolve, reject) {
  33526. _this._loadFile(url, function (data) {
  33527. resolve(data);
  33528. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  33529. reject(exception);
  33530. });
  33531. });
  33532. };
  33533. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  33534. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  33535. var onload = function (data) {
  33536. loadedFiles[index] = data;
  33537. loadedFiles._internalCount++;
  33538. if (loadedFiles._internalCount === 6) {
  33539. onfinish(loadedFiles);
  33540. }
  33541. };
  33542. var onerror = function (request, exception) {
  33543. if (onErrorCallBack && request) {
  33544. onErrorCallBack(request.status + " " + request.statusText, exception);
  33545. }
  33546. };
  33547. this._loadFile(url, onload, undefined, undefined, true, onerror);
  33548. };
  33549. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  33550. if (onError === void 0) { onError = null; }
  33551. var loadedFiles = [];
  33552. loadedFiles._internalCount = 0;
  33553. for (var index = 0; index < 6; index++) {
  33554. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  33555. }
  33556. };
  33557. // Statics
  33558. /**
  33559. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33560. * @returns true if the engine can be created
  33561. * @ignorenaming
  33562. */
  33563. Engine.isSupported = function () {
  33564. try {
  33565. var tempcanvas = document.createElement("canvas");
  33566. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  33567. return gl != null && !!window.WebGLRenderingContext;
  33568. }
  33569. catch (e) {
  33570. return false;
  33571. }
  33572. };
  33573. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33574. Engine.ExceptionList = [
  33575. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  33576. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33577. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33578. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33579. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33580. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  33581. ];
  33582. /**
  33583. * Hidden
  33584. */
  33585. Engine._TextureLoaders = [];
  33586. // Const statics
  33587. /** Defines that alpha blending is disabled */
  33588. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  33589. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33590. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  33591. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33592. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  33593. /** Defines that alpha blending to DEST - SRC * DEST */
  33594. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  33595. /** Defines that alpha blending to SRC * DEST */
  33596. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  33597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33598. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  33599. /** Defines that alpha blending to SRC + DEST */
  33600. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  33601. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33602. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  33603. /**
  33604. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33605. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33606. */
  33607. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  33608. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33609. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  33610. /**
  33611. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33612. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33613. */
  33614. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  33615. /** Defines that the ressource is not delayed*/
  33616. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  33617. /** Defines that the ressource was successfully delay loaded */
  33618. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  33619. /** Defines that the ressource is currently delay loading */
  33620. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  33621. /** Defines that the ressource is delayed and has not started loading */
  33622. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  33623. // Depht or Stencil test Constants.
  33624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33625. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  33626. /** 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 */
  33627. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  33628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33629. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  33630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33631. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  33632. /** 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 */
  33633. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  33634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33635. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  33636. /** 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 */
  33637. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  33638. /** 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 */
  33639. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  33640. // Stencil Actions Constants.
  33641. /** Passed to stencilOperation to specify that stencil value must be kept */
  33642. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  33643. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33644. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  33645. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33646. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  33647. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33648. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  33649. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33650. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  33651. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33652. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  33653. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33654. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  33655. /** Texture is not repeating outside of 0..1 UVs */
  33656. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  33657. /** Texture is repeating outside of 0..1 UVs */
  33658. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  33659. /** Texture is repeating and mirrored */
  33660. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  33661. /** ALPHA */
  33662. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  33663. /** LUMINANCE */
  33664. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  33665. /** LUMINANCE_ALPHA */
  33666. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  33667. /** RGB */
  33668. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  33669. /** RGBA */
  33670. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  33671. /** RED */
  33672. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  33673. /** RED (2nd reference) */
  33674. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  33675. /** RG */
  33676. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  33677. /** RED_INTEGER */
  33678. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  33679. /** RED_INTEGER (2nd reference) */
  33680. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  33681. /** RG_INTEGER */
  33682. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  33683. /** RGB_INTEGER */
  33684. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  33685. /** RGBA_INTEGER */
  33686. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  33687. /** UNSIGNED_BYTE */
  33688. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  33689. /** UNSIGNED_BYTE (2nd reference) */
  33690. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33691. /** FLOAT */
  33692. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  33693. /** HALF_FLOAT */
  33694. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  33695. /** BYTE */
  33696. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  33697. /** SHORT */
  33698. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  33699. /** UNSIGNED_SHORT */
  33700. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  33701. /** INT */
  33702. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  33703. /** UNSIGNED_INT */
  33704. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  33705. /** UNSIGNED_SHORT_4_4_4_4 */
  33706. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  33707. /** UNSIGNED_SHORT_5_5_5_1 */
  33708. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  33709. /** UNSIGNED_SHORT_5_6_5 */
  33710. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  33711. /** UNSIGNED_INT_2_10_10_10_REV */
  33712. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  33713. /** UNSIGNED_INT_24_8 */
  33714. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  33715. /** UNSIGNED_INT_10F_11F_11F_REV */
  33716. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  33717. /** UNSIGNED_INT_5_9_9_9_REV */
  33718. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  33719. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33720. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  33721. /** nearest is mag = nearest and min = nearest and mip = linear */
  33722. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  33723. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33724. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  33725. /** Trilinear is mag = linear and min = linear and mip = linear */
  33726. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33727. /** nearest is mag = nearest and min = nearest and mip = linear */
  33728. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  33729. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33730. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  33731. /** Trilinear is mag = linear and min = linear and mip = linear */
  33732. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  33733. /** mag = nearest and min = nearest and mip = nearest */
  33734. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  33735. /** mag = nearest and min = linear and mip = nearest */
  33736. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  33737. /** mag = nearest and min = linear and mip = linear */
  33738. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  33739. /** mag = nearest and min = linear and mip = none */
  33740. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  33741. /** mag = nearest and min = nearest and mip = none */
  33742. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  33743. /** mag = linear and min = nearest and mip = nearest */
  33744. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  33745. /** mag = linear and min = nearest and mip = linear */
  33746. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  33747. /** mag = linear and min = linear and mip = none */
  33748. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  33749. /** mag = linear and min = nearest and mip = none */
  33750. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  33751. /** Explicit coordinates mode */
  33752. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  33753. /** Spherical coordinates mode */
  33754. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  33755. /** Planar coordinates mode */
  33756. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  33757. /** Cubic coordinates mode */
  33758. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  33759. /** Projection coordinates mode */
  33760. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  33761. /** Skybox coordinates mode */
  33762. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  33763. /** Inverse Cubic coordinates mode */
  33764. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  33765. /** Equirectangular coordinates mode */
  33766. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  33767. /** Equirectangular Fixed coordinates mode */
  33768. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  33769. /** Equirectangular Fixed Mirrored coordinates mode */
  33770. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  33771. // Texture rescaling mode
  33772. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33773. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  33774. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33775. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  33776. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33777. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  33778. // Updatable statics so stick with vars here
  33779. /**
  33780. * Gets or sets the epsilon value used by collision engine
  33781. */
  33782. Engine.CollisionsEpsilon = 0.001;
  33783. /**
  33784. * Method called to create the default rescale post process on each engine.
  33785. */
  33786. Engine._RescalePostProcessFactory = null;
  33787. return Engine;
  33788. }());
  33789. /***/ }),
  33790. /***/ "./Engines/engineStore.ts":
  33791. /*!********************************!*\
  33792. !*** ./Engines/engineStore.ts ***!
  33793. \********************************/
  33794. /*! exports provided: EngineStore */
  33795. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33796. "use strict";
  33797. __webpack_require__.r(__webpack_exports__);
  33798. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  33799. /**
  33800. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33801. * during the life time of the application.
  33802. */
  33803. var EngineStore = /** @class */ (function () {
  33804. function EngineStore() {
  33805. }
  33806. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  33807. /**
  33808. * Gets the latest created engine
  33809. */
  33810. get: function () {
  33811. if (this.Instances.length === 0) {
  33812. return null;
  33813. }
  33814. return this.Instances[this.Instances.length - 1];
  33815. },
  33816. enumerable: true,
  33817. configurable: true
  33818. });
  33819. Object.defineProperty(EngineStore, "LastCreatedScene", {
  33820. /**
  33821. * Gets the latest created scene
  33822. */
  33823. get: function () {
  33824. var lastCreatedEngine = this.LastCreatedEngine;
  33825. if (!lastCreatedEngine) {
  33826. return null;
  33827. }
  33828. if (lastCreatedEngine.scenes.length === 0) {
  33829. return null;
  33830. }
  33831. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  33832. },
  33833. enumerable: true,
  33834. configurable: true
  33835. });
  33836. /** Gets the list of created engines */
  33837. EngineStore.Instances = new Array();
  33838. return EngineStore;
  33839. }());
  33840. /***/ }),
  33841. /***/ "./Engines/index.ts":
  33842. /*!**************************!*\
  33843. !*** ./Engines/index.ts ***!
  33844. \**************************/
  33845. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  33846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33847. "use strict";
  33848. __webpack_require__.r(__webpack_exports__);
  33849. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  33851. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  33852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  33853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  33854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  33855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  33856. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  33857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  33858. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  33859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  33860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  33861. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  33862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  33863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  33864. /***/ }),
  33865. /***/ "./Engines/nullEngine.ts":
  33866. /*!*******************************!*\
  33867. !*** ./Engines/nullEngine.ts ***!
  33868. \*******************************/
  33869. /*! exports provided: NullEngineOptions, NullEngine */
  33870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33871. "use strict";
  33872. __webpack_require__.r(__webpack_exports__);
  33873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  33874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  33875. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33876. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  33877. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  33878. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  33879. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  33880. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33881. /**
  33882. * Options to create the null engine
  33883. */
  33884. var NullEngineOptions = /** @class */ (function () {
  33885. function NullEngineOptions() {
  33886. /**
  33887. * Render width (Default: 512)
  33888. */
  33889. this.renderWidth = 512;
  33890. /**
  33891. * Render height (Default: 256)
  33892. */
  33893. this.renderHeight = 256;
  33894. /**
  33895. * Texture size (Default: 512)
  33896. */
  33897. this.textureSize = 512;
  33898. /**
  33899. * If delta time between frames should be constant
  33900. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33901. */
  33902. this.deterministicLockstep = false;
  33903. /**
  33904. * Maximum about of steps between frames (Default: 4)
  33905. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33906. */
  33907. this.lockstepMaxSteps = 4;
  33908. }
  33909. return NullEngineOptions;
  33910. }());
  33911. /**
  33912. * The null engine class provides support for headless version of babylon.js.
  33913. * This can be used in server side scenario or for testing purposes
  33914. */
  33915. var NullEngine = /** @class */ (function (_super) {
  33916. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33917. function NullEngine(options) {
  33918. if (options === void 0) { options = new NullEngineOptions(); }
  33919. var _this = _super.call(this, null) || this;
  33920. if (options.deterministicLockstep === undefined) {
  33921. options.deterministicLockstep = false;
  33922. }
  33923. if (options.lockstepMaxSteps === undefined) {
  33924. options.lockstepMaxSteps = 4;
  33925. }
  33926. _this._options = options;
  33927. // Init caps
  33928. // We consider we are on a webgl1 capable device
  33929. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33930. _this._caps.maxTexturesImageUnits = 16;
  33931. _this._caps.maxVertexTextureImageUnits = 16;
  33932. _this._caps.maxTextureSize = 512;
  33933. _this._caps.maxCubemapTextureSize = 512;
  33934. _this._caps.maxRenderTextureSize = 512;
  33935. _this._caps.maxVertexAttribs = 16;
  33936. _this._caps.maxVaryingVectors = 16;
  33937. _this._caps.maxFragmentUniformVectors = 16;
  33938. _this._caps.maxVertexUniformVectors = 16;
  33939. // Extensions
  33940. _this._caps.standardDerivatives = false;
  33941. _this._caps.astc = null;
  33942. _this._caps.s3tc = null;
  33943. _this._caps.pvrtc = null;
  33944. _this._caps.etc1 = null;
  33945. _this._caps.etc2 = null;
  33946. _this._caps.textureAnisotropicFilterExtension = null;
  33947. _this._caps.maxAnisotropy = 0;
  33948. _this._caps.uintIndices = false;
  33949. _this._caps.fragmentDepthSupported = false;
  33950. _this._caps.highPrecisionShaderSupported = true;
  33951. _this._caps.colorBufferFloat = false;
  33952. _this._caps.textureFloat = false;
  33953. _this._caps.textureFloatLinearFiltering = false;
  33954. _this._caps.textureFloatRender = false;
  33955. _this._caps.textureHalfFloat = false;
  33956. _this._caps.textureHalfFloatLinearFiltering = false;
  33957. _this._caps.textureHalfFloatRender = false;
  33958. _this._caps.textureLOD = false;
  33959. _this._caps.drawBuffersExtension = false;
  33960. _this._caps.depthTextureExtension = false;
  33961. _this._caps.vertexArrayObject = false;
  33962. _this._caps.instancedArrays = false;
  33963. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33964. // Wrappers
  33965. if (typeof URL === "undefined") {
  33966. URL = {
  33967. createObjectURL: function () { },
  33968. revokeObjectURL: function () { }
  33969. };
  33970. }
  33971. if (typeof Blob === "undefined") {
  33972. Blob = function () { };
  33973. }
  33974. return _this;
  33975. }
  33976. /**
  33977. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33978. */
  33979. NullEngine.prototype.isDeterministicLockStep = function () {
  33980. return this._options.deterministicLockstep;
  33981. };
  33982. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  33983. NullEngine.prototype.getLockstepMaxSteps = function () {
  33984. return this._options.lockstepMaxSteps;
  33985. };
  33986. /**
  33987. * Sets hardware scaling, used to save performance if needed
  33988. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33989. */
  33990. NullEngine.prototype.getHardwareScalingLevel = function () {
  33991. return 1.0;
  33992. };
  33993. NullEngine.prototype.createVertexBuffer = function (vertices) {
  33994. return {
  33995. capacity: 0,
  33996. references: 1,
  33997. is32Bits: false
  33998. };
  33999. };
  34000. NullEngine.prototype.createIndexBuffer = function (indices) {
  34001. return {
  34002. capacity: 0,
  34003. references: 1,
  34004. is32Bits: false
  34005. };
  34006. };
  34007. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34008. if (stencil === void 0) { stencil = false; }
  34009. };
  34010. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34011. if (useScreen === void 0) { useScreen = false; }
  34012. if (!useScreen && this._currentRenderTarget) {
  34013. return this._currentRenderTarget.width;
  34014. }
  34015. return this._options.renderWidth;
  34016. };
  34017. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34018. if (useScreen === void 0) { useScreen = false; }
  34019. if (!useScreen && this._currentRenderTarget) {
  34020. return this._currentRenderTarget.height;
  34021. }
  34022. return this._options.renderHeight;
  34023. };
  34024. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34025. this._cachedViewport = viewport;
  34026. };
  34027. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34028. return {
  34029. transformFeedback: null,
  34030. __SPECTOR_rebuildProgram: null,
  34031. isParallelCompiled: false
  34032. };
  34033. };
  34034. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34035. return [];
  34036. };
  34037. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34038. return [];
  34039. };
  34040. NullEngine.prototype.bindSamplers = function (effect) {
  34041. this._currentEffect = null;
  34042. };
  34043. NullEngine.prototype.enableEffect = function (effect) {
  34044. this._currentEffect = effect;
  34045. if (effect.onBind) {
  34046. effect.onBind(effect);
  34047. }
  34048. if (effect._onBindObservable) {
  34049. effect._onBindObservable.notifyObservers(effect);
  34050. }
  34051. };
  34052. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34053. if (zOffset === void 0) { zOffset = 0; }
  34054. if (reverseSide === void 0) { reverseSide = false; }
  34055. };
  34056. NullEngine.prototype.setIntArray = function (uniform, array) {
  34057. };
  34058. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34059. };
  34060. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34061. };
  34062. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34063. };
  34064. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34065. };
  34066. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34067. };
  34068. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34069. };
  34070. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34071. };
  34072. NullEngine.prototype.setArray = function (uniform, array) {
  34073. };
  34074. NullEngine.prototype.setArray2 = function (uniform, array) {
  34075. };
  34076. NullEngine.prototype.setArray3 = function (uniform, array) {
  34077. };
  34078. NullEngine.prototype.setArray4 = function (uniform, array) {
  34079. };
  34080. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34081. };
  34082. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34083. };
  34084. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34085. };
  34086. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34087. };
  34088. NullEngine.prototype.setFloat = function (uniform, value) {
  34089. };
  34090. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34091. };
  34092. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34093. };
  34094. NullEngine.prototype.setBool = function (uniform, bool) {
  34095. };
  34096. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34097. };
  34098. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34099. };
  34100. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34101. };
  34102. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34103. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34104. if (this._alphaMode === mode) {
  34105. return;
  34106. }
  34107. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34108. if (!noDepthWriteChange) {
  34109. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34110. }
  34111. this._alphaMode = mode;
  34112. };
  34113. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34114. };
  34115. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34116. if (this.preventCacheWipeBetweenFrames) {
  34117. return;
  34118. }
  34119. this.resetTextureCache();
  34120. this._currentEffect = null;
  34121. if (bruteForce) {
  34122. this._currentProgram = null;
  34123. this._stencilState.reset();
  34124. this._depthCullingState.reset();
  34125. this._alphaState.reset();
  34126. }
  34127. this._cachedVertexBuffers = null;
  34128. this._cachedIndexBuffer = null;
  34129. this._cachedEffectForVertexBuffers = null;
  34130. };
  34131. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34132. };
  34133. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34134. };
  34135. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34136. };
  34137. /** @hidden */
  34138. NullEngine.prototype._createTexture = function () {
  34139. return {};
  34140. };
  34141. /** @hidden */
  34142. NullEngine.prototype._releaseTexture = function (texture) {
  34143. };
  34144. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34145. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34146. if (onLoad === void 0) { onLoad = null; }
  34147. if (onError === void 0) { onError = null; }
  34148. if (buffer === void 0) { buffer = null; }
  34149. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34150. var url = String(urlArg);
  34151. texture.url = url;
  34152. texture.generateMipMaps = !noMipmap;
  34153. texture.samplingMode = samplingMode;
  34154. texture.invertY = invertY;
  34155. texture.baseWidth = this._options.textureSize;
  34156. texture.baseHeight = this._options.textureSize;
  34157. texture.width = this._options.textureSize;
  34158. texture.height = this._options.textureSize;
  34159. if (format) {
  34160. texture.format = format;
  34161. }
  34162. texture.isReady = true;
  34163. if (onLoad) {
  34164. onLoad();
  34165. }
  34166. this._internalTexturesCache.push(texture);
  34167. return texture;
  34168. };
  34169. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34170. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34171. if (options !== undefined && typeof options === "object") {
  34172. fullOptions.generateMipMaps = options.generateMipMaps;
  34173. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34174. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34175. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34176. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34177. }
  34178. else {
  34179. fullOptions.generateMipMaps = options;
  34180. fullOptions.generateDepthBuffer = true;
  34181. fullOptions.generateStencilBuffer = false;
  34182. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34183. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34184. }
  34185. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34186. var width = size.width || size;
  34187. var height = size.height || size;
  34188. texture._depthStencilBuffer = {};
  34189. texture._framebuffer = {};
  34190. texture.baseWidth = width;
  34191. texture.baseHeight = height;
  34192. texture.width = width;
  34193. texture.height = height;
  34194. texture.isReady = true;
  34195. texture.samples = 1;
  34196. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34197. texture.samplingMode = fullOptions.samplingMode;
  34198. texture.type = fullOptions.type;
  34199. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34200. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34201. this._internalTexturesCache.push(texture);
  34202. return texture;
  34203. };
  34204. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34205. texture.samplingMode = samplingMode;
  34206. };
  34207. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34208. if (this._currentRenderTarget) {
  34209. this.unBindFramebuffer(this._currentRenderTarget);
  34210. }
  34211. this._currentRenderTarget = texture;
  34212. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34213. if (this._cachedViewport && !forceFullscreenViewport) {
  34214. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34215. }
  34216. };
  34217. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34218. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34219. this._currentRenderTarget = null;
  34220. if (onBeforeUnbind) {
  34221. if (texture._MSAAFramebuffer) {
  34222. this._currentFramebuffer = texture._framebuffer;
  34223. }
  34224. onBeforeUnbind();
  34225. }
  34226. this._currentFramebuffer = null;
  34227. };
  34228. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34229. var vbo = {
  34230. capacity: 1,
  34231. references: 1,
  34232. is32Bits: false
  34233. };
  34234. return vbo;
  34235. };
  34236. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34237. if (premulAlpha === void 0) { premulAlpha = false; }
  34238. };
  34239. NullEngine.prototype.areAllEffectsReady = function () {
  34240. return true;
  34241. };
  34242. /**
  34243. * @hidden
  34244. * Get the current error code of the webGL context
  34245. * @returns the error code
  34246. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34247. */
  34248. NullEngine.prototype.getError = function () {
  34249. return 0;
  34250. };
  34251. /** @hidden */
  34252. NullEngine.prototype._getUnpackAlignement = function () {
  34253. return 1;
  34254. };
  34255. /** @hidden */
  34256. NullEngine.prototype._unpackFlipY = function (value) {
  34257. };
  34258. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34259. if (offset === void 0) { offset = 0; }
  34260. };
  34261. /**
  34262. * Updates a dynamic vertex buffer.
  34263. * @param vertexBuffer the vertex buffer to update
  34264. * @param data the data used to update the vertex buffer
  34265. * @param byteOffset the byte offset of the data (optional)
  34266. * @param byteLength the byte length of the data (optional)
  34267. */
  34268. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34269. };
  34270. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34271. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34272. this._boundTexturesCache[this._activeChannel] = texture;
  34273. return true;
  34274. }
  34275. return false;
  34276. };
  34277. /** @hidden */
  34278. NullEngine.prototype._bindTexture = function (channel, texture) {
  34279. if (channel < 0) {
  34280. return;
  34281. }
  34282. this._bindTextureDirectly(0, texture);
  34283. };
  34284. /** @hidden */
  34285. NullEngine.prototype._releaseBuffer = function (buffer) {
  34286. buffer.references--;
  34287. if (buffer.references === 0) {
  34288. return true;
  34289. }
  34290. return false;
  34291. };
  34292. NullEngine.prototype.releaseEffects = function () {
  34293. };
  34294. NullEngine.prototype.displayLoadingUI = function () {
  34295. };
  34296. NullEngine.prototype.hideLoadingUI = function () {
  34297. };
  34298. /** @hidden */
  34299. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34300. if (faceIndex === void 0) { faceIndex = 0; }
  34301. if (lod === void 0) { lod = 0; }
  34302. };
  34303. /** @hidden */
  34304. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34305. if (faceIndex === void 0) { faceIndex = 0; }
  34306. if (lod === void 0) { lod = 0; }
  34307. };
  34308. /** @hidden */
  34309. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34310. if (faceIndex === void 0) { faceIndex = 0; }
  34311. if (lod === void 0) { lod = 0; }
  34312. };
  34313. /** @hidden */
  34314. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34315. if (faceIndex === void 0) { faceIndex = 0; }
  34316. if (lod === void 0) { lod = 0; }
  34317. };
  34318. return NullEngine;
  34319. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34320. /***/ }),
  34321. /***/ "./Events/clipboardEvents.ts":
  34322. /*!***********************************!*\
  34323. !*** ./Events/clipboardEvents.ts ***!
  34324. \***********************************/
  34325. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34327. "use strict";
  34328. __webpack_require__.r(__webpack_exports__);
  34329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34331. /**
  34332. * Gather the list of clipboard event types as constants.
  34333. */
  34334. var ClipboardEventTypes = /** @class */ (function () {
  34335. function ClipboardEventTypes() {
  34336. }
  34337. /**
  34338. * The clipboard event is fired when a copy command is active (pressed).
  34339. */
  34340. ClipboardEventTypes.COPY = 0x01; //
  34341. /**
  34342. * The clipboard event is fired when a cut command is active (pressed).
  34343. */
  34344. ClipboardEventTypes.CUT = 0x02;
  34345. /**
  34346. * The clipboard event is fired when a paste command is active (pressed).
  34347. */
  34348. ClipboardEventTypes.PASTE = 0x03;
  34349. return ClipboardEventTypes;
  34350. }());
  34351. /**
  34352. * This class is used to store clipboard related info for the onClipboardObservable event.
  34353. */
  34354. var ClipboardInfo = /** @class */ (function () {
  34355. /**
  34356. *Creates an instance of ClipboardInfo.
  34357. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34358. * @param event Defines the related dom event
  34359. */
  34360. function ClipboardInfo(
  34361. /**
  34362. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34363. */
  34364. type,
  34365. /**
  34366. * Defines the related dom event
  34367. */
  34368. event) {
  34369. this.type = type;
  34370. this.event = event;
  34371. }
  34372. /**
  34373. * Get the clipboard event's type from the keycode.
  34374. * @param keyCode Defines the keyCode for the current keyboard event.
  34375. * @return {number}
  34376. */
  34377. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34378. var charCode = keyCode;
  34379. //TODO: add codes for extended ASCII
  34380. switch (charCode) {
  34381. case 67: return ClipboardEventTypes.COPY;
  34382. case 86: return ClipboardEventTypes.PASTE;
  34383. case 88: return ClipboardEventTypes.CUT;
  34384. default: return -1;
  34385. }
  34386. };
  34387. return ClipboardInfo;
  34388. }());
  34389. /***/ }),
  34390. /***/ "./Events/index.ts":
  34391. /*!*************************!*\
  34392. !*** ./Events/index.ts ***!
  34393. \*************************/
  34394. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34396. "use strict";
  34397. __webpack_require__.r(__webpack_exports__);
  34398. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34402. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34407. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34410. /***/ }),
  34411. /***/ "./Events/keyboardEvents.ts":
  34412. /*!**********************************!*\
  34413. !*** ./Events/keyboardEvents.ts ***!
  34414. \**********************************/
  34415. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34417. "use strict";
  34418. __webpack_require__.r(__webpack_exports__);
  34419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  34420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  34421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  34422. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34423. /**
  34424. * Gather the list of keyboard event types as constants.
  34425. */
  34426. var KeyboardEventTypes = /** @class */ (function () {
  34427. function KeyboardEventTypes() {
  34428. }
  34429. /**
  34430. * The keydown event is fired when a key becomes active (pressed).
  34431. */
  34432. KeyboardEventTypes.KEYDOWN = 0x01;
  34433. /**
  34434. * The keyup event is fired when a key has been released.
  34435. */
  34436. KeyboardEventTypes.KEYUP = 0x02;
  34437. return KeyboardEventTypes;
  34438. }());
  34439. /**
  34440. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34441. */
  34442. var KeyboardInfo = /** @class */ (function () {
  34443. /**
  34444. * Instantiates a new keyboard info.
  34445. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34446. * @param type Defines the type of event (KeyboardEventTypes)
  34447. * @param event Defines the related dom event
  34448. */
  34449. function KeyboardInfo(
  34450. /**
  34451. * Defines the type of event (KeyboardEventTypes)
  34452. */
  34453. type,
  34454. /**
  34455. * Defines the related dom event
  34456. */
  34457. event) {
  34458. this.type = type;
  34459. this.event = event;
  34460. }
  34461. return KeyboardInfo;
  34462. }());
  34463. /**
  34464. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34465. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  34466. */
  34467. var KeyboardInfoPre = /** @class */ (function (_super) {
  34468. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  34469. /**
  34470. * Instantiates a new keyboard pre info.
  34471. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34472. * @param type Defines the type of event (KeyboardEventTypes)
  34473. * @param event Defines the related dom event
  34474. */
  34475. function KeyboardInfoPre(
  34476. /**
  34477. * Defines the type of event (KeyboardEventTypes)
  34478. */
  34479. type,
  34480. /**
  34481. * Defines the related dom event
  34482. */
  34483. event) {
  34484. var _this = _super.call(this, type, event) || this;
  34485. _this.type = type;
  34486. _this.event = event;
  34487. _this.skipOnPointerObservable = false;
  34488. return _this;
  34489. }
  34490. return KeyboardInfoPre;
  34491. }(KeyboardInfo));
  34492. /***/ }),
  34493. /***/ "./Events/pointerEvents.ts":
  34494. /*!*********************************!*\
  34495. !*** ./Events/pointerEvents.ts ***!
  34496. \*********************************/
  34497. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  34498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34499. "use strict";
  34500. __webpack_require__.r(__webpack_exports__);
  34501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  34502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  34503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  34504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  34505. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34506. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  34507. /**
  34508. * Gather the list of pointer event types as constants.
  34509. */
  34510. var PointerEventTypes = /** @class */ (function () {
  34511. function PointerEventTypes() {
  34512. }
  34513. /**
  34514. * 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.
  34515. */
  34516. PointerEventTypes.POINTERDOWN = 0x01;
  34517. /**
  34518. * The pointerup event is fired when a pointer is no longer active.
  34519. */
  34520. PointerEventTypes.POINTERUP = 0x02;
  34521. /**
  34522. * The pointermove event is fired when a pointer changes coordinates.
  34523. */
  34524. PointerEventTypes.POINTERMOVE = 0x04;
  34525. /**
  34526. * The pointerwheel event is fired when a mouse wheel has been rotated.
  34527. */
  34528. PointerEventTypes.POINTERWHEEL = 0x08;
  34529. /**
  34530. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  34531. */
  34532. PointerEventTypes.POINTERPICK = 0x10;
  34533. /**
  34534. * The pointertap event is fired when a the object has been touched and released without drag.
  34535. */
  34536. PointerEventTypes.POINTERTAP = 0x20;
  34537. /**
  34538. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  34539. */
  34540. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  34541. return PointerEventTypes;
  34542. }());
  34543. /**
  34544. * Base class of pointer info types.
  34545. */
  34546. var PointerInfoBase = /** @class */ (function () {
  34547. /**
  34548. * Instantiates the base class of pointers info.
  34549. * @param type Defines the type of event (PointerEventTypes)
  34550. * @param event Defines the related dom event
  34551. */
  34552. function PointerInfoBase(
  34553. /**
  34554. * Defines the type of event (PointerEventTypes)
  34555. */
  34556. type,
  34557. /**
  34558. * Defines the related dom event
  34559. */
  34560. event) {
  34561. this.type = type;
  34562. this.event = event;
  34563. }
  34564. return PointerInfoBase;
  34565. }());
  34566. /**
  34567. * This class is used to store pointer related info for the onPrePointerObservable event.
  34568. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  34569. */
  34570. var PointerInfoPre = /** @class */ (function (_super) {
  34571. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  34572. /**
  34573. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  34574. * @param type Defines the type of event (PointerEventTypes)
  34575. * @param event Defines the related dom event
  34576. * @param localX Defines the local x coordinates of the pointer when the event occured
  34577. * @param localY Defines the local y coordinates of the pointer when the event occured
  34578. */
  34579. function PointerInfoPre(type, event, localX, localY) {
  34580. var _this = _super.call(this, type, event) || this;
  34581. /**
  34582. * Ray from a pointer if availible (eg. 6dof controller)
  34583. */
  34584. _this.ray = null;
  34585. _this.skipOnPointerObservable = false;
  34586. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  34587. return _this;
  34588. }
  34589. return PointerInfoPre;
  34590. }(PointerInfoBase));
  34591. /**
  34592. * This type contains all the data related to a pointer event in Babylon.js.
  34593. * 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.
  34594. */
  34595. var PointerInfo = /** @class */ (function (_super) {
  34596. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  34597. /**
  34598. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  34599. * @param type Defines the type of event (PointerEventTypes)
  34600. * @param event Defines the related dom event
  34601. * @param pickInfo Defines the picking info associated to the info (if any)\
  34602. */
  34603. function PointerInfo(type, event,
  34604. /**
  34605. * Defines the picking info associated to the info (if any)\
  34606. */
  34607. pickInfo) {
  34608. var _this = _super.call(this, type, event) || this;
  34609. _this.pickInfo = pickInfo;
  34610. return _this;
  34611. }
  34612. return PointerInfo;
  34613. }(PointerInfoBase));
  34614. /***/ }),
  34615. /***/ "./Gamepads/Controllers/daydreamController.ts":
  34616. /*!****************************************************!*\
  34617. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  34618. \****************************************************/
  34619. /*! exports provided: DaydreamController */
  34620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34621. "use strict";
  34622. __webpack_require__.r(__webpack_exports__);
  34623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  34624. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34625. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  34626. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34627. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34628. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34629. /**
  34630. * Google Daydream controller
  34631. */
  34632. var DaydreamController = /** @class */ (function (_super) {
  34633. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  34634. /**
  34635. * Creates a new DaydreamController from a gamepad
  34636. * @param vrGamepad the gamepad that the controller should be created from
  34637. */
  34638. function DaydreamController(vrGamepad) {
  34639. var _this = _super.call(this, vrGamepad) || this;
  34640. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  34641. return _this;
  34642. }
  34643. /**
  34644. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34645. * @param scene scene in which to add meshes
  34646. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34647. */
  34648. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34649. var _this = this;
  34650. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  34651. _this._defaultModel = newMeshes[1];
  34652. _this.attachToMesh(_this._defaultModel);
  34653. if (meshLoaded) {
  34654. meshLoaded(_this._defaultModel);
  34655. }
  34656. });
  34657. };
  34658. /**
  34659. * Called once for each button that changed state since the last frame
  34660. * @param buttonIdx Which button index changed
  34661. * @param state New state of the button
  34662. * @param changes Which properties on the state changed since last frame
  34663. */
  34664. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34665. // Daydream controller only has 1 GamepadButton (on the trackpad).
  34666. if (buttonIdx === 0) {
  34667. var observable = this.onTriggerStateChangedObservable;
  34668. if (observable) {
  34669. observable.notifyObservers(state);
  34670. }
  34671. }
  34672. else {
  34673. // If the app or home buttons are ever made available
  34674. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  34675. }
  34676. };
  34677. /**
  34678. * Base Url for the controller model.
  34679. */
  34680. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34681. /**
  34682. * File name for the controller model.
  34683. */
  34684. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  34685. /**
  34686. * Gamepad Id prefix used to identify Daydream Controller.
  34687. */
  34688. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  34689. return DaydreamController;
  34690. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34691. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34692. canCreate: function (gamepadInfo) {
  34693. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  34694. },
  34695. create: function (gamepadInfo) {
  34696. return new DaydreamController(gamepadInfo);
  34697. }
  34698. });
  34699. /***/ }),
  34700. /***/ "./Gamepads/Controllers/gearVRController.ts":
  34701. /*!**************************************************!*\
  34702. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  34703. \**************************************************/
  34704. /*! exports provided: GearVRController */
  34705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34706. "use strict";
  34707. __webpack_require__.r(__webpack_exports__);
  34708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  34709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34710. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34711. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34712. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34713. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34714. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34715. /**
  34716. * Gear VR Controller
  34717. */
  34718. var GearVRController = /** @class */ (function (_super) {
  34719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  34720. /**
  34721. * Creates a new GearVRController from a gamepad
  34722. * @param vrGamepad the gamepad that the controller should be created from
  34723. */
  34724. function GearVRController(vrGamepad) {
  34725. var _this = _super.call(this, vrGamepad) || this;
  34726. _this._buttonIndexToObservableNameMap = [
  34727. 'onTrackpadChangedObservable',
  34728. 'onTriggerStateChangedObservable' // Trigger
  34729. ];
  34730. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  34731. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  34732. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  34733. _this._disableTrackPosition(_this._calculatedPosition);
  34734. return _this;
  34735. }
  34736. /**
  34737. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34738. * @param scene scene in which to add meshes
  34739. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34740. */
  34741. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34742. var _this = this;
  34743. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  34744. // Offset the controller so it will rotate around the users wrist
  34745. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  34746. newMeshes[1].parent = mesh;
  34747. newMeshes[1].position.z = -0.15;
  34748. _this._defaultModel = mesh;
  34749. _this.attachToMesh(_this._defaultModel);
  34750. if (meshLoaded) {
  34751. meshLoaded(_this._defaultModel);
  34752. }
  34753. });
  34754. };
  34755. /**
  34756. * Called once for each button that changed state since the last frame
  34757. * @param buttonIdx Which button index changed
  34758. * @param state New state of the button
  34759. * @param changes Which properties on the state changed since last frame
  34760. */
  34761. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34762. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  34763. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  34764. // Only emit events for buttons that we know how to map from index to observable
  34765. var observable = this[observableName];
  34766. if (observable) {
  34767. observable.notifyObservers(state);
  34768. }
  34769. }
  34770. };
  34771. /**
  34772. * Base Url for the controller model.
  34773. */
  34774. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34775. /**
  34776. * File name for the controller model.
  34777. */
  34778. GearVRController.MODEL_FILENAME = 'generic.babylon';
  34779. /**
  34780. * Gamepad Id prefix used to identify this controller.
  34781. */
  34782. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  34783. return GearVRController;
  34784. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  34785. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34786. canCreate: function (gamepadInfo) {
  34787. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  34788. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  34789. },
  34790. create: function (gamepadInfo) {
  34791. return new GearVRController(gamepadInfo);
  34792. }
  34793. });
  34794. /***/ }),
  34795. /***/ "./Gamepads/Controllers/genericController.ts":
  34796. /*!***************************************************!*\
  34797. !*** ./Gamepads/Controllers/genericController.ts ***!
  34798. \***************************************************/
  34799. /*! exports provided: GenericController */
  34800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34801. "use strict";
  34802. __webpack_require__.r(__webpack_exports__);
  34803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  34804. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34805. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34806. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34807. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34808. /**
  34809. * Generic Controller
  34810. */
  34811. var GenericController = /** @class */ (function (_super) {
  34812. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  34813. /**
  34814. * Creates a new GenericController from a gamepad
  34815. * @param vrGamepad the gamepad that the controller should be created from
  34816. */
  34817. function GenericController(vrGamepad) {
  34818. return _super.call(this, vrGamepad) || this;
  34819. }
  34820. /**
  34821. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34822. * @param scene scene in which to add meshes
  34823. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34824. */
  34825. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34826. var _this = this;
  34827. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  34828. _this._defaultModel = newMeshes[1];
  34829. _this.attachToMesh(_this._defaultModel);
  34830. if (meshLoaded) {
  34831. meshLoaded(_this._defaultModel);
  34832. }
  34833. });
  34834. };
  34835. /**
  34836. * Called once for each button that changed state since the last frame
  34837. * @param buttonIdx Which button index changed
  34838. * @param state New state of the button
  34839. * @param changes Which properties on the state changed since last frame
  34840. */
  34841. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34842. console.log("Button id: " + buttonIdx + "state: ");
  34843. console.dir(state);
  34844. };
  34845. /**
  34846. * Base Url for the controller model.
  34847. */
  34848. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34849. /**
  34850. * File name for the controller model.
  34851. */
  34852. GenericController.MODEL_FILENAME = 'generic.babylon';
  34853. return GenericController;
  34854. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34855. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  34856. /***/ }),
  34857. /***/ "./Gamepads/Controllers/index.ts":
  34858. /*!***************************************!*\
  34859. !*** ./Gamepads/Controllers/index.ts ***!
  34860. \***************************************/
  34861. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  34862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34863. "use strict";
  34864. __webpack_require__.r(__webpack_exports__);
  34865. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  34866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  34867. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  34868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  34869. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  34871. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  34872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  34873. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  34875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  34876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  34877. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  34878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  34879. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  34881. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  34882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  34883. /***/ }),
  34884. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  34885. /*!*******************************************************!*\
  34886. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  34887. \*******************************************************/
  34888. /*! exports provided: OculusTouchController */
  34889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34890. "use strict";
  34891. __webpack_require__.r(__webpack_exports__);
  34892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  34893. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34894. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34895. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34896. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34897. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34898. /**
  34899. * Oculus Touch Controller
  34900. */
  34901. var OculusTouchController = /** @class */ (function (_super) {
  34902. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  34903. /**
  34904. * Creates a new OculusTouchController from a gamepad
  34905. * @param vrGamepad the gamepad that the controller should be created from
  34906. */
  34907. function OculusTouchController(vrGamepad) {
  34908. var _this = _super.call(this, vrGamepad) || this;
  34909. /**
  34910. * Fired when the secondary trigger on this controller is modified
  34911. */
  34912. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34913. /**
  34914. * Fired when the thumb rest on this controller is modified
  34915. */
  34916. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34917. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34918. return _this;
  34919. }
  34920. /**
  34921. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34922. * @param scene scene in which to add meshes
  34923. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34924. */
  34925. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34926. var _this = this;
  34927. var meshName;
  34928. // Hand
  34929. if (this.hand === 'left') {
  34930. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34931. }
  34932. else { // Right is the default if no hand is specified
  34933. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34934. }
  34935. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34936. /*
  34937. Parent Mesh name: oculus_touch_left
  34938. - body
  34939. - trigger
  34940. - thumbstick
  34941. - grip
  34942. - button_y
  34943. - button_x
  34944. - button_enter
  34945. */
  34946. _this._defaultModel = newMeshes[1];
  34947. _this.attachToMesh(_this._defaultModel);
  34948. if (meshLoaded) {
  34949. meshLoaded(_this._defaultModel);
  34950. }
  34951. });
  34952. };
  34953. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34954. /**
  34955. * Fired when the A button on this controller is modified
  34956. */
  34957. get: function () {
  34958. if (this.hand === 'right') {
  34959. return this.onMainButtonStateChangedObservable;
  34960. }
  34961. else {
  34962. throw new Error('No A button on left hand');
  34963. }
  34964. },
  34965. enumerable: true,
  34966. configurable: true
  34967. });
  34968. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34969. /**
  34970. * Fired when the B button on this controller is modified
  34971. */
  34972. get: function () {
  34973. if (this.hand === 'right') {
  34974. return this.onSecondaryButtonStateChangedObservable;
  34975. }
  34976. else {
  34977. throw new Error('No B button on left hand');
  34978. }
  34979. },
  34980. enumerable: true,
  34981. configurable: true
  34982. });
  34983. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  34984. /**
  34985. * Fired when the X button on this controller is modified
  34986. */
  34987. get: function () {
  34988. if (this.hand === 'left') {
  34989. return this.onMainButtonStateChangedObservable;
  34990. }
  34991. else {
  34992. throw new Error('No X button on right hand');
  34993. }
  34994. },
  34995. enumerable: true,
  34996. configurable: true
  34997. });
  34998. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  34999. /**
  35000. * Fired when the Y button on this controller is modified
  35001. */
  35002. get: function () {
  35003. if (this.hand === 'left') {
  35004. return this.onSecondaryButtonStateChangedObservable;
  35005. }
  35006. else {
  35007. throw new Error('No Y button on right hand');
  35008. }
  35009. },
  35010. enumerable: true,
  35011. configurable: true
  35012. });
  35013. /**
  35014. * Called once for each button that changed state since the last frame
  35015. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35016. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35017. * 2) secondary trigger (same)
  35018. * 3) A (right) X (left), touch, pressed = value
  35019. * 4) B / Y
  35020. * 5) thumb rest
  35021. * @param buttonIdx Which button index changed
  35022. * @param state New state of the button
  35023. * @param changes Which properties on the state changed since last frame
  35024. */
  35025. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35026. var notifyObject = state; //{ state: state, changes: changes };
  35027. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35028. switch (buttonIdx) {
  35029. case 0:
  35030. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35031. return;
  35032. case 1: // index trigger
  35033. if (this._defaultModel) {
  35034. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35035. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35036. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35037. }
  35038. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35039. return;
  35040. case 2: // secondary trigger
  35041. if (this._defaultModel) {
  35042. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35043. }
  35044. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35045. return;
  35046. case 3:
  35047. if (this._defaultModel) {
  35048. if (notifyObject.pressed) {
  35049. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35050. }
  35051. else {
  35052. (this._defaultModel.getChildren()[1]).position.y = 0;
  35053. }
  35054. }
  35055. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35056. return;
  35057. case 4:
  35058. if (this._defaultModel) {
  35059. if (notifyObject.pressed) {
  35060. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35061. }
  35062. else {
  35063. (this._defaultModel.getChildren()[2]).position.y = 0;
  35064. }
  35065. }
  35066. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35067. return;
  35068. case 5:
  35069. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35070. return;
  35071. }
  35072. };
  35073. /**
  35074. * Base Url for the controller model.
  35075. */
  35076. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35077. /**
  35078. * File name for the left controller model.
  35079. */
  35080. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35081. /**
  35082. * File name for the right controller model.
  35083. */
  35084. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35085. return OculusTouchController;
  35086. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35087. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35088. canCreate: function (gamepadInfo) {
  35089. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35090. },
  35091. create: function (gamepadInfo) {
  35092. return new OculusTouchController(gamepadInfo);
  35093. }
  35094. });
  35095. /***/ }),
  35096. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35097. /*!*******************************************************!*\
  35098. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35099. \*******************************************************/
  35100. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35102. "use strict";
  35103. __webpack_require__.r(__webpack_exports__);
  35104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35107. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35108. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35109. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35110. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35111. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35112. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35113. /**
  35114. * Defines the types of pose enabled controllers that are supported
  35115. */
  35116. var PoseEnabledControllerType;
  35117. (function (PoseEnabledControllerType) {
  35118. /**
  35119. * HTC Vive
  35120. */
  35121. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35122. /**
  35123. * Oculus Rift
  35124. */
  35125. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35126. /**
  35127. * Windows mixed reality
  35128. */
  35129. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35130. /**
  35131. * Samsung gear VR
  35132. */
  35133. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35134. /**
  35135. * Google Daydream
  35136. */
  35137. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35138. /**
  35139. * Generic
  35140. */
  35141. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35142. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35143. /**
  35144. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35145. */
  35146. var PoseEnabledControllerHelper = /** @class */ (function () {
  35147. function PoseEnabledControllerHelper() {
  35148. }
  35149. /**
  35150. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35151. * @param vrGamepad the gamepad to initialized
  35152. * @returns a vr controller of the type the gamepad identified as
  35153. */
  35154. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35155. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35156. var factory = _a[_i];
  35157. if (factory.canCreate(vrGamepad)) {
  35158. return factory.create(vrGamepad);
  35159. }
  35160. }
  35161. if (this._DefaultControllerFactory) {
  35162. return this._DefaultControllerFactory(vrGamepad);
  35163. }
  35164. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35165. };
  35166. /** @hidden */
  35167. PoseEnabledControllerHelper._ControllerFactories = [];
  35168. /** @hidden */
  35169. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35170. return PoseEnabledControllerHelper;
  35171. }());
  35172. /**
  35173. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35174. */
  35175. var PoseEnabledController = /** @class */ (function (_super) {
  35176. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35177. /**
  35178. * Creates a new PoseEnabledController from a gamepad
  35179. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35180. */
  35181. function PoseEnabledController(browserGamepad) {
  35182. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35183. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35184. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35185. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35186. /**
  35187. * The device position in babylon space
  35188. */
  35189. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35190. /**
  35191. * The device rotation in babylon space
  35192. */
  35193. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35194. /**
  35195. * The scale factor of the device in babylon space
  35196. */
  35197. _this.deviceScaleFactor = 1;
  35198. // Used to convert 6dof controllers to 3dof
  35199. _this._trackPosition = true;
  35200. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35201. _this._draggedRoomRotation = 0;
  35202. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35203. /**
  35204. * Internal, matrix used to convert room space to babylon space
  35205. * @hidden
  35206. */
  35207. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35208. /**
  35209. * Node to be used when casting a ray from the controller
  35210. * @hidden
  35211. */
  35212. _this._pointingPoseNode = null;
  35213. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35214. /**
  35215. * @hidden
  35216. */
  35217. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35218. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35219. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35220. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35221. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35222. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35223. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35224. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35225. return _this;
  35226. }
  35227. /**
  35228. * @hidden
  35229. */
  35230. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35231. if (this._trackPosition) {
  35232. this._calculatedPosition.copyFrom(fixedPosition);
  35233. this._trackPosition = false;
  35234. }
  35235. };
  35236. /**
  35237. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35238. */
  35239. PoseEnabledController.prototype.update = function () {
  35240. _super.prototype.update.call(this);
  35241. this._updatePoseAndMesh();
  35242. };
  35243. /**
  35244. * Updates only the pose device and mesh without doing any button event checking
  35245. */
  35246. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35247. var pose = this.browserGamepad.pose;
  35248. this.updateFromDevice(pose);
  35249. 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) {
  35250. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35251. camera._computeDevicePosition();
  35252. this._deviceToWorld.setTranslation(camera.devicePosition);
  35253. if (camera.deviceRotationQuaternion) {
  35254. var camera = camera;
  35255. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35256. // Find the radian distance away that the headset is from the controllers rotation
  35257. 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));
  35258. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35259. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35260. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35261. this._draggedRoomRotation += rotationAmount;
  35262. // Rotate controller around headset
  35263. var sin = Math.sin(-rotationAmount);
  35264. var cos = Math.cos(-rotationAmount);
  35265. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35266. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35267. }
  35268. }
  35269. }
  35270. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35271. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35272. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35273. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35274. if (this._mesh) {
  35275. this._mesh.position.copyFrom(this.devicePosition);
  35276. if (this._mesh.rotationQuaternion) {
  35277. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35278. }
  35279. }
  35280. };
  35281. /**
  35282. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35283. * @param poseData raw pose fromthe device
  35284. */
  35285. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35286. if (poseData) {
  35287. this.rawPose = poseData;
  35288. if (poseData.position) {
  35289. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35290. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35291. this._deviceRoomPosition.z *= -1;
  35292. }
  35293. if (this._trackPosition) {
  35294. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35295. }
  35296. this._calculatedPosition.addInPlace(this.position);
  35297. }
  35298. var pose = this.rawPose;
  35299. if (poseData.orientation && pose.orientation) {
  35300. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35301. if (this._mesh) {
  35302. if (this._mesh.getScene().useRightHandedSystem) {
  35303. this._deviceRoomRotationQuaternion.z *= -1;
  35304. this._deviceRoomRotationQuaternion.w *= -1;
  35305. }
  35306. else {
  35307. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35308. }
  35309. }
  35310. // if the camera is set, rotate to the camera's rotation
  35311. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35312. }
  35313. }
  35314. };
  35315. /**
  35316. * Attaches a mesh to the controller
  35317. * @param mesh the mesh to be attached
  35318. */
  35319. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35320. if (this._mesh) {
  35321. this._mesh.parent = null;
  35322. }
  35323. this._mesh = mesh;
  35324. if (this._poseControlledCamera) {
  35325. this._mesh.parent = this._poseControlledCamera;
  35326. }
  35327. if (!this._mesh.rotationQuaternion) {
  35328. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35329. }
  35330. // 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
  35331. this._updatePoseAndMesh();
  35332. if (this._pointingPoseNode) {
  35333. var parents = [];
  35334. var obj = this._pointingPoseNode;
  35335. while (obj.parent) {
  35336. parents.push(obj.parent);
  35337. obj = obj.parent;
  35338. }
  35339. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35340. }
  35341. this._meshAttachedObservable.notifyObservers(mesh);
  35342. };
  35343. /**
  35344. * Attaches the controllers mesh to a camera
  35345. * @param camera the camera the mesh should be attached to
  35346. */
  35347. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35348. this._poseControlledCamera = camera;
  35349. if (this._mesh) {
  35350. this._mesh.parent = this._poseControlledCamera;
  35351. }
  35352. };
  35353. /**
  35354. * Disposes of the controller
  35355. */
  35356. PoseEnabledController.prototype.dispose = function () {
  35357. if (this._mesh) {
  35358. this._mesh.dispose();
  35359. }
  35360. this._mesh = null;
  35361. _super.prototype.dispose.call(this);
  35362. };
  35363. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35364. /**
  35365. * The mesh that is attached to the controller
  35366. */
  35367. get: function () {
  35368. return this._mesh;
  35369. },
  35370. enumerable: true,
  35371. configurable: true
  35372. });
  35373. /**
  35374. * Gets the ray of the controller in the direction the controller is pointing
  35375. * @param length the length the resulting ray should be
  35376. * @returns a ray in the direction the controller is pointing
  35377. */
  35378. PoseEnabledController.prototype.getForwardRay = function (length) {
  35379. if (length === void 0) { length = 100; }
  35380. if (!this.mesh) {
  35381. 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);
  35382. }
  35383. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35384. var origin = m.getTranslation();
  35385. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35386. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35387. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35388. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35389. };
  35390. /**
  35391. * Name of the child mesh that can be used to cast a ray from the controller
  35392. */
  35393. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35394. return PoseEnabledController;
  35395. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35396. /***/ }),
  35397. /***/ "./Gamepads/Controllers/viveController.ts":
  35398. /*!************************************************!*\
  35399. !*** ./Gamepads/Controllers/viveController.ts ***!
  35400. \************************************************/
  35401. /*! exports provided: ViveController */
  35402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35403. "use strict";
  35404. __webpack_require__.r(__webpack_exports__);
  35405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35406. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35407. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35408. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35409. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35410. /**
  35411. * Vive Controller
  35412. */
  35413. var ViveController = /** @class */ (function (_super) {
  35414. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35415. /**
  35416. * Creates a new ViveController from a gamepad
  35417. * @param vrGamepad the gamepad that the controller should be created from
  35418. */
  35419. function ViveController(vrGamepad) {
  35420. var _this = _super.call(this, vrGamepad) || this;
  35421. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  35422. _this._invertLeftStickY = true;
  35423. return _this;
  35424. }
  35425. /**
  35426. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35427. * @param scene scene in which to add meshes
  35428. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35429. */
  35430. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35431. var _this = this;
  35432. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  35433. /*
  35434. Parent Mesh name: ViveWand
  35435. - body
  35436. - r_gripper
  35437. - l_gripper
  35438. - menu_button
  35439. - system_button
  35440. - trackpad
  35441. - trigger
  35442. - LED
  35443. */
  35444. _this._defaultModel = newMeshes[1];
  35445. _this.attachToMesh(_this._defaultModel);
  35446. if (meshLoaded) {
  35447. meshLoaded(_this._defaultModel);
  35448. }
  35449. });
  35450. };
  35451. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  35452. /**
  35453. * Fired when the left button on this controller is modified
  35454. */
  35455. get: function () {
  35456. return this.onMainButtonStateChangedObservable;
  35457. },
  35458. enumerable: true,
  35459. configurable: true
  35460. });
  35461. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  35462. /**
  35463. * Fired when the right button on this controller is modified
  35464. */
  35465. get: function () {
  35466. return this.onMainButtonStateChangedObservable;
  35467. },
  35468. enumerable: true,
  35469. configurable: true
  35470. });
  35471. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  35472. /**
  35473. * Fired when the menu button on this controller is modified
  35474. */
  35475. get: function () {
  35476. return this.onSecondaryButtonStateChangedObservable;
  35477. },
  35478. enumerable: true,
  35479. configurable: true
  35480. });
  35481. /**
  35482. * Called once for each button that changed state since the last frame
  35483. * Vive mapping:
  35484. * 0: touchpad
  35485. * 1: trigger
  35486. * 2: left AND right buttons
  35487. * 3: menu button
  35488. * @param buttonIdx Which button index changed
  35489. * @param state New state of the button
  35490. * @param changes Which properties on the state changed since last frame
  35491. */
  35492. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35493. var notifyObject = state; //{ state: state, changes: changes };
  35494. switch (buttonIdx) {
  35495. case 0:
  35496. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35497. return;
  35498. case 1: // index trigger
  35499. if (this._defaultModel) {
  35500. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  35501. }
  35502. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35503. return;
  35504. case 2: // left AND right button
  35505. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35506. return;
  35507. case 3:
  35508. if (this._defaultModel) {
  35509. if (notifyObject.pressed) {
  35510. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35511. }
  35512. else {
  35513. (this._defaultModel.getChildren()[2]).position.y = 0;
  35514. }
  35515. }
  35516. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35517. return;
  35518. }
  35519. };
  35520. /**
  35521. * Base Url for the controller model.
  35522. */
  35523. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  35524. /**
  35525. * File name for the controller model.
  35526. */
  35527. ViveController.MODEL_FILENAME = 'wand.babylon';
  35528. return ViveController;
  35529. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35530. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35531. canCreate: function (gamepadInfo) {
  35532. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  35533. },
  35534. create: function (gamepadInfo) {
  35535. return new ViveController(gamepadInfo);
  35536. }
  35537. });
  35538. /***/ }),
  35539. /***/ "./Gamepads/Controllers/webVRController.ts":
  35540. /*!*************************************************!*\
  35541. !*** ./Gamepads/Controllers/webVRController.ts ***!
  35542. \*************************************************/
  35543. /*! exports provided: WebVRController */
  35544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35545. "use strict";
  35546. __webpack_require__.r(__webpack_exports__);
  35547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  35548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35549. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35550. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35551. /**
  35552. * Defines the WebVRController object that represents controllers tracked in 3D space
  35553. */
  35554. var WebVRController = /** @class */ (function (_super) {
  35555. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  35556. /**
  35557. * Creates a new WebVRController from a gamepad
  35558. * @param vrGamepad the gamepad that the WebVRController should be created from
  35559. */
  35560. function WebVRController(vrGamepad) {
  35561. var _this = _super.call(this, vrGamepad) || this;
  35562. // Observables
  35563. /**
  35564. * Fired when the trigger state has changed
  35565. */
  35566. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35567. /**
  35568. * Fired when the main button state has changed
  35569. */
  35570. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35571. /**
  35572. * Fired when the secondary button state has changed
  35573. */
  35574. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35575. /**
  35576. * Fired when the pad state has changed
  35577. */
  35578. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35579. /**
  35580. * Fired when controllers stick values have changed
  35581. */
  35582. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35583. /**
  35584. * X and Y axis corrisponding to the controllers joystick
  35585. */
  35586. _this.pad = { x: 0, y: 0 };
  35587. // avoid GC, store state in a tmp object
  35588. _this._changes = {
  35589. pressChanged: false,
  35590. touchChanged: false,
  35591. valueChanged: false,
  35592. changed: false
  35593. };
  35594. _this._buttons = new Array(vrGamepad.buttons.length);
  35595. _this.hand = vrGamepad.hand;
  35596. return _this;
  35597. }
  35598. /**
  35599. * Fired when a controller button's state has changed
  35600. * @param callback the callback containing the button that was modified
  35601. */
  35602. WebVRController.prototype.onButtonStateChange = function (callback) {
  35603. this._onButtonStateChange = callback;
  35604. };
  35605. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  35606. /**
  35607. * The default controller model for the controller
  35608. */
  35609. get: function () {
  35610. return this._defaultModel;
  35611. },
  35612. enumerable: true,
  35613. configurable: true
  35614. });
  35615. /**
  35616. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  35617. */
  35618. WebVRController.prototype.update = function () {
  35619. _super.prototype.update.call(this);
  35620. for (var index = 0; index < this._buttons.length; index++) {
  35621. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  35622. }
  35623. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  35624. this.pad.x = this.leftStick.x;
  35625. this.pad.y = this.leftStick.y;
  35626. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  35627. }
  35628. };
  35629. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  35630. if (!newState) {
  35631. newState = {
  35632. pressed: false,
  35633. touched: false,
  35634. value: 0
  35635. };
  35636. }
  35637. if (!currentState) {
  35638. this._buttons[buttonIndex] = {
  35639. pressed: newState.pressed,
  35640. touched: newState.touched,
  35641. value: newState.value
  35642. };
  35643. return;
  35644. }
  35645. this._checkChanges(newState, currentState);
  35646. if (this._changes.changed) {
  35647. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  35648. this._handleButtonChange(buttonIndex, newState, this._changes);
  35649. }
  35650. this._buttons[buttonIndex].pressed = newState.pressed;
  35651. this._buttons[buttonIndex].touched = newState.touched;
  35652. // oculus triggers are never 0, thou not touched.
  35653. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  35654. };
  35655. WebVRController.prototype._checkChanges = function (newState, currentState) {
  35656. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  35657. this._changes.touchChanged = newState.touched !== currentState.touched;
  35658. this._changes.valueChanged = newState.value !== currentState.value;
  35659. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  35660. return this._changes;
  35661. };
  35662. /**
  35663. * Disposes of th webVRCOntroller
  35664. */
  35665. WebVRController.prototype.dispose = function () {
  35666. _super.prototype.dispose.call(this);
  35667. this.onTriggerStateChangedObservable.clear();
  35668. this.onMainButtonStateChangedObservable.clear();
  35669. this.onSecondaryButtonStateChangedObservable.clear();
  35670. this.onPadStateChangedObservable.clear();
  35671. this.onPadValuesChangedObservable.clear();
  35672. };
  35673. return WebVRController;
  35674. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  35675. /***/ }),
  35676. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  35677. /*!*********************************************************!*\
  35678. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  35679. \*********************************************************/
  35680. /*! exports provided: WindowsMotionController */
  35681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35682. "use strict";
  35683. __webpack_require__.r(__webpack_exports__);
  35684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  35685. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35686. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35687. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35688. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35689. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35690. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35691. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35692. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35693. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35694. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35695. /**
  35696. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  35697. */
  35698. var LoadedMeshInfo = /** @class */ (function () {
  35699. function LoadedMeshInfo() {
  35700. /**
  35701. * Map of the button meshes contained in the controller
  35702. */
  35703. this.buttonMeshes = {};
  35704. /**
  35705. * Map of the axis meshes contained in the controller
  35706. */
  35707. this.axisMeshes = {};
  35708. }
  35709. return LoadedMeshInfo;
  35710. }());
  35711. /**
  35712. * Defines the WindowsMotionController object that the state of the windows motion controller
  35713. */
  35714. var WindowsMotionController = /** @class */ (function (_super) {
  35715. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  35716. /**
  35717. * Creates a new WindowsMotionController from a gamepad
  35718. * @param vrGamepad the gamepad that the controller should be created from
  35719. */
  35720. function WindowsMotionController(vrGamepad) {
  35721. var _this = _super.call(this, vrGamepad) || this;
  35722. _this._mapping = {
  35723. // Semantic button names
  35724. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  35725. // A mapping of the button name to glTF model node name
  35726. // that should be transformed by button value.
  35727. buttonMeshNames: {
  35728. 'trigger': 'SELECT',
  35729. 'menu': 'MENU',
  35730. 'grip': 'GRASP',
  35731. 'thumbstick': 'THUMBSTICK_PRESS',
  35732. 'trackpad': 'TOUCHPAD_PRESS'
  35733. },
  35734. // This mapping is used to translate from the Motion Controller to Babylon semantics
  35735. buttonObservableNames: {
  35736. 'trigger': 'onTriggerStateChangedObservable',
  35737. 'menu': 'onSecondaryButtonStateChangedObservable',
  35738. 'grip': 'onMainButtonStateChangedObservable',
  35739. 'thumbstick': 'onPadStateChangedObservable',
  35740. 'trackpad': 'onTrackpadChangedObservable'
  35741. },
  35742. // A mapping of the axis name to glTF model node name
  35743. // that should be transformed by axis value.
  35744. // This array mirrors the browserGamepad.axes array, such that
  35745. // the mesh corresponding to axis 0 is in this array index 0.
  35746. axisMeshNames: [
  35747. 'THUMBSTICK_X',
  35748. 'THUMBSTICK_Y',
  35749. 'TOUCHPAD_TOUCH_X',
  35750. 'TOUCHPAD_TOUCH_Y'
  35751. ],
  35752. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  35753. };
  35754. /**
  35755. * Fired when the trackpad on this controller is clicked
  35756. */
  35757. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35758. /**
  35759. * Fired when the trackpad on this controller is modified
  35760. */
  35761. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35762. /**
  35763. * The current x and y values of this controller's trackpad
  35764. */
  35765. _this.trackpad = { x: 0, y: 0 };
  35766. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  35767. _this._loadedMeshInfo = null;
  35768. return _this;
  35769. }
  35770. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  35771. /**
  35772. * Fired when the trigger on this controller is modified
  35773. */
  35774. get: function () {
  35775. return this.onTriggerStateChangedObservable;
  35776. },
  35777. enumerable: true,
  35778. configurable: true
  35779. });
  35780. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  35781. /**
  35782. * Fired when the menu button on this controller is modified
  35783. */
  35784. get: function () {
  35785. return this.onSecondaryButtonStateChangedObservable;
  35786. },
  35787. enumerable: true,
  35788. configurable: true
  35789. });
  35790. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  35791. /**
  35792. * Fired when the grip button on this controller is modified
  35793. */
  35794. get: function () {
  35795. return this.onMainButtonStateChangedObservable;
  35796. },
  35797. enumerable: true,
  35798. configurable: true
  35799. });
  35800. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  35801. /**
  35802. * Fired when the thumbstick button on this controller is modified
  35803. */
  35804. get: function () {
  35805. return this.onPadStateChangedObservable;
  35806. },
  35807. enumerable: true,
  35808. configurable: true
  35809. });
  35810. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  35811. /**
  35812. * Fired when the touchpad button on this controller is modified
  35813. */
  35814. get: function () {
  35815. return this.onTrackpadChangedObservable;
  35816. },
  35817. enumerable: true,
  35818. configurable: true
  35819. });
  35820. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  35821. /**
  35822. * Fired when the touchpad values on this controller are modified
  35823. */
  35824. get: function () {
  35825. return this.onTrackpadValuesChangedObservable;
  35826. },
  35827. enumerable: true,
  35828. configurable: true
  35829. });
  35830. WindowsMotionController.prototype._updateTrackpad = function () {
  35831. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  35832. this.trackpad.x = this.browserGamepad["axes"][2];
  35833. this.trackpad.y = this.browserGamepad["axes"][3];
  35834. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  35835. }
  35836. };
  35837. /**
  35838. * Called once per frame by the engine.
  35839. */
  35840. WindowsMotionController.prototype.update = function () {
  35841. _super.prototype.update.call(this);
  35842. if (this.browserGamepad.axes) {
  35843. this._updateTrackpad();
  35844. // Only need to animate axes if there is a loaded mesh
  35845. if (this._loadedMeshInfo) {
  35846. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  35847. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  35848. }
  35849. }
  35850. }
  35851. };
  35852. /**
  35853. * Called once for each button that changed state since the last frame
  35854. * @param buttonIdx Which button index changed
  35855. * @param state New state of the button
  35856. * @param changes Which properties on the state changed since last frame
  35857. */
  35858. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35859. var buttonName = this._mapping.buttons[buttonIdx];
  35860. if (!buttonName) {
  35861. return;
  35862. }
  35863. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  35864. this._updateTrackpad();
  35865. // Only emit events for buttons that we know how to map from index to name
  35866. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  35867. if (observable) {
  35868. observable.notifyObservers(state);
  35869. }
  35870. this._lerpButtonTransform(buttonName, state.value);
  35871. };
  35872. /**
  35873. * Moves the buttons on the controller mesh based on their current state
  35874. * @param buttonName the name of the button to move
  35875. * @param buttonValue the value of the button which determines the buttons new position
  35876. */
  35877. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  35878. // If there is no loaded mesh, there is nothing to transform.
  35879. if (!this._loadedMeshInfo) {
  35880. return;
  35881. }
  35882. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  35883. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35884. return;
  35885. }
  35886. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  35887. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  35888. };
  35889. /**
  35890. * Moves the axis on the controller mesh based on its current state
  35891. * @param axis the index of the axis
  35892. * @param axisValue the value of the axis which determines the meshes new position
  35893. * @hidden
  35894. */
  35895. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  35896. if (!this._loadedMeshInfo) {
  35897. return;
  35898. }
  35899. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  35900. if (!meshInfo) {
  35901. return;
  35902. }
  35903. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35904. return;
  35905. }
  35906. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  35907. var lerpValue = axisValue * 0.5 + 0.5;
  35908. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  35909. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  35910. };
  35911. /**
  35912. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35913. * @param scene scene in which to add meshes
  35914. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35915. */
  35916. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35917. var _this = this;
  35918. if (forceDefault === void 0) { forceDefault = false; }
  35919. var path;
  35920. var filename;
  35921. // Checking if GLB loader is present
  35922. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35923. // Determine the device specific folder based on the ID suffix
  35924. var device = 'default';
  35925. if (this.id && !forceDefault) {
  35926. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35927. device = ((match && match[0]) || device);
  35928. }
  35929. // Hand
  35930. if (this.hand === 'left') {
  35931. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35932. }
  35933. else { // Right is the default if no hand is specified
  35934. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35935. }
  35936. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35937. }
  35938. else {
  35939. _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");
  35940. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35941. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35942. }
  35943. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35944. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35945. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35946. if (!_this._loadedMeshInfo) {
  35947. return;
  35948. }
  35949. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35950. _this.attachToMesh(_this._defaultModel);
  35951. if (meshLoaded) {
  35952. meshLoaded(_this._defaultModel);
  35953. }
  35954. }, null, function (scene, message) {
  35955. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35956. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35957. if (!forceDefault) {
  35958. _this.initControllerMesh(scene, meshLoaded, true);
  35959. }
  35960. });
  35961. };
  35962. /**
  35963. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35964. * can be transformed by button presses and axes values, based on this._mapping.
  35965. *
  35966. * @param scene scene in which the meshes exist
  35967. * @param meshes list of meshes that make up the controller model to process
  35968. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35969. */
  35970. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35971. var loadedMeshInfo = null;
  35972. // Create a new mesh to contain the glTF hierarchy
  35973. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35974. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35975. var childMesh = null;
  35976. for (var i = 0; i < meshes.length; i++) {
  35977. var mesh = meshes[i];
  35978. if (!mesh.parent) {
  35979. // Exclude controller meshes from picking results
  35980. mesh.isPickable = false;
  35981. // Handle root node, attach to the new parentMesh
  35982. childMesh = mesh;
  35983. break;
  35984. }
  35985. }
  35986. if (childMesh) {
  35987. childMesh.setParent(parentMesh);
  35988. // Create our mesh info. Note that this method will always return non-null.
  35989. loadedMeshInfo = this.createMeshInfo(parentMesh);
  35990. }
  35991. else {
  35992. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  35993. }
  35994. return loadedMeshInfo;
  35995. };
  35996. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  35997. var loadedMeshInfo = new LoadedMeshInfo();
  35998. var i;
  35999. loadedMeshInfo.rootNode = rootNode;
  36000. // Reset the caches
  36001. loadedMeshInfo.buttonMeshes = {};
  36002. loadedMeshInfo.axisMeshes = {};
  36003. // Button Meshes
  36004. for (i = 0; i < this._mapping.buttons.length; i++) {
  36005. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36006. if (!buttonMeshName) {
  36007. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36008. continue;
  36009. }
  36010. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36011. if (!buttonMesh) {
  36012. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36013. continue;
  36014. }
  36015. var buttonMeshInfo = {
  36016. index: i,
  36017. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36018. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36019. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36020. };
  36021. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36022. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36023. }
  36024. else {
  36025. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36026. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36027. '(VALUE: ' + !!buttonMeshInfo.value +
  36028. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36029. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36030. ')');
  36031. }
  36032. }
  36033. // Axis Meshes
  36034. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36035. var axisMeshName = this._mapping.axisMeshNames[i];
  36036. if (!axisMeshName) {
  36037. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36038. continue;
  36039. }
  36040. var axisMesh = getChildByName(rootNode, axisMeshName);
  36041. if (!axisMesh) {
  36042. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36043. continue;
  36044. }
  36045. var axisMeshInfo = {
  36046. index: i,
  36047. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36048. min: getImmediateChildByName(axisMesh, 'MIN'),
  36049. max: getImmediateChildByName(axisMesh, 'MAX')
  36050. };
  36051. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36052. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36053. }
  36054. else {
  36055. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36056. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36057. '(VALUE: ' + !!axisMeshInfo.value +
  36058. ', MIN: ' + !!axisMeshInfo.min +
  36059. ', MAX:' + !!axisMeshInfo.max +
  36060. ')');
  36061. }
  36062. }
  36063. // Pointing Ray
  36064. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36065. if (!loadedMeshInfo.pointingPoseNode) {
  36066. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36067. }
  36068. else {
  36069. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36070. }
  36071. return loadedMeshInfo;
  36072. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36073. function getChildByName(node, name) {
  36074. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36075. }
  36076. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36077. function getImmediateChildByName(node, name) {
  36078. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36079. }
  36080. };
  36081. /**
  36082. * Gets the ray of the controller in the direction the controller is pointing
  36083. * @param length the length the resulting ray should be
  36084. * @returns a ray in the direction the controller is pointing
  36085. */
  36086. WindowsMotionController.prototype.getForwardRay = function (length) {
  36087. if (length === void 0) { length = 100; }
  36088. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36089. return _super.prototype.getForwardRay.call(this, length);
  36090. }
  36091. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36092. var origin = m.getTranslation();
  36093. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36094. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36095. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36096. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36097. };
  36098. /**
  36099. * Disposes of the controller
  36100. */
  36101. WindowsMotionController.prototype.dispose = function () {
  36102. _super.prototype.dispose.call(this);
  36103. this.onTrackpadChangedObservable.clear();
  36104. };
  36105. /**
  36106. * The base url used to load the left and right controller models
  36107. */
  36108. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36109. /**
  36110. * The name of the left controller model file
  36111. */
  36112. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36113. /**
  36114. * The name of the right controller model file
  36115. */
  36116. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36117. /**
  36118. * The controller name prefix for this controller type
  36119. */
  36120. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36121. /**
  36122. * The controller id pattern for this controller type
  36123. */
  36124. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36125. return WindowsMotionController;
  36126. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36127. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36128. canCreate: function (gamepadInfo) {
  36129. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36130. },
  36131. create: function (gamepadInfo) {
  36132. return new WindowsMotionController(gamepadInfo);
  36133. }
  36134. });
  36135. /***/ }),
  36136. /***/ "./Gamepads/gamepad.ts":
  36137. /*!*****************************!*\
  36138. !*** ./Gamepads/gamepad.ts ***!
  36139. \*****************************/
  36140. /*! exports provided: StickValues, Gamepad, GenericPad */
  36141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36142. "use strict";
  36143. __webpack_require__.r(__webpack_exports__);
  36144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36148. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36149. /**
  36150. * Represents a gamepad control stick position
  36151. */
  36152. var StickValues = /** @class */ (function () {
  36153. /**
  36154. * Initializes the gamepad x and y control stick values
  36155. * @param x The x component of the gamepad control stick value
  36156. * @param y The y component of the gamepad control stick value
  36157. */
  36158. function StickValues(
  36159. /**
  36160. * The x component of the control stick
  36161. */
  36162. x,
  36163. /**
  36164. * The y component of the control stick
  36165. */
  36166. y) {
  36167. this.x = x;
  36168. this.y = y;
  36169. }
  36170. return StickValues;
  36171. }());
  36172. /**
  36173. * Represents a gamepad
  36174. */
  36175. var Gamepad = /** @class */ (function () {
  36176. /**
  36177. * Initializes the gamepad
  36178. * @param id The id of the gamepad
  36179. * @param index The index of the gamepad
  36180. * @param browserGamepad The browser gamepad
  36181. * @param leftStickX The x component of the left joystick
  36182. * @param leftStickY The y component of the left joystick
  36183. * @param rightStickX The x component of the right joystick
  36184. * @param rightStickY The y component of the right joystick
  36185. */
  36186. function Gamepad(
  36187. /**
  36188. * The id of the gamepad
  36189. */
  36190. id,
  36191. /**
  36192. * The index of the gamepad
  36193. */
  36194. index,
  36195. /**
  36196. * The browser gamepad
  36197. */
  36198. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36199. if (leftStickX === void 0) { leftStickX = 0; }
  36200. if (leftStickY === void 0) { leftStickY = 1; }
  36201. if (rightStickX === void 0) { rightStickX = 2; }
  36202. if (rightStickY === void 0) { rightStickY = 3; }
  36203. this.id = id;
  36204. this.index = index;
  36205. this.browserGamepad = browserGamepad;
  36206. this._leftStick = { x: 0, y: 0 };
  36207. this._rightStick = { x: 0, y: 0 };
  36208. /** @hidden */
  36209. this._isConnected = true;
  36210. /**
  36211. * Specifies whether the left control stick should be Y-inverted
  36212. */
  36213. this._invertLeftStickY = false;
  36214. this.type = Gamepad.GAMEPAD;
  36215. this._leftStickAxisX = leftStickX;
  36216. this._leftStickAxisY = leftStickY;
  36217. this._rightStickAxisX = rightStickX;
  36218. this._rightStickAxisY = rightStickY;
  36219. if (this.browserGamepad.axes.length >= 2) {
  36220. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36221. }
  36222. if (this.browserGamepad.axes.length >= 4) {
  36223. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36224. }
  36225. }
  36226. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36227. /**
  36228. * Specifies if the gamepad has been connected
  36229. */
  36230. get: function () {
  36231. return this._isConnected;
  36232. },
  36233. enumerable: true,
  36234. configurable: true
  36235. });
  36236. /**
  36237. * Callback triggered when the left joystick has changed
  36238. * @param callback
  36239. */
  36240. Gamepad.prototype.onleftstickchanged = function (callback) {
  36241. this._onleftstickchanged = callback;
  36242. };
  36243. /**
  36244. * Callback triggered when the right joystick has changed
  36245. * @param callback
  36246. */
  36247. Gamepad.prototype.onrightstickchanged = function (callback) {
  36248. this._onrightstickchanged = callback;
  36249. };
  36250. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36251. /**
  36252. * Gets the left joystick
  36253. */
  36254. get: function () {
  36255. return this._leftStick;
  36256. },
  36257. /**
  36258. * Sets the left joystick values
  36259. */
  36260. set: function (newValues) {
  36261. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36262. this._onleftstickchanged(newValues);
  36263. }
  36264. this._leftStick = newValues;
  36265. },
  36266. enumerable: true,
  36267. configurable: true
  36268. });
  36269. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36270. /**
  36271. * Gets the right joystick
  36272. */
  36273. get: function () {
  36274. return this._rightStick;
  36275. },
  36276. /**
  36277. * Sets the right joystick value
  36278. */
  36279. set: function (newValues) {
  36280. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36281. this._onrightstickchanged(newValues);
  36282. }
  36283. this._rightStick = newValues;
  36284. },
  36285. enumerable: true,
  36286. configurable: true
  36287. });
  36288. /**
  36289. * Updates the gamepad joystick positions
  36290. */
  36291. Gamepad.prototype.update = function () {
  36292. if (this._leftStick) {
  36293. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36294. if (this._invertLeftStickY) {
  36295. this.leftStick.y *= -1;
  36296. }
  36297. }
  36298. if (this._rightStick) {
  36299. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36300. }
  36301. };
  36302. /**
  36303. * Disposes the gamepad
  36304. */
  36305. Gamepad.prototype.dispose = function () {
  36306. };
  36307. /**
  36308. * Represents a gamepad controller
  36309. */
  36310. Gamepad.GAMEPAD = 0;
  36311. /**
  36312. * Represents a generic controller
  36313. */
  36314. Gamepad.GENERIC = 1;
  36315. /**
  36316. * Represents an XBox controller
  36317. */
  36318. Gamepad.XBOX = 2;
  36319. /**
  36320. * Represents a pose-enabled controller
  36321. */
  36322. Gamepad.POSE_ENABLED = 3;
  36323. return Gamepad;
  36324. }());
  36325. /**
  36326. * Represents a generic gamepad
  36327. */
  36328. var GenericPad = /** @class */ (function (_super) {
  36329. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36330. /**
  36331. * Initializes the generic gamepad
  36332. * @param id The id of the generic gamepad
  36333. * @param index The index of the generic gamepad
  36334. * @param browserGamepad The browser gamepad
  36335. */
  36336. function GenericPad(id, index, browserGamepad) {
  36337. var _this = _super.call(this, id, index, browserGamepad) || this;
  36338. /**
  36339. * Observable triggered when a button has been pressed
  36340. */
  36341. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36342. /**
  36343. * Observable triggered when a button has been released
  36344. */
  36345. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36346. _this.type = Gamepad.GENERIC;
  36347. _this._buttons = new Array(browserGamepad.buttons.length);
  36348. return _this;
  36349. }
  36350. /**
  36351. * Callback triggered when a button has been pressed
  36352. * @param callback Called when a button has been pressed
  36353. */
  36354. GenericPad.prototype.onbuttondown = function (callback) {
  36355. this._onbuttondown = callback;
  36356. };
  36357. /**
  36358. * Callback triggered when a button has been released
  36359. * @param callback Called when a button has been released
  36360. */
  36361. GenericPad.prototype.onbuttonup = function (callback) {
  36362. this._onbuttonup = callback;
  36363. };
  36364. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36365. if (newValue !== currentValue) {
  36366. if (newValue === 1) {
  36367. if (this._onbuttondown) {
  36368. this._onbuttondown(buttonIndex);
  36369. }
  36370. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36371. }
  36372. if (newValue === 0) {
  36373. if (this._onbuttonup) {
  36374. this._onbuttonup(buttonIndex);
  36375. }
  36376. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36377. }
  36378. }
  36379. return newValue;
  36380. };
  36381. /**
  36382. * Updates the generic gamepad
  36383. */
  36384. GenericPad.prototype.update = function () {
  36385. _super.prototype.update.call(this);
  36386. for (var index = 0; index < this._buttons.length; index++) {
  36387. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36388. }
  36389. };
  36390. /**
  36391. * Disposes the generic gamepad
  36392. */
  36393. GenericPad.prototype.dispose = function () {
  36394. _super.prototype.dispose.call(this);
  36395. this.onButtonDownObservable.clear();
  36396. this.onButtonUpObservable.clear();
  36397. };
  36398. return GenericPad;
  36399. }(Gamepad));
  36400. /***/ }),
  36401. /***/ "./Gamepads/gamepadManager.ts":
  36402. /*!************************************!*\
  36403. !*** ./Gamepads/gamepadManager.ts ***!
  36404. \************************************/
  36405. /*! exports provided: GamepadManager */
  36406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36407. "use strict";
  36408. __webpack_require__.r(__webpack_exports__);
  36409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36410. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36411. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36412. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36413. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36414. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36415. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36416. /**
  36417. * Manager for handling gamepads
  36418. */
  36419. var GamepadManager = /** @class */ (function () {
  36420. /**
  36421. * Initializes the gamepad manager
  36422. * @param _scene BabylonJS scene
  36423. */
  36424. function GamepadManager(_scene) {
  36425. var _this = this;
  36426. this._scene = _scene;
  36427. this._babylonGamepads = [];
  36428. this._oneGamepadConnected = false;
  36429. /** @hidden */
  36430. this._isMonitoring = false;
  36431. /**
  36432. * observable to be triggered when the gamepad controller has been disconnected
  36433. */
  36434. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36435. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  36436. this._gamepadEventSupported = false;
  36437. }
  36438. else {
  36439. this._gamepadEventSupported = 'GamepadEvent' in window;
  36440. this._gamepadSupport = (navigator.getGamepads ||
  36441. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  36442. }
  36443. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  36444. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  36445. for (var i in _this._babylonGamepads) {
  36446. var gamepad = _this._babylonGamepads[i];
  36447. if (gamepad && gamepad._isConnected) {
  36448. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  36449. }
  36450. }
  36451. });
  36452. this._onGamepadConnectedEvent = function (evt) {
  36453. var gamepad = evt.gamepad;
  36454. if (gamepad.index in _this._babylonGamepads) {
  36455. if (_this._babylonGamepads[gamepad.index].isConnected) {
  36456. return;
  36457. }
  36458. }
  36459. var newGamepad;
  36460. if (_this._babylonGamepads[gamepad.index]) {
  36461. newGamepad = _this._babylonGamepads[gamepad.index];
  36462. newGamepad.browserGamepad = gamepad;
  36463. newGamepad._isConnected = true;
  36464. }
  36465. else {
  36466. newGamepad = _this._addNewGamepad(gamepad);
  36467. }
  36468. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36469. _this._startMonitoringGamepads();
  36470. };
  36471. this._onGamepadDisconnectedEvent = function (evt) {
  36472. var gamepad = evt.gamepad;
  36473. // Remove the gamepad from the list of gamepads to monitor.
  36474. for (var i in _this._babylonGamepads) {
  36475. if (_this._babylonGamepads[i].index === gamepad.index) {
  36476. var disconnectedGamepad = _this._babylonGamepads[i];
  36477. disconnectedGamepad._isConnected = false;
  36478. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  36479. break;
  36480. }
  36481. }
  36482. };
  36483. if (this._gamepadSupport) {
  36484. //first add already-connected gamepads
  36485. this._updateGamepadObjects();
  36486. if (this._babylonGamepads.length) {
  36487. this._startMonitoringGamepads();
  36488. }
  36489. // Checking if the gamepad connected event is supported (like in Firefox)
  36490. if (this._gamepadEventSupported) {
  36491. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  36492. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  36493. }
  36494. else {
  36495. this._startMonitoringGamepads();
  36496. }
  36497. }
  36498. }
  36499. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  36500. /**
  36501. * The gamepads in the game pad manager
  36502. */
  36503. get: function () {
  36504. return this._babylonGamepads;
  36505. },
  36506. enumerable: true,
  36507. configurable: true
  36508. });
  36509. /**
  36510. * Get the gamepad controllers based on type
  36511. * @param type The type of gamepad controller
  36512. * @returns Nullable gamepad
  36513. */
  36514. GamepadManager.prototype.getGamepadByType = function (type) {
  36515. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  36516. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  36517. var gamepad = _a[_i];
  36518. if (gamepad && gamepad.type === type) {
  36519. return gamepad;
  36520. }
  36521. }
  36522. return null;
  36523. };
  36524. /**
  36525. * Disposes the gamepad manager
  36526. */
  36527. GamepadManager.prototype.dispose = function () {
  36528. if (this._gamepadEventSupported) {
  36529. if (this._onGamepadConnectedEvent) {
  36530. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  36531. }
  36532. if (this._onGamepadDisconnectedEvent) {
  36533. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  36534. }
  36535. this._onGamepadConnectedEvent = null;
  36536. this._onGamepadDisconnectedEvent = null;
  36537. }
  36538. this._babylonGamepads.forEach(function (gamepad) {
  36539. gamepad.dispose();
  36540. });
  36541. this.onGamepadConnectedObservable.clear();
  36542. this.onGamepadDisconnectedObservable.clear();
  36543. this._oneGamepadConnected = false;
  36544. this._stopMonitoringGamepads();
  36545. this._babylonGamepads = [];
  36546. };
  36547. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  36548. if (!this._oneGamepadConnected) {
  36549. this._oneGamepadConnected = true;
  36550. }
  36551. var newGamepad;
  36552. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  36553. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  36554. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  36555. }
  36556. // if pose is supported, use the (WebVR) pose enabled controller
  36557. else if (gamepad.pose) {
  36558. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  36559. }
  36560. else {
  36561. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  36562. }
  36563. this._babylonGamepads[newGamepad.index] = newGamepad;
  36564. return newGamepad;
  36565. };
  36566. GamepadManager.prototype._startMonitoringGamepads = function () {
  36567. if (!this._isMonitoring) {
  36568. this._isMonitoring = true;
  36569. //back-comp
  36570. if (!this._scene) {
  36571. this._checkGamepadsStatus();
  36572. }
  36573. }
  36574. };
  36575. GamepadManager.prototype._stopMonitoringGamepads = function () {
  36576. this._isMonitoring = false;
  36577. };
  36578. /** @hidden */
  36579. GamepadManager.prototype._checkGamepadsStatus = function () {
  36580. var _this = this;
  36581. // Hack to be compatible Chrome
  36582. this._updateGamepadObjects();
  36583. for (var i in this._babylonGamepads) {
  36584. var gamepad = this._babylonGamepads[i];
  36585. if (!gamepad || !gamepad.isConnected) {
  36586. continue;
  36587. }
  36588. gamepad.update();
  36589. }
  36590. if (this._isMonitoring && !this._scene) {
  36591. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  36592. }
  36593. };
  36594. // This function is called only on Chrome, which does not properly support
  36595. // connection/disconnection events and forces you to recopy again the gamepad object
  36596. GamepadManager.prototype._updateGamepadObjects = function () {
  36597. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  36598. for (var i = 0; i < gamepads.length; i++) {
  36599. var gamepad = gamepads[i];
  36600. if (gamepad) {
  36601. if (!this._babylonGamepads[gamepad.index]) {
  36602. var newGamepad = this._addNewGamepad(gamepad);
  36603. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36604. }
  36605. else {
  36606. // Forced to copy again this object for Chrome for unknown reason
  36607. this._babylonGamepads[i].browserGamepad = gamepad;
  36608. if (!this._babylonGamepads[i].isConnected) {
  36609. this._babylonGamepads[i]._isConnected = true;
  36610. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  36611. }
  36612. }
  36613. }
  36614. }
  36615. };
  36616. return GamepadManager;
  36617. }());
  36618. /***/ }),
  36619. /***/ "./Gamepads/gamepadSceneComponent.ts":
  36620. /*!*******************************************!*\
  36621. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  36622. \*******************************************/
  36623. /*! exports provided: GamepadSystemSceneComponent */
  36624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36625. "use strict";
  36626. __webpack_require__.r(__webpack_exports__);
  36627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  36628. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  36629. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  36630. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36631. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  36632. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  36633. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  36634. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  36635. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  36636. get: function () {
  36637. if (!this._gamepadManager) {
  36638. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  36639. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  36640. if (!component) {
  36641. component = new GamepadSystemSceneComponent(this);
  36642. this._addComponent(component);
  36643. }
  36644. }
  36645. return this._gamepadManager;
  36646. },
  36647. enumerable: true,
  36648. configurable: true
  36649. });
  36650. /**
  36651. * Adds a gamepad to the free camera inputs manager
  36652. */
  36653. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  36654. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  36655. return this;
  36656. };
  36657. /**
  36658. * Adds a gamepad to the arc rotate camera inputs manager
  36659. */
  36660. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  36661. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  36662. return this;
  36663. };
  36664. /**
  36665. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  36666. */
  36667. var GamepadSystemSceneComponent = /** @class */ (function () {
  36668. /**
  36669. * Creates a new instance of the component for the given scene
  36670. * @param scene Defines the scene to register the component in
  36671. */
  36672. function GamepadSystemSceneComponent(scene) {
  36673. /**
  36674. * The component name helpfull to identify the component in the list of scene components.
  36675. */
  36676. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  36677. this.scene = scene;
  36678. }
  36679. /**
  36680. * Registers the component in a given scene
  36681. */
  36682. GamepadSystemSceneComponent.prototype.register = function () {
  36683. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  36684. };
  36685. /**
  36686. * Rebuilds the elements related to this component in case of
  36687. * context lost for instance.
  36688. */
  36689. GamepadSystemSceneComponent.prototype.rebuild = function () {
  36690. // Nothing to do for gamepads
  36691. };
  36692. /**
  36693. * Disposes the component and the associated ressources
  36694. */
  36695. GamepadSystemSceneComponent.prototype.dispose = function () {
  36696. var gamepadManager = this.scene._gamepadManager;
  36697. if (gamepadManager) {
  36698. gamepadManager.dispose();
  36699. this.scene._gamepadManager = null;
  36700. }
  36701. };
  36702. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  36703. var gamepadManager = this.scene._gamepadManager;
  36704. if (gamepadManager && gamepadManager._isMonitoring) {
  36705. gamepadManager._checkGamepadsStatus();
  36706. }
  36707. };
  36708. return GamepadSystemSceneComponent;
  36709. }());
  36710. /***/ }),
  36711. /***/ "./Gamepads/index.ts":
  36712. /*!***************************!*\
  36713. !*** ./Gamepads/index.ts ***!
  36714. \***************************/
  36715. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36717. "use strict";
  36718. __webpack_require__.r(__webpack_exports__);
  36719. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  36720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  36721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  36722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  36723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  36724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  36725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  36726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  36727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  36728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  36729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  36730. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  36732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  36733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  36734. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  36736. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  36737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  36738. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  36740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  36741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  36742. /***/ }),
  36743. /***/ "./Gamepads/xboxGamepad.ts":
  36744. /*!*********************************!*\
  36745. !*** ./Gamepads/xboxGamepad.ts ***!
  36746. \*********************************/
  36747. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36749. "use strict";
  36750. __webpack_require__.r(__webpack_exports__);
  36751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  36752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  36753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  36754. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36755. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36756. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36757. /**
  36758. * Defines supported buttons for XBox360 compatible gamepads
  36759. */
  36760. var Xbox360Button;
  36761. (function (Xbox360Button) {
  36762. /** A */
  36763. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  36764. /** B */
  36765. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  36766. /** X */
  36767. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  36768. /** Y */
  36769. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  36770. /** Start */
  36771. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  36772. /** Back */
  36773. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  36774. /** Left button */
  36775. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  36776. /** Right button */
  36777. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  36778. /** Left stick */
  36779. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  36780. /** Right stick */
  36781. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  36782. })(Xbox360Button || (Xbox360Button = {}));
  36783. /** Defines values for XBox360 DPad */
  36784. var Xbox360Dpad;
  36785. (function (Xbox360Dpad) {
  36786. /** Up */
  36787. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  36788. /** Down */
  36789. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  36790. /** Left */
  36791. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  36792. /** Right */
  36793. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  36794. })(Xbox360Dpad || (Xbox360Dpad = {}));
  36795. /**
  36796. * Defines a XBox360 gamepad
  36797. */
  36798. var Xbox360Pad = /** @class */ (function (_super) {
  36799. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  36800. /**
  36801. * Creates a new XBox360 gamepad object
  36802. * @param id defines the id of this gamepad
  36803. * @param index defines its index
  36804. * @param gamepad defines the internal HTML gamepad object
  36805. * @param xboxOne defines if it is a XBox One gamepad
  36806. */
  36807. function Xbox360Pad(id, index, gamepad, xboxOne) {
  36808. if (xboxOne === void 0) { xboxOne = false; }
  36809. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  36810. _this._leftTrigger = 0;
  36811. _this._rightTrigger = 0;
  36812. /** Observable raised when a button is pressed */
  36813. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36814. /** Observable raised when a button is released */
  36815. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36816. /** Observable raised when a pad is pressed */
  36817. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36818. /** Observable raised when a pad is released */
  36819. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36820. _this._buttonA = 0;
  36821. _this._buttonB = 0;
  36822. _this._buttonX = 0;
  36823. _this._buttonY = 0;
  36824. _this._buttonBack = 0;
  36825. _this._buttonStart = 0;
  36826. _this._buttonLB = 0;
  36827. _this._buttonRB = 0;
  36828. _this._buttonLeftStick = 0;
  36829. _this._buttonRightStick = 0;
  36830. _this._dPadUp = 0;
  36831. _this._dPadDown = 0;
  36832. _this._dPadLeft = 0;
  36833. _this._dPadRight = 0;
  36834. _this._isXboxOnePad = false;
  36835. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  36836. _this._isXboxOnePad = xboxOne;
  36837. return _this;
  36838. }
  36839. /**
  36840. * Defines the callback to call when left trigger is pressed
  36841. * @param callback defines the callback to use
  36842. */
  36843. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  36844. this._onlefttriggerchanged = callback;
  36845. };
  36846. /**
  36847. * Defines the callback to call when right trigger is pressed
  36848. * @param callback defines the callback to use
  36849. */
  36850. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  36851. this._onrighttriggerchanged = callback;
  36852. };
  36853. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  36854. /**
  36855. * Gets the left trigger value
  36856. */
  36857. get: function () {
  36858. return this._leftTrigger;
  36859. },
  36860. /**
  36861. * Sets the left trigger value
  36862. */
  36863. set: function (newValue) {
  36864. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  36865. this._onlefttriggerchanged(newValue);
  36866. }
  36867. this._leftTrigger = newValue;
  36868. },
  36869. enumerable: true,
  36870. configurable: true
  36871. });
  36872. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  36873. /**
  36874. * Gets the right trigger value
  36875. */
  36876. get: function () {
  36877. return this._rightTrigger;
  36878. },
  36879. /**
  36880. * Sets the right trigger value
  36881. */
  36882. set: function (newValue) {
  36883. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  36884. this._onrighttriggerchanged(newValue);
  36885. }
  36886. this._rightTrigger = newValue;
  36887. },
  36888. enumerable: true,
  36889. configurable: true
  36890. });
  36891. /**
  36892. * Defines the callback to call when a button is pressed
  36893. * @param callback defines the callback to use
  36894. */
  36895. Xbox360Pad.prototype.onbuttondown = function (callback) {
  36896. this._onbuttondown = callback;
  36897. };
  36898. /**
  36899. * Defines the callback to call when a button is released
  36900. * @param callback defines the callback to use
  36901. */
  36902. Xbox360Pad.prototype.onbuttonup = function (callback) {
  36903. this._onbuttonup = callback;
  36904. };
  36905. /**
  36906. * Defines the callback to call when a pad is pressed
  36907. * @param callback defines the callback to use
  36908. */
  36909. Xbox360Pad.prototype.ondpaddown = function (callback) {
  36910. this._ondpaddown = callback;
  36911. };
  36912. /**
  36913. * Defines the callback to call when a pad is released
  36914. * @param callback defines the callback to use
  36915. */
  36916. Xbox360Pad.prototype.ondpadup = function (callback) {
  36917. this._ondpadup = callback;
  36918. };
  36919. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36920. if (newValue !== currentValue) {
  36921. if (newValue === 1) {
  36922. if (this._onbuttondown) {
  36923. this._onbuttondown(buttonType);
  36924. }
  36925. this.onButtonDownObservable.notifyObservers(buttonType);
  36926. }
  36927. if (newValue === 0) {
  36928. if (this._onbuttonup) {
  36929. this._onbuttonup(buttonType);
  36930. }
  36931. this.onButtonUpObservable.notifyObservers(buttonType);
  36932. }
  36933. }
  36934. return newValue;
  36935. };
  36936. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36937. if (newValue !== currentValue) {
  36938. if (newValue === 1) {
  36939. if (this._ondpaddown) {
  36940. this._ondpaddown(buttonType);
  36941. }
  36942. this.onPadDownObservable.notifyObservers(buttonType);
  36943. }
  36944. if (newValue === 0) {
  36945. if (this._ondpadup) {
  36946. this._ondpadup(buttonType);
  36947. }
  36948. this.onPadUpObservable.notifyObservers(buttonType);
  36949. }
  36950. }
  36951. return newValue;
  36952. };
  36953. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36954. /**
  36955. * Gets the value of the `A` button
  36956. */
  36957. get: function () {
  36958. return this._buttonA;
  36959. },
  36960. /**
  36961. * Sets the value of the `A` button
  36962. */
  36963. set: function (value) {
  36964. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36965. },
  36966. enumerable: true,
  36967. configurable: true
  36968. });
  36969. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36970. /**
  36971. * Gets the value of the `B` button
  36972. */
  36973. get: function () {
  36974. return this._buttonB;
  36975. },
  36976. /**
  36977. * Sets the value of the `B` button
  36978. */
  36979. set: function (value) {
  36980. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  36981. },
  36982. enumerable: true,
  36983. configurable: true
  36984. });
  36985. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  36986. /**
  36987. * Gets the value of the `X` button
  36988. */
  36989. get: function () {
  36990. return this._buttonX;
  36991. },
  36992. /**
  36993. * Sets the value of the `X` button
  36994. */
  36995. set: function (value) {
  36996. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  36997. },
  36998. enumerable: true,
  36999. configurable: true
  37000. });
  37001. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37002. /**
  37003. * Gets the value of the `Y` button
  37004. */
  37005. get: function () {
  37006. return this._buttonY;
  37007. },
  37008. /**
  37009. * Sets the value of the `Y` button
  37010. */
  37011. set: function (value) {
  37012. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37013. },
  37014. enumerable: true,
  37015. configurable: true
  37016. });
  37017. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37018. /**
  37019. * Gets the value of the `Start` button
  37020. */
  37021. get: function () {
  37022. return this._buttonStart;
  37023. },
  37024. /**
  37025. * Sets the value of the `Start` button
  37026. */
  37027. set: function (value) {
  37028. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37029. },
  37030. enumerable: true,
  37031. configurable: true
  37032. });
  37033. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37034. /**
  37035. * Gets the value of the `Back` button
  37036. */
  37037. get: function () {
  37038. return this._buttonBack;
  37039. },
  37040. /**
  37041. * Sets the value of the `Back` button
  37042. */
  37043. set: function (value) {
  37044. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37045. },
  37046. enumerable: true,
  37047. configurable: true
  37048. });
  37049. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37050. /**
  37051. * Gets the value of the `Left` button
  37052. */
  37053. get: function () {
  37054. return this._buttonLB;
  37055. },
  37056. /**
  37057. * Sets the value of the `Left` button
  37058. */
  37059. set: function (value) {
  37060. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37061. },
  37062. enumerable: true,
  37063. configurable: true
  37064. });
  37065. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37066. /**
  37067. * Gets the value of the `Right` button
  37068. */
  37069. get: function () {
  37070. return this._buttonRB;
  37071. },
  37072. /**
  37073. * Sets the value of the `Right` button
  37074. */
  37075. set: function (value) {
  37076. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37077. },
  37078. enumerable: true,
  37079. configurable: true
  37080. });
  37081. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37082. /**
  37083. * Gets the value of the Left joystick
  37084. */
  37085. get: function () {
  37086. return this._buttonLeftStick;
  37087. },
  37088. /**
  37089. * Sets the value of the Left joystick
  37090. */
  37091. set: function (value) {
  37092. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37093. },
  37094. enumerable: true,
  37095. configurable: true
  37096. });
  37097. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37098. /**
  37099. * Gets the value of the Right joystick
  37100. */
  37101. get: function () {
  37102. return this._buttonRightStick;
  37103. },
  37104. /**
  37105. * Sets the value of the Right joystick
  37106. */
  37107. set: function (value) {
  37108. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37109. },
  37110. enumerable: true,
  37111. configurable: true
  37112. });
  37113. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37114. /**
  37115. * Gets the value of D-pad up
  37116. */
  37117. get: function () {
  37118. return this._dPadUp;
  37119. },
  37120. /**
  37121. * Sets the value of D-pad up
  37122. */
  37123. set: function (value) {
  37124. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37125. },
  37126. enumerable: true,
  37127. configurable: true
  37128. });
  37129. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37130. /**
  37131. * Gets the value of D-pad down
  37132. */
  37133. get: function () {
  37134. return this._dPadDown;
  37135. },
  37136. /**
  37137. * Sets the value of D-pad down
  37138. */
  37139. set: function (value) {
  37140. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37141. },
  37142. enumerable: true,
  37143. configurable: true
  37144. });
  37145. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37146. /**
  37147. * Gets the value of D-pad left
  37148. */
  37149. get: function () {
  37150. return this._dPadLeft;
  37151. },
  37152. /**
  37153. * Sets the value of D-pad left
  37154. */
  37155. set: function (value) {
  37156. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37157. },
  37158. enumerable: true,
  37159. configurable: true
  37160. });
  37161. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37162. /**
  37163. * Gets the value of D-pad right
  37164. */
  37165. get: function () {
  37166. return this._dPadRight;
  37167. },
  37168. /**
  37169. * Sets the value of D-pad right
  37170. */
  37171. set: function (value) {
  37172. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37173. },
  37174. enumerable: true,
  37175. configurable: true
  37176. });
  37177. /**
  37178. * Force the gamepad to synchronize with device values
  37179. */
  37180. Xbox360Pad.prototype.update = function () {
  37181. _super.prototype.update.call(this);
  37182. if (this._isXboxOnePad) {
  37183. this.buttonA = this.browserGamepad.buttons[0].value;
  37184. this.buttonB = this.browserGamepad.buttons[1].value;
  37185. this.buttonX = this.browserGamepad.buttons[2].value;
  37186. this.buttonY = this.browserGamepad.buttons[3].value;
  37187. this.buttonLB = this.browserGamepad.buttons[4].value;
  37188. this.buttonRB = this.browserGamepad.buttons[5].value;
  37189. this.leftTrigger = this.browserGamepad.axes[2];
  37190. this.rightTrigger = this.browserGamepad.axes[5];
  37191. this.buttonBack = this.browserGamepad.buttons[9].value;
  37192. this.buttonStart = this.browserGamepad.buttons[8].value;
  37193. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37194. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37195. this.dPadUp = this.browserGamepad.buttons[11].value;
  37196. this.dPadDown = this.browserGamepad.buttons[12].value;
  37197. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37198. this.dPadRight = this.browserGamepad.buttons[14].value;
  37199. }
  37200. else {
  37201. this.buttonA = this.browserGamepad.buttons[0].value;
  37202. this.buttonB = this.browserGamepad.buttons[1].value;
  37203. this.buttonX = this.browserGamepad.buttons[2].value;
  37204. this.buttonY = this.browserGamepad.buttons[3].value;
  37205. this.buttonLB = this.browserGamepad.buttons[4].value;
  37206. this.buttonRB = this.browserGamepad.buttons[5].value;
  37207. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37208. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37209. this.buttonBack = this.browserGamepad.buttons[8].value;
  37210. this.buttonStart = this.browserGamepad.buttons[9].value;
  37211. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37212. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37213. this.dPadUp = this.browserGamepad.buttons[12].value;
  37214. this.dPadDown = this.browserGamepad.buttons[13].value;
  37215. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37216. this.dPadRight = this.browserGamepad.buttons[15].value;
  37217. }
  37218. };
  37219. /**
  37220. * Disposes the gamepad
  37221. */
  37222. Xbox360Pad.prototype.dispose = function () {
  37223. _super.prototype.dispose.call(this);
  37224. this.onButtonDownObservable.clear();
  37225. this.onButtonUpObservable.clear();
  37226. this.onPadDownObservable.clear();
  37227. this.onPadUpObservable.clear();
  37228. };
  37229. return Xbox360Pad;
  37230. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37231. /***/ }),
  37232. /***/ "./Gizmos/axisDragGizmo.ts":
  37233. /*!*********************************!*\
  37234. !*** ./Gizmos/axisDragGizmo.ts ***!
  37235. \*********************************/
  37236. /*! exports provided: AxisDragGizmo */
  37237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37238. "use strict";
  37239. __webpack_require__.r(__webpack_exports__);
  37240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37241. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37242. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37243. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37244. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37245. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37246. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37247. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37248. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37249. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37250. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37251. /**
  37252. * Single axis drag gizmo
  37253. */
  37254. var AxisDragGizmo = /** @class */ (function (_super) {
  37255. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37256. /**
  37257. * Creates an AxisDragGizmo
  37258. * @param gizmoLayer The utility layer the gizmo will be added to
  37259. * @param dragAxis The axis which the gizmo will be able to drag on
  37260. * @param color The color of the gizmo
  37261. */
  37262. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37263. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37264. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37265. var _this = _super.call(this, gizmoLayer) || this;
  37266. _this._pointerObserver = null;
  37267. /**
  37268. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37269. */
  37270. _this.snapDistance = 0;
  37271. /**
  37272. * Event that fires each time the gizmo snaps to a new location.
  37273. * * snapDistance is the the change in distance
  37274. */
  37275. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37276. // Create Material
  37277. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37278. coloredMaterial.disableLighting = true;
  37279. coloredMaterial.emissiveColor = color;
  37280. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37281. hoverMaterial.disableLighting = true;
  37282. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37283. // Build mesh on root node
  37284. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37285. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37286. arrow.scaling.scaleInPlace(1 / 3);
  37287. arrow.parent = _this._rootMesh;
  37288. var currentSnapDragDistance = 0;
  37289. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37290. var tmpSnapEvent = { snapDistance: 0 };
  37291. // Add drag behavior to handle events when the gizmo is dragged
  37292. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37293. _this.dragBehavior.moveAttached = false;
  37294. _this._rootMesh.addBehavior(_this.dragBehavior);
  37295. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37296. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37297. _this.dragBehavior.onDragObservable.add(function (event) {
  37298. if (_this.attachedMesh) {
  37299. // Convert delta to local translation if it has a parent
  37300. if (_this.attachedMesh.parent) {
  37301. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37302. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37303. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37304. }
  37305. else {
  37306. localDelta.copyFrom(event.delta);
  37307. }
  37308. // Snapping logic
  37309. if (_this.snapDistance == 0) {
  37310. _this.attachedMesh.position.addInPlace(localDelta);
  37311. }
  37312. else {
  37313. currentSnapDragDistance += event.dragDistance;
  37314. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37315. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37316. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37317. localDelta.normalizeToRef(tmpVector);
  37318. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37319. _this.attachedMesh.position.addInPlace(tmpVector);
  37320. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37321. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37322. }
  37323. }
  37324. }
  37325. });
  37326. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37327. if (_this._customMeshSet) {
  37328. return;
  37329. }
  37330. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37331. var material = isHovered ? hoverMaterial : coloredMaterial;
  37332. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37333. m.material = material;
  37334. if (m.color) {
  37335. m.color = material.emissiveColor;
  37336. }
  37337. });
  37338. });
  37339. return _this;
  37340. }
  37341. /** @hidden */
  37342. AxisDragGizmo._CreateArrow = function (scene, material) {
  37343. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37344. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37345. 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);
  37346. line.color = material.emissiveColor;
  37347. cylinder.parent = arrow;
  37348. line.parent = arrow;
  37349. // Position arrow pointing in its drag axis
  37350. cylinder.scaling.scaleInPlace(0.05);
  37351. cylinder.material = material;
  37352. cylinder.rotation.x = Math.PI / 2;
  37353. cylinder.position.z += 0.3;
  37354. line.scaling.scaleInPlace(0.26);
  37355. line.rotation.x = Math.PI / 2;
  37356. line.material = material;
  37357. return arrow;
  37358. };
  37359. /** @hidden */
  37360. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37361. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37362. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37363. var mesh = _a[_i];
  37364. var childInstance = mesh.createInstance(mesh.name);
  37365. childInstance.parent = instance;
  37366. }
  37367. return instance;
  37368. };
  37369. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37370. if (this.dragBehavior) {
  37371. this.dragBehavior.enabled = value ? true : false;
  37372. }
  37373. };
  37374. /**
  37375. * Disposes of the gizmo
  37376. */
  37377. AxisDragGizmo.prototype.dispose = function () {
  37378. this.onSnapObservable.clear();
  37379. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37380. this.dragBehavior.detach();
  37381. _super.prototype.dispose.call(this);
  37382. };
  37383. return AxisDragGizmo;
  37384. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37385. /***/ }),
  37386. /***/ "./Gizmos/axisScaleGizmo.ts":
  37387. /*!**********************************!*\
  37388. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37389. \**********************************/
  37390. /*! exports provided: AxisScaleGizmo */
  37391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37392. "use strict";
  37393. __webpack_require__.r(__webpack_exports__);
  37394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37395. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37396. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37397. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37398. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37399. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37400. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37401. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37402. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37403. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37404. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37405. /**
  37406. * Single axis scale gizmo
  37407. */
  37408. var AxisScaleGizmo = /** @class */ (function (_super) {
  37409. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37410. /**
  37411. * Creates an AxisScaleGizmo
  37412. * @param gizmoLayer The utility layer the gizmo will be added to
  37413. * @param dragAxis The axis which the gizmo will be able to scale on
  37414. * @param color The color of the gizmo
  37415. */
  37416. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  37417. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37418. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37419. var _this = _super.call(this, gizmoLayer) || this;
  37420. _this._pointerObserver = null;
  37421. /**
  37422. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37423. */
  37424. _this.snapDistance = 0;
  37425. /**
  37426. * Event that fires each time the gizmo snaps to a new location.
  37427. * * snapDistance is the the change in distance
  37428. */
  37429. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37430. /**
  37431. * If the scaling operation should be done on all axis (default: false)
  37432. */
  37433. _this.uniformScaling = false;
  37434. // Create Material
  37435. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37436. _this._coloredMaterial.disableLighting = true;
  37437. _this._coloredMaterial.emissiveColor = color;
  37438. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37439. hoverMaterial.disableLighting = true;
  37440. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37441. // Build mesh on root node
  37442. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37443. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  37444. 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);
  37445. arrowTail.color = _this._coloredMaterial.emissiveColor;
  37446. arrow.addChild(arrowMesh);
  37447. arrow.addChild(arrowTail);
  37448. // Position arrow pointing in its drag axis
  37449. arrowMesh.scaling.scaleInPlace(0.1);
  37450. arrowMesh.material = _this._coloredMaterial;
  37451. arrowMesh.rotation.x = Math.PI / 2;
  37452. arrowMesh.position.z += 0.3;
  37453. arrowTail.scaling.scaleInPlace(0.26);
  37454. arrowTail.rotation.x = Math.PI / 2;
  37455. arrowTail.material = _this._coloredMaterial;
  37456. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37457. _this._rootMesh.addChild(arrow);
  37458. arrow.scaling.scaleInPlace(1 / 3);
  37459. // Add drag behavior to handle events when the gizmo is dragged
  37460. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37461. _this.dragBehavior.moveAttached = false;
  37462. _this._rootMesh.addBehavior(_this.dragBehavior);
  37463. var currentSnapDragDistance = 0;
  37464. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37465. var tmpSnapEvent = { snapDistance: 0 };
  37466. _this.dragBehavior.onDragObservable.add(function (event) {
  37467. if (_this.attachedMesh) {
  37468. // Snapping logic
  37469. var snapped = false;
  37470. var dragSteps = 0;
  37471. if (_this.uniformScaling) {
  37472. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  37473. if (tmpVector.y < 0) {
  37474. tmpVector.scaleInPlace(-1);
  37475. }
  37476. }
  37477. else {
  37478. tmpVector.copyFrom(dragAxis);
  37479. }
  37480. if (_this.snapDistance == 0) {
  37481. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  37482. }
  37483. else {
  37484. currentSnapDragDistance += event.dragDistance;
  37485. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37486. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37487. if (currentSnapDragDistance < 0) {
  37488. dragSteps *= -1;
  37489. }
  37490. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37491. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  37492. snapped = true;
  37493. }
  37494. else {
  37495. tmpVector.scaleInPlace(0);
  37496. }
  37497. }
  37498. _this.attachedMesh.scaling.addInPlace(tmpVector);
  37499. if (snapped) {
  37500. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37501. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37502. }
  37503. }
  37504. });
  37505. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37506. if (_this._customMeshSet) {
  37507. return;
  37508. }
  37509. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37510. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  37511. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37512. m.material = material;
  37513. if (m.color) {
  37514. m.color = material.emissiveColor;
  37515. }
  37516. });
  37517. });
  37518. return _this;
  37519. }
  37520. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  37521. if (this.dragBehavior) {
  37522. this.dragBehavior.enabled = value ? true : false;
  37523. }
  37524. };
  37525. /**
  37526. * Disposes of the gizmo
  37527. */
  37528. AxisScaleGizmo.prototype.dispose = function () {
  37529. this.onSnapObservable.clear();
  37530. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37531. this.dragBehavior.detach();
  37532. _super.prototype.dispose.call(this);
  37533. };
  37534. /**
  37535. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37536. * @param mesh The mesh to replace the default mesh of the gizmo
  37537. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  37538. */
  37539. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  37540. var _this = this;
  37541. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  37542. _super.prototype.setCustomMesh.call(this, mesh);
  37543. if (useGizmoMaterial) {
  37544. this._rootMesh.getChildMeshes().forEach(function (m) {
  37545. m.material = _this._coloredMaterial;
  37546. if (m.color) {
  37547. m.color = _this._coloredMaterial.emissiveColor;
  37548. }
  37549. });
  37550. this._customMeshSet = false;
  37551. }
  37552. };
  37553. return AxisScaleGizmo;
  37554. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37555. /***/ }),
  37556. /***/ "./Gizmos/boundingBoxGizmo.ts":
  37557. /*!************************************!*\
  37558. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  37559. \************************************/
  37560. /*! exports provided: BoundingBoxGizmo */
  37561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37562. "use strict";
  37563. __webpack_require__.r(__webpack_exports__);
  37564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  37565. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37566. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37567. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37568. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37569. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37570. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37571. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  37572. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37573. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37574. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37575. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37576. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37577. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37578. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  37579. /**
  37580. * Bounding box gizmo
  37581. */
  37582. var BoundingBoxGizmo = /** @class */ (function (_super) {
  37583. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  37584. /**
  37585. * Creates an BoundingBoxGizmo
  37586. * @param gizmoLayer The utility layer the gizmo will be added to
  37587. * @param color The color of the gizmo
  37588. */
  37589. function BoundingBoxGizmo(color, gizmoLayer) {
  37590. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  37591. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  37592. var _this = _super.call(this, gizmoLayer) || this;
  37593. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  37594. _this._renderObserver = null;
  37595. _this._pointerObserver = null;
  37596. _this._scaleDragSpeed = 0.2;
  37597. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37598. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  37599. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  37600. /**
  37601. * 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)
  37602. */
  37603. _this.ignoreChildren = false;
  37604. /**
  37605. * 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)
  37606. */
  37607. _this.includeChildPredicate = null;
  37608. /**
  37609. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  37610. */
  37611. _this.rotationSphereSize = 0.1;
  37612. /**
  37613. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  37614. */
  37615. _this.scaleBoxSize = 0.1;
  37616. /**
  37617. * 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)
  37618. */
  37619. _this.fixedDragMeshScreenSize = false;
  37620. /**
  37621. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  37622. */
  37623. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  37624. /**
  37625. * Fired when a rotation sphere or scale box is dragged
  37626. */
  37627. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37628. /**
  37629. * Fired when a scale box is dragged
  37630. */
  37631. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37632. /**
  37633. * Fired when a scale box drag is ended
  37634. */
  37635. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37636. /**
  37637. * Fired when a rotation sphere is dragged
  37638. */
  37639. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37640. /**
  37641. * Fired when a rotation sphere drag is ended
  37642. */
  37643. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37644. /**
  37645. * 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)
  37646. */
  37647. _this.scalePivot = null;
  37648. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  37649. // Dragging
  37650. _this._dragMesh = null;
  37651. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  37652. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  37653. _this._updateScale = false;
  37654. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  37655. // Create Materials
  37656. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37657. coloredMaterial.disableLighting = true;
  37658. coloredMaterial.emissiveColor = color;
  37659. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37660. hoverColoredMaterial.disableLighting = true;
  37661. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  37662. // Build bounding box out of lines
  37663. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37664. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37665. var lines = [];
  37666. 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));
  37667. 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));
  37668. 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));
  37669. 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));
  37670. 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));
  37671. 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));
  37672. 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));
  37673. 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));
  37674. 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));
  37675. 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));
  37676. 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));
  37677. 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));
  37678. lines.forEach(function (l) {
  37679. l.color = color;
  37680. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  37681. l.isPickable = false;
  37682. _this._lineBoundingBox.addChild(l);
  37683. });
  37684. _this._rootMesh.addChild(_this._lineBoundingBox);
  37685. // Create rotation spheres
  37686. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37687. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37688. var _loop_1 = function (i_1) {
  37689. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  37690. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37691. sphere.material = coloredMaterial;
  37692. // Drag behavior
  37693. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  37694. _dragBehavior.moveAttached = false;
  37695. _dragBehavior.updateDragPlane = false;
  37696. sphere.addBehavior(_dragBehavior);
  37697. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  37698. var totalTurnAmountOfDrag = 0;
  37699. _dragBehavior.onDragStartObservable.add(function () {
  37700. startingTurnDirection.copyFrom(sphere.forward);
  37701. totalTurnAmountOfDrag = 0;
  37702. });
  37703. _dragBehavior.onDragObservable.add(function (event) {
  37704. _this.onRotationSphereDragObservable.notifyObservers({});
  37705. if (_this.attachedMesh) {
  37706. var originalParent = _this.attachedMesh.parent;
  37707. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37708. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37709. return;
  37710. }
  37711. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37712. var worldDragDirection = startingTurnDirection;
  37713. // Project the world right on to the drag plane
  37714. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  37715. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  37716. // project drag delta on to the resulting drag axis and rotate based on that
  37717. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  37718. // Make rotation relative to size of mesh.
  37719. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37720. // Rotate based on axis
  37721. if (!_this.attachedMesh.rotationQuaternion) {
  37722. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37723. }
  37724. if (!_this._anchorMesh.rotationQuaternion) {
  37725. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  37726. }
  37727. // Do not allow the object to turn more than a full circle
  37728. totalTurnAmountOfDrag += projectDist;
  37729. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  37730. if (i_1 >= 8) {
  37731. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  37732. }
  37733. else if (i_1 >= 4) {
  37734. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  37735. }
  37736. else {
  37737. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  37738. }
  37739. // Rotate around center of bounding box
  37740. _this._anchorMesh.addChild(_this.attachedMesh);
  37741. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  37742. _this._anchorMesh.removeChild(_this.attachedMesh);
  37743. _this.attachedMesh.setParent(originalParent);
  37744. }
  37745. _this.updateBoundingBox();
  37746. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37747. }
  37748. _this._updateDummy();
  37749. });
  37750. // Selection/deselection
  37751. _dragBehavior.onDragStartObservable.add(function () {
  37752. _this.onDragStartObservable.notifyObservers({});
  37753. _this._selectNode(sphere);
  37754. });
  37755. _dragBehavior.onDragEndObservable.add(function () {
  37756. _this.onRotationSphereDragEndObservable.notifyObservers({});
  37757. _this._selectNode(null);
  37758. _this._updateDummy();
  37759. });
  37760. this_1._rotateSpheresParent.addChild(sphere);
  37761. };
  37762. var this_1 = this, _dragBehavior;
  37763. for (var i_1 = 0; i_1 < 12; i_1++) {
  37764. _loop_1(i_1);
  37765. }
  37766. _this._rootMesh.addChild(_this._rotateSpheresParent);
  37767. // Create scale cubes
  37768. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37769. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37770. for (var i = 0; i < 2; i++) {
  37771. for (var j = 0; j < 2; j++) {
  37772. var _loop_2 = function () {
  37773. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  37774. box.material = coloredMaterial;
  37775. // Dragging logic
  37776. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  37777. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37778. _dragBehavior.moveAttached = false;
  37779. box.addBehavior(_dragBehavior);
  37780. _dragBehavior.onDragObservable.add(function (event) {
  37781. _this.onScaleBoxDragObservable.notifyObservers({});
  37782. if (_this.attachedMesh) {
  37783. var originalParent = _this.attachedMesh.parent;
  37784. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37785. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37786. return;
  37787. }
  37788. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37789. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37790. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  37791. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  37792. _this.updateBoundingBox();
  37793. if (_this.scalePivot) {
  37794. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  37795. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  37796. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  37797. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37798. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37799. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  37800. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37801. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  37802. }
  37803. else {
  37804. // Scale from the position of the opposite corner
  37805. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  37806. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37807. }
  37808. _this._anchorMesh.addChild(_this.attachedMesh);
  37809. _this._anchorMesh.scaling.addInPlace(deltaScale);
  37810. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  37811. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  37812. }
  37813. _this._anchorMesh.removeChild(_this.attachedMesh);
  37814. _this.attachedMesh.setParent(originalParent);
  37815. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37816. }
  37817. _this._updateDummy();
  37818. });
  37819. // Selection/deselection
  37820. _dragBehavior.onDragStartObservable.add(function () {
  37821. _this.onDragStartObservable.notifyObservers({});
  37822. _this._selectNode(box);
  37823. });
  37824. _dragBehavior.onDragEndObservable.add(function () {
  37825. _this.onScaleBoxDragEndObservable.notifyObservers({});
  37826. _this._selectNode(null);
  37827. _this._updateDummy();
  37828. });
  37829. this_2._scaleBoxesParent.addChild(box);
  37830. };
  37831. var this_2 = this, _dragBehavior;
  37832. for (var k = 0; k < 2; k++) {
  37833. _loop_2();
  37834. }
  37835. }
  37836. }
  37837. _this._rootMesh.addChild(_this._scaleBoxesParent);
  37838. // Hover color change
  37839. var pointerIds = new Array();
  37840. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37841. if (!pointerIds[pointerInfo.event.pointerId]) {
  37842. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  37843. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  37844. pointerIds[pointerInfo.event.pointerId] = mesh;
  37845. mesh.material = hoverColoredMaterial;
  37846. }
  37847. });
  37848. }
  37849. else {
  37850. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  37851. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  37852. delete pointerIds[pointerInfo.event.pointerId];
  37853. }
  37854. }
  37855. });
  37856. // Update bounding box positions
  37857. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  37858. // Only update the bouding box if scaling has changed
  37859. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  37860. _this.updateBoundingBox();
  37861. }
  37862. else if (_this.fixedDragMeshScreenSize) {
  37863. _this._updateRotationSpheres();
  37864. _this._updateScaleBoxes();
  37865. }
  37866. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  37867. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  37868. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  37869. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  37870. }
  37871. });
  37872. _this.updateBoundingBox();
  37873. return _this;
  37874. }
  37875. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  37876. var _this = this;
  37877. if (value) {
  37878. // Reset anchor mesh to match attached mesh's scale
  37879. // This is needed to avoid invalid box/sphere position on first drag
  37880. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  37881. var originalParent = value.parent;
  37882. this._anchorMesh.addChild(value);
  37883. this._anchorMesh.removeChild(value);
  37884. value.setParent(originalParent);
  37885. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  37886. this.updateBoundingBox();
  37887. value.getChildMeshes(false).forEach(function (m) {
  37888. m.markAsDirty("scaling");
  37889. });
  37890. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  37891. _this._updateDummy();
  37892. });
  37893. }
  37894. };
  37895. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  37896. this._rotateSpheresParent.getChildMeshes()
  37897. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  37898. m.isVisible = (!selectedMesh || m == selectedMesh);
  37899. });
  37900. };
  37901. /**
  37902. * Updates the bounding box information for the Gizmo
  37903. */
  37904. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  37905. if (this.attachedMesh) {
  37906. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  37907. var originalParent = this.attachedMesh.parent;
  37908. this.attachedMesh.setParent(null);
  37909. this._update();
  37910. // Rotate based on axis
  37911. if (!this.attachedMesh.rotationQuaternion) {
  37912. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  37913. }
  37914. if (!this._anchorMesh.rotationQuaternion) {
  37915. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  37916. }
  37917. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37918. // Store original position and reset mesh to origin before computing the bounding box
  37919. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37920. this._tmpVector.copyFrom(this.attachedMesh.position);
  37921. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37922. this.attachedMesh.position.set(0, 0, 0);
  37923. // Update bounding dimensions/positions
  37924. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37925. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37926. // Update gizmo to match bounding box scaling and rotation
  37927. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37928. 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);
  37929. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37930. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37931. this._lineBoundingBox.computeWorldMatrix();
  37932. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37933. // restore position/rotation values
  37934. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37935. this.attachedMesh.position.copyFrom(this._tmpVector);
  37936. this.attachedMesh.setParent(originalParent);
  37937. }
  37938. this._updateRotationSpheres();
  37939. this._updateScaleBoxes();
  37940. if (this.attachedMesh) {
  37941. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37942. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37943. }
  37944. };
  37945. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37946. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37947. for (var i = 0; i < 3; i++) {
  37948. for (var j = 0; j < 2; j++) {
  37949. for (var k = 0; k < 2; k++) {
  37950. var index = ((i * 4) + (j * 2)) + k;
  37951. if (i == 0) {
  37952. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37953. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37954. 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));
  37955. }
  37956. if (i == 1) {
  37957. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37958. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37959. 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));
  37960. }
  37961. if (i == 2) {
  37962. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37963. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37964. 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));
  37965. }
  37966. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37967. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37968. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37969. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37970. }
  37971. else {
  37972. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37973. }
  37974. }
  37975. }
  37976. }
  37977. };
  37978. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  37979. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  37980. for (var i = 0; i < 2; i++) {
  37981. for (var j = 0; j < 2; j++) {
  37982. for (var k = 0; k < 2; k++) {
  37983. var index = ((i * 4) + (j * 2)) + k;
  37984. if (scaleBoxes[index]) {
  37985. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37986. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37987. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37988. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37989. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37990. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37991. }
  37992. else {
  37993. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  37994. }
  37995. }
  37996. }
  37997. }
  37998. }
  37999. };
  38000. /**
  38001. * Enables rotation on the specified axis and disables rotation on the others
  38002. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38003. */
  38004. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38005. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38006. if (i < 4) {
  38007. m.setEnabled(axis.indexOf("x") != -1);
  38008. }
  38009. else if (i < 8) {
  38010. m.setEnabled(axis.indexOf("y") != -1);
  38011. }
  38012. else {
  38013. m.setEnabled(axis.indexOf("z") != -1);
  38014. }
  38015. });
  38016. };
  38017. /**
  38018. * Enables/disables scaling
  38019. * @param enable if scaling should be enabled
  38020. */
  38021. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38022. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38023. m.setEnabled(enable);
  38024. });
  38025. };
  38026. BoundingBoxGizmo.prototype._updateDummy = function () {
  38027. if (this._dragMesh) {
  38028. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38029. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38030. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38031. }
  38032. };
  38033. /**
  38034. * Enables a pointer drag behavior on the bounding box of the gizmo
  38035. */
  38036. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38037. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38038. this._dragMesh.visibility = 0;
  38039. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38040. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38041. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38042. };
  38043. /**
  38044. * Disposes of the gizmo
  38045. */
  38046. BoundingBoxGizmo.prototype.dispose = function () {
  38047. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38048. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38049. this._lineBoundingBox.dispose();
  38050. this._rotateSpheresParent.dispose();
  38051. this._scaleBoxesParent.dispose();
  38052. if (this._dragMesh) {
  38053. this._dragMesh.dispose();
  38054. }
  38055. _super.prototype.dispose.call(this);
  38056. };
  38057. /**
  38058. * 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)
  38059. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38060. * @returns the bounding box mesh with the passed in mesh as a child
  38061. */
  38062. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38063. var makeNotPickable = function (root) {
  38064. root.isPickable = false;
  38065. root.getChildMeshes().forEach(function (c) {
  38066. makeNotPickable(c);
  38067. });
  38068. };
  38069. makeNotPickable(mesh);
  38070. // Reset position to get boudning box from origin with no rotation
  38071. if (!mesh.rotationQuaternion) {
  38072. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38073. }
  38074. var oldPos = mesh.position.clone();
  38075. var oldRot = mesh.rotationQuaternion.clone();
  38076. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38077. mesh.position.set(0, 0, 0);
  38078. // Update bounding dimensions/positions
  38079. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38080. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38081. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38082. // Adjust scale to avoid undefined behavior when adding child
  38083. if (box.scaling.y === 0) {
  38084. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38085. }
  38086. if (box.scaling.x === 0) {
  38087. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38088. }
  38089. if (box.scaling.z === 0) {
  38090. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38091. }
  38092. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38093. // Restore original positions
  38094. mesh.addChild(box);
  38095. mesh.rotationQuaternion.copyFrom(oldRot);
  38096. mesh.position.copyFrom(oldPos);
  38097. // Reverse parenting
  38098. mesh.removeChild(box);
  38099. box.addChild(mesh);
  38100. box.visibility = 0;
  38101. return box;
  38102. };
  38103. /**
  38104. * CustomMeshes are not supported by this gizmo
  38105. * @param mesh The mesh to replace the default mesh of the gizmo
  38106. */
  38107. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38108. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38109. };
  38110. return BoundingBoxGizmo;
  38111. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38112. /***/ }),
  38113. /***/ "./Gizmos/gizmo.ts":
  38114. /*!*************************!*\
  38115. !*** ./Gizmos/gizmo.ts ***!
  38116. \*************************/
  38117. /*! exports provided: Gizmo */
  38118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38119. "use strict";
  38120. __webpack_require__.r(__webpack_exports__);
  38121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38122. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38123. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38124. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38125. /**
  38126. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38127. */
  38128. var Gizmo = /** @class */ (function () {
  38129. /**
  38130. * Creates a gizmo
  38131. * @param gizmoLayer The utility layer the gizmo will be added to
  38132. */
  38133. function Gizmo(
  38134. /** The utility layer the gizmo will be added to */
  38135. gizmoLayer) {
  38136. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38137. var _this = this;
  38138. this.gizmoLayer = gizmoLayer;
  38139. /**
  38140. * Ratio for the scale of the gizmo (Default: 1)
  38141. */
  38142. this.scaleRatio = 1;
  38143. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38144. /**
  38145. * If a custom mesh has been set (Default: false)
  38146. */
  38147. this._customMeshSet = false;
  38148. /**
  38149. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38150. */
  38151. this.updateGizmoRotationToMatchAttachedMesh = true;
  38152. /**
  38153. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38154. */
  38155. this.updateGizmoPositionToMatchAttachedMesh = true;
  38156. /**
  38157. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38158. */
  38159. this._updateScale = true;
  38160. this._interactionsEnabled = true;
  38161. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38162. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38163. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38164. _this._update();
  38165. });
  38166. this.attachedMesh = null;
  38167. }
  38168. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38169. /**
  38170. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38171. * * When set, interactions will be enabled
  38172. */
  38173. get: function () {
  38174. return this._attachedMesh;
  38175. },
  38176. set: function (value) {
  38177. this._attachedMesh = value;
  38178. this._rootMesh.setEnabled(value ? true : false);
  38179. this._attachedMeshChanged(value);
  38180. },
  38181. enumerable: true,
  38182. configurable: true
  38183. });
  38184. /**
  38185. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38186. * @param mesh The mesh to replace the default mesh of the gizmo
  38187. */
  38188. Gizmo.prototype.setCustomMesh = function (mesh) {
  38189. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38190. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38191. }
  38192. this._rootMesh.getChildMeshes().forEach(function (c) {
  38193. c.dispose();
  38194. });
  38195. mesh.parent = this._rootMesh;
  38196. this._customMeshSet = true;
  38197. };
  38198. Gizmo.prototype._attachedMeshChanged = function (value) {
  38199. };
  38200. /**
  38201. * @hidden
  38202. * Updates the gizmo to match the attached mesh's position/rotation
  38203. */
  38204. Gizmo.prototype._update = function () {
  38205. if (this.attachedMesh) {
  38206. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38207. if (!this._rootMesh.rotationQuaternion) {
  38208. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38209. }
  38210. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38211. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38212. if (this.attachedMesh.scaling.x < 0) {
  38213. this.attachedMesh.scaling.x *= -1;
  38214. }
  38215. if (this.attachedMesh.scaling.y < 0) {
  38216. this.attachedMesh.scaling.y *= -1;
  38217. }
  38218. if (this.attachedMesh.scaling.z < 0) {
  38219. this.attachedMesh.scaling.z *= -1;
  38220. }
  38221. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38222. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38223. this.attachedMesh.computeWorldMatrix();
  38224. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38225. }
  38226. else if (this._rootMesh.rotationQuaternion) {
  38227. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38228. }
  38229. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38230. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38231. }
  38232. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38233. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38234. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38235. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38236. }
  38237. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38238. var dist = this._tempVector.length() * this.scaleRatio;
  38239. this._rootMesh.scaling.set(dist, dist, dist);
  38240. }
  38241. }
  38242. };
  38243. /**
  38244. * Disposes of the gizmo
  38245. */
  38246. Gizmo.prototype.dispose = function () {
  38247. this._rootMesh.dispose();
  38248. if (this._beforeRenderObserver) {
  38249. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38250. }
  38251. };
  38252. return Gizmo;
  38253. }());
  38254. /***/ }),
  38255. /***/ "./Gizmos/gizmoManager.ts":
  38256. /*!********************************!*\
  38257. !*** ./Gizmos/gizmoManager.ts ***!
  38258. \********************************/
  38259. /*! exports provided: GizmoManager */
  38260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38261. "use strict";
  38262. __webpack_require__.r(__webpack_exports__);
  38263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38264. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38265. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38266. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38267. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38268. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38269. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38270. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38271. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38272. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38273. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38274. /**
  38275. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38276. */
  38277. var GizmoManager = /** @class */ (function () {
  38278. /**
  38279. * Instatiates a gizmo manager
  38280. * @param scene the scene to overlay the gizmos on top of
  38281. */
  38282. function GizmoManager(scene) {
  38283. var _this = this;
  38284. this.scene = scene;
  38285. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38286. this.clearGizmoOnEmptyPointerEvent = false;
  38287. /** Fires an event when the manager is attached to a mesh */
  38288. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38289. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38290. this._pointerObserver = null;
  38291. this._attachedMesh = null;
  38292. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38293. /**
  38294. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38295. */
  38296. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38297. /**
  38298. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38299. */
  38300. this.attachableMeshes = null;
  38301. /**
  38302. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38303. */
  38304. this.usePointerToAttachGizmos = true;
  38305. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38306. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38307. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38308. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38309. // Instatiate/dispose gizmos based on pointer actions
  38310. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38311. if (!_this.usePointerToAttachGizmos) {
  38312. return;
  38313. }
  38314. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38315. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38316. var node = pointerInfo.pickInfo.pickedMesh;
  38317. if (_this.attachableMeshes == null) {
  38318. // Attach to the most parent node
  38319. while (node && node.parent != null) {
  38320. node = node.parent;
  38321. }
  38322. }
  38323. else {
  38324. // Attach to the parent node that is an attachableMesh
  38325. var found = false;
  38326. _this.attachableMeshes.forEach(function (mesh) {
  38327. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38328. node = mesh;
  38329. found = true;
  38330. }
  38331. });
  38332. if (!found) {
  38333. node = null;
  38334. }
  38335. }
  38336. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38337. if (_this._attachedMesh != node) {
  38338. _this.attachToMesh(node);
  38339. }
  38340. }
  38341. else {
  38342. if (_this.clearGizmoOnEmptyPointerEvent) {
  38343. _this.attachToMesh(null);
  38344. }
  38345. }
  38346. }
  38347. else {
  38348. if (_this.clearGizmoOnEmptyPointerEvent) {
  38349. _this.attachToMesh(null);
  38350. }
  38351. }
  38352. }
  38353. });
  38354. }
  38355. /**
  38356. * Attaches a set of gizmos to the specified mesh
  38357. * @param mesh The mesh the gizmo's should be attached to
  38358. */
  38359. GizmoManager.prototype.attachToMesh = function (mesh) {
  38360. if (this._attachedMesh) {
  38361. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38362. }
  38363. this._attachedMesh = mesh;
  38364. for (var key in this.gizmos) {
  38365. var gizmo = (this.gizmos[key]);
  38366. if (gizmo && this._gizmosEnabled[key]) {
  38367. gizmo.attachedMesh = mesh;
  38368. }
  38369. }
  38370. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38371. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38372. }
  38373. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38374. };
  38375. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38376. get: function () {
  38377. return this._gizmosEnabled.positionGizmo;
  38378. },
  38379. /**
  38380. * If the position gizmo is enabled
  38381. */
  38382. set: function (value) {
  38383. if (value) {
  38384. if (!this.gizmos.positionGizmo) {
  38385. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38386. }
  38387. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38388. }
  38389. else if (this.gizmos.positionGizmo) {
  38390. this.gizmos.positionGizmo.attachedMesh = null;
  38391. }
  38392. this._gizmosEnabled.positionGizmo = value;
  38393. },
  38394. enumerable: true,
  38395. configurable: true
  38396. });
  38397. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38398. get: function () {
  38399. return this._gizmosEnabled.rotationGizmo;
  38400. },
  38401. /**
  38402. * If the rotation gizmo is enabled
  38403. */
  38404. set: function (value) {
  38405. if (value) {
  38406. if (!this.gizmos.rotationGizmo) {
  38407. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  38408. }
  38409. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  38410. }
  38411. else if (this.gizmos.rotationGizmo) {
  38412. this.gizmos.rotationGizmo.attachedMesh = null;
  38413. }
  38414. this._gizmosEnabled.rotationGizmo = value;
  38415. },
  38416. enumerable: true,
  38417. configurable: true
  38418. });
  38419. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  38420. get: function () {
  38421. return this._gizmosEnabled.scaleGizmo;
  38422. },
  38423. /**
  38424. * If the scale gizmo is enabled
  38425. */
  38426. set: function (value) {
  38427. if (value) {
  38428. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  38429. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  38430. }
  38431. else if (this.gizmos.scaleGizmo) {
  38432. this.gizmos.scaleGizmo.attachedMesh = null;
  38433. }
  38434. this._gizmosEnabled.scaleGizmo = value;
  38435. },
  38436. enumerable: true,
  38437. configurable: true
  38438. });
  38439. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  38440. get: function () {
  38441. return this._gizmosEnabled.boundingBoxGizmo;
  38442. },
  38443. /**
  38444. * If the boundingBox gizmo is enabled
  38445. */
  38446. set: function (value) {
  38447. if (value) {
  38448. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  38449. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  38450. if (this._attachedMesh) {
  38451. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38452. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38453. }
  38454. }
  38455. else if (this.gizmos.boundingBoxGizmo) {
  38456. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  38457. }
  38458. this._gizmosEnabled.boundingBoxGizmo = value;
  38459. },
  38460. enumerable: true,
  38461. configurable: true
  38462. });
  38463. /**
  38464. * Disposes of the gizmo manager
  38465. */
  38466. GizmoManager.prototype.dispose = function () {
  38467. this.scene.onPointerObservable.remove(this._pointerObserver);
  38468. for (var key in this.gizmos) {
  38469. var gizmo = (this.gizmos[key]);
  38470. if (gizmo) {
  38471. gizmo.dispose();
  38472. }
  38473. }
  38474. this._defaultKeepDepthUtilityLayer.dispose();
  38475. this._defaultUtilityLayer.dispose();
  38476. this.boundingBoxDragBehavior.detach();
  38477. this.onAttachedToMeshObservable.clear();
  38478. };
  38479. return GizmoManager;
  38480. }());
  38481. /***/ }),
  38482. /***/ "./Gizmos/index.ts":
  38483. /*!*************************!*\
  38484. !*** ./Gizmos/index.ts ***!
  38485. \*************************/
  38486. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  38487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38488. "use strict";
  38489. __webpack_require__.r(__webpack_exports__);
  38490. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  38492. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  38494. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  38496. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  38498. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  38499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  38500. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  38502. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  38504. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  38506. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  38508. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  38509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  38510. /***/ }),
  38511. /***/ "./Gizmos/lightGizmo.ts":
  38512. /*!******************************!*\
  38513. !*** ./Gizmos/lightGizmo.ts ***!
  38514. \******************************/
  38515. /*! exports provided: LightGizmo */
  38516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38517. "use strict";
  38518. __webpack_require__.r(__webpack_exports__);
  38519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  38520. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38521. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38522. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38523. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38524. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38525. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38526. /**
  38527. * Gizmo that enables viewing a light
  38528. */
  38529. var LightGizmo = /** @class */ (function (_super) {
  38530. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  38531. /**
  38532. * Creates a LightGizmo
  38533. * @param gizmoLayer The utility layer the gizmo will be added to
  38534. */
  38535. function LightGizmo(gizmoLayer) {
  38536. var _this = _super.call(this, gizmoLayer) || this;
  38537. _this._light = null;
  38538. _this._box = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("light", 0.02, 0, 0.02, 16, 1, _this.gizmoLayer.utilityLayerScene);
  38539. _this._box.rotation.x = -Math.PI / 2;
  38540. _this._box.bakeCurrentTransformIntoVertices();
  38541. _this._box.material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", _this.gizmoLayer.utilityLayerScene);
  38542. _this._box.material.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Yellow();
  38543. _this._rootMesh.addChild(_this._box);
  38544. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  38545. return _this;
  38546. }
  38547. Object.defineProperty(LightGizmo.prototype, "light", {
  38548. get: function () {
  38549. return this._light;
  38550. },
  38551. /**
  38552. * The light that the gizmo is attached to
  38553. */
  38554. set: function (light) {
  38555. this._light = light;
  38556. if (light.position) {
  38557. this.attachedMesh.position.copyFrom(light.position);
  38558. }
  38559. if (light.direction) {
  38560. this._box.setDirection(light.direction);
  38561. }
  38562. },
  38563. enumerable: true,
  38564. configurable: true
  38565. });
  38566. /**
  38567. * @hidden
  38568. * Updates the gizmo to match the attached mesh's position/rotation
  38569. */
  38570. LightGizmo.prototype._update = function () {
  38571. _super.prototype._update.call(this);
  38572. if (!this._light) {
  38573. return;
  38574. }
  38575. if (this._light.position) {
  38576. this._light.position.copyFrom(this.attachedMesh.position);
  38577. }
  38578. if (this._light.direction) {
  38579. this._light.direction.copyFrom(this._box.forward);
  38580. }
  38581. if (!this._light.isEnabled()) {
  38582. this._box.material.emissiveColor.set(0, 0, 0);
  38583. }
  38584. else {
  38585. this._box.material.emissiveColor.set(1, 1, 1);
  38586. }
  38587. };
  38588. return LightGizmo;
  38589. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38590. /***/ }),
  38591. /***/ "./Gizmos/planeRotationGizmo.ts":
  38592. /*!**************************************!*\
  38593. !*** ./Gizmos/planeRotationGizmo.ts ***!
  38594. \**************************************/
  38595. /*! exports provided: PlaneRotationGizmo */
  38596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38597. "use strict";
  38598. __webpack_require__.r(__webpack_exports__);
  38599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  38600. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38601. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38602. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38603. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38604. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38605. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38606. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38607. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38608. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38609. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38610. /**
  38611. * Single plane rotation gizmo
  38612. */
  38613. var PlaneRotationGizmo = /** @class */ (function (_super) {
  38614. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  38615. /**
  38616. * Creates a PlaneRotationGizmo
  38617. * @param gizmoLayer The utility layer the gizmo will be added to
  38618. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  38619. * @param color The color of the gizmo
  38620. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38621. */
  38622. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  38623. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38624. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38625. if (tessellation === void 0) { tessellation = 32; }
  38626. var _this = _super.call(this, gizmoLayer) || this;
  38627. _this._pointerObserver = null;
  38628. /**
  38629. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  38630. */
  38631. _this.snapDistance = 0;
  38632. /**
  38633. * Event that fires each time the gizmo snaps to a new location.
  38634. * * snapDistance is the the change in distance
  38635. */
  38636. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38637. // Create Material
  38638. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38639. coloredMaterial.disableLighting = true;
  38640. coloredMaterial.emissiveColor = color;
  38641. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38642. hoverMaterial.disableLighting = true;
  38643. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38644. // Build mesh on root node
  38645. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38646. // Create circle out of lines
  38647. var radius = 0.8;
  38648. var points = new Array();
  38649. for (var i = 0; i < tessellation; i++) {
  38650. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  38651. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  38652. }
  38653. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  38654. rotationMesh.color = coloredMaterial.emissiveColor;
  38655. // Position arrow pointing in its drag axis
  38656. rotationMesh.scaling.scaleInPlace(0.26);
  38657. rotationMesh.material = coloredMaterial;
  38658. rotationMesh.rotation.x = Math.PI / 2;
  38659. parentMesh.addChild(rotationMesh);
  38660. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  38661. _this._rootMesh.addChild(parentMesh);
  38662. parentMesh.scaling.scaleInPlace(1 / 3);
  38663. // Add drag behavior to handle events when the gizmo is dragged
  38664. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  38665. _this.dragBehavior.moveAttached = false;
  38666. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  38667. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  38668. _this._rootMesh.addBehavior(_this.dragBehavior);
  38669. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38670. _this.dragBehavior.onDragStartObservable.add(function (e) {
  38671. if (_this.attachedMesh) {
  38672. lastDragPosition.copyFrom(e.dragPlanePoint);
  38673. }
  38674. });
  38675. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38676. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38677. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38678. var tmpSnapEvent = { snapDistance: 0 };
  38679. var currentSnapDragDistance = 0;
  38680. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38681. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38682. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  38683. _this.dragBehavior.onDragObservable.add(function (event) {
  38684. if (_this.attachedMesh) {
  38685. if (!_this.attachedMesh.rotationQuaternion) {
  38686. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38687. }
  38688. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  38689. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  38690. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  38691. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  38692. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  38693. var angle = Math.atan2(cross.length(), dot);
  38694. planeNormalTowardsCamera.copyFrom(planeNormal);
  38695. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  38696. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38697. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  38698. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  38699. }
  38700. // Flip up vector depending on which side the camera is on
  38701. if (gizmoLayer.utilityLayerScene.activeCamera) {
  38702. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  38703. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  38704. planeNormalTowardsCamera.scaleInPlace(-1);
  38705. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  38706. }
  38707. }
  38708. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  38709. if (halfCircleSide) {
  38710. angle = -angle;
  38711. }
  38712. // Snapping logic
  38713. var snapped = false;
  38714. if (_this.snapDistance != 0) {
  38715. currentSnapDragDistance += angle;
  38716. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38717. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38718. if (currentSnapDragDistance < 0) {
  38719. dragSteps *= -1;
  38720. }
  38721. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38722. angle = _this.snapDistance * dragSteps;
  38723. snapped = true;
  38724. }
  38725. else {
  38726. angle = 0;
  38727. }
  38728. }
  38729. // If the mesh has a parent, convert needed world rotation to local rotation
  38730. tmpMatrix.reset();
  38731. if (_this.attachedMesh.parent) {
  38732. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38733. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  38734. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  38735. }
  38736. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  38737. var quaternionCoefficient = Math.sin(angle / 2);
  38738. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  38739. // 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
  38740. if (tmpMatrix.determinant() > 0) {
  38741. amountToRotate.toEulerAnglesToRef(tmpVector);
  38742. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  38743. }
  38744. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38745. // Rotate selected mesh quaternion over fixed axis
  38746. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  38747. }
  38748. else {
  38749. // Rotate selected mesh quaternion over rotated axis
  38750. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  38751. }
  38752. lastDragPosition.copyFrom(event.dragPlanePoint);
  38753. if (snapped) {
  38754. tmpSnapEvent.snapDistance = angle;
  38755. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38756. }
  38757. }
  38758. });
  38759. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38760. if (_this._customMeshSet) {
  38761. return;
  38762. }
  38763. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38764. var material = isHovered ? hoverMaterial : coloredMaterial;
  38765. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38766. m.material = material;
  38767. if (m.color) {
  38768. m.color = material.emissiveColor;
  38769. }
  38770. });
  38771. });
  38772. return _this;
  38773. }
  38774. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  38775. if (this.dragBehavior) {
  38776. this.dragBehavior.enabled = value ? true : false;
  38777. }
  38778. };
  38779. /**
  38780. * Disposes of the gizmo
  38781. */
  38782. PlaneRotationGizmo.prototype.dispose = function () {
  38783. this.onSnapObservable.clear();
  38784. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38785. this.dragBehavior.detach();
  38786. _super.prototype.dispose.call(this);
  38787. };
  38788. return PlaneRotationGizmo;
  38789. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38790. /***/ }),
  38791. /***/ "./Gizmos/positionGizmo.ts":
  38792. /*!*********************************!*\
  38793. !*** ./Gizmos/positionGizmo.ts ***!
  38794. \*********************************/
  38795. /*! exports provided: PositionGizmo */
  38796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38797. "use strict";
  38798. __webpack_require__.r(__webpack_exports__);
  38799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  38800. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38801. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38802. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38803. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38804. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38805. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38806. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38807. /**
  38808. * Gizmo that enables dragging a mesh along 3 axis
  38809. */
  38810. var PositionGizmo = /** @class */ (function (_super) {
  38811. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  38812. /**
  38813. * Creates a PositionGizmo
  38814. * @param gizmoLayer The utility layer the gizmo will be added to
  38815. */
  38816. function PositionGizmo(gizmoLayer) {
  38817. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38818. var _this = _super.call(this, gizmoLayer) || this;
  38819. /** Fires an event when any of it's sub gizmos are dragged */
  38820. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38821. /** Fires an event when any of it's sub gizmos are released from dragging */
  38822. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38823. _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);
  38824. _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);
  38825. _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);
  38826. // Relay drag events
  38827. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38828. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38829. _this.onDragStartObservable.notifyObservers({});
  38830. });
  38831. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38832. _this.onDragEndObservable.notifyObservers({});
  38833. });
  38834. });
  38835. _this.attachedMesh = null;
  38836. return _this;
  38837. }
  38838. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  38839. set: function (mesh) {
  38840. if (this.xGizmo) {
  38841. this.xGizmo.attachedMesh = mesh;
  38842. this.yGizmo.attachedMesh = mesh;
  38843. this.zGizmo.attachedMesh = mesh;
  38844. }
  38845. },
  38846. enumerable: true,
  38847. configurable: true
  38848. });
  38849. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38850. get: function () {
  38851. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38852. },
  38853. set: function (value) {
  38854. if (this.xGizmo) {
  38855. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38856. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38857. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38858. }
  38859. },
  38860. enumerable: true,
  38861. configurable: true
  38862. });
  38863. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  38864. get: function () {
  38865. return this.xGizmo.snapDistance;
  38866. },
  38867. /**
  38868. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38869. */
  38870. set: function (value) {
  38871. if (this.xGizmo) {
  38872. this.xGizmo.snapDistance = value;
  38873. this.yGizmo.snapDistance = value;
  38874. this.zGizmo.snapDistance = value;
  38875. }
  38876. },
  38877. enumerable: true,
  38878. configurable: true
  38879. });
  38880. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  38881. get: function () {
  38882. return this.xGizmo.scaleRatio;
  38883. },
  38884. /**
  38885. * Ratio for the scale of the gizmo (Default: 1)
  38886. */
  38887. set: function (value) {
  38888. if (this.xGizmo) {
  38889. this.xGizmo.scaleRatio = value;
  38890. this.yGizmo.scaleRatio = value;
  38891. this.zGizmo.scaleRatio = value;
  38892. }
  38893. },
  38894. enumerable: true,
  38895. configurable: true
  38896. });
  38897. /**
  38898. * Disposes of the gizmo
  38899. */
  38900. PositionGizmo.prototype.dispose = function () {
  38901. this.xGizmo.dispose();
  38902. this.yGizmo.dispose();
  38903. this.zGizmo.dispose();
  38904. this.onDragStartObservable.clear();
  38905. this.onDragEndObservable.clear();
  38906. };
  38907. /**
  38908. * CustomMeshes are not supported by this gizmo
  38909. * @param mesh The mesh to replace the default mesh of the gizmo
  38910. */
  38911. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  38912. _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)");
  38913. };
  38914. return PositionGizmo;
  38915. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38916. /***/ }),
  38917. /***/ "./Gizmos/rotationGizmo.ts":
  38918. /*!*********************************!*\
  38919. !*** ./Gizmos/rotationGizmo.ts ***!
  38920. \*********************************/
  38921. /*! exports provided: RotationGizmo */
  38922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38923. "use strict";
  38924. __webpack_require__.r(__webpack_exports__);
  38925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  38926. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38927. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38928. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38929. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38930. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38931. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38932. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38933. /**
  38934. * Gizmo that enables rotating a mesh along 3 axis
  38935. */
  38936. var RotationGizmo = /** @class */ (function (_super) {
  38937. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  38938. /**
  38939. * Creates a RotationGizmo
  38940. * @param gizmoLayer The utility layer the gizmo will be added to
  38941. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38942. */
  38943. function RotationGizmo(gizmoLayer, tessellation) {
  38944. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38945. if (tessellation === void 0) { tessellation = 32; }
  38946. var _this = _super.call(this, gizmoLayer) || this;
  38947. /** Fires an event when any of it's sub gizmos are dragged */
  38948. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38949. /** Fires an event when any of it's sub gizmos are released from dragging */
  38950. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38951. _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);
  38952. _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);
  38953. _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);
  38954. // Relay drag events
  38955. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38956. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38957. _this.onDragStartObservable.notifyObservers({});
  38958. });
  38959. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38960. _this.onDragEndObservable.notifyObservers({});
  38961. });
  38962. });
  38963. _this.attachedMesh = null;
  38964. return _this;
  38965. }
  38966. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  38967. set: function (mesh) {
  38968. if (this.xGizmo) {
  38969. this.xGizmo.attachedMesh = mesh;
  38970. this.yGizmo.attachedMesh = mesh;
  38971. this.zGizmo.attachedMesh = mesh;
  38972. }
  38973. },
  38974. enumerable: true,
  38975. configurable: true
  38976. });
  38977. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38978. get: function () {
  38979. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38980. },
  38981. set: function (value) {
  38982. if (this.xGizmo) {
  38983. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38984. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38985. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38986. }
  38987. },
  38988. enumerable: true,
  38989. configurable: true
  38990. });
  38991. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  38992. get: function () {
  38993. return this.xGizmo.snapDistance;
  38994. },
  38995. /**
  38996. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38997. */
  38998. set: function (value) {
  38999. if (this.xGizmo) {
  39000. this.xGizmo.snapDistance = value;
  39001. this.yGizmo.snapDistance = value;
  39002. this.zGizmo.snapDistance = value;
  39003. }
  39004. },
  39005. enumerable: true,
  39006. configurable: true
  39007. });
  39008. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  39009. get: function () {
  39010. return this.xGizmo.scaleRatio;
  39011. },
  39012. /**
  39013. * Ratio for the scale of the gizmo (Default: 1)
  39014. */
  39015. set: function (value) {
  39016. if (this.xGizmo) {
  39017. this.xGizmo.scaleRatio = value;
  39018. this.yGizmo.scaleRatio = value;
  39019. this.zGizmo.scaleRatio = value;
  39020. }
  39021. },
  39022. enumerable: true,
  39023. configurable: true
  39024. });
  39025. /**
  39026. * Disposes of the gizmo
  39027. */
  39028. RotationGizmo.prototype.dispose = function () {
  39029. this.xGizmo.dispose();
  39030. this.yGizmo.dispose();
  39031. this.zGizmo.dispose();
  39032. this.onDragStartObservable.clear();
  39033. this.onDragEndObservable.clear();
  39034. };
  39035. /**
  39036. * CustomMeshes are not supported by this gizmo
  39037. * @param mesh The mesh to replace the default mesh of the gizmo
  39038. */
  39039. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  39040. _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)");
  39041. };
  39042. return RotationGizmo;
  39043. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39044. /***/ }),
  39045. /***/ "./Gizmos/scaleGizmo.ts":
  39046. /*!******************************!*\
  39047. !*** ./Gizmos/scaleGizmo.ts ***!
  39048. \******************************/
  39049. /*! exports provided: ScaleGizmo */
  39050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39051. "use strict";
  39052. __webpack_require__.r(__webpack_exports__);
  39053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  39054. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39055. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39056. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39058. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  39059. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39060. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39061. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39062. /**
  39063. * Gizmo that enables scaling a mesh along 3 axis
  39064. */
  39065. var ScaleGizmo = /** @class */ (function (_super) {
  39066. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  39067. /**
  39068. * Creates a ScaleGizmo
  39069. * @param gizmoLayer The utility layer the gizmo will be added to
  39070. */
  39071. function ScaleGizmo(gizmoLayer) {
  39072. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39073. var _this = _super.call(this, gizmoLayer) || this;
  39074. /** Fires an event when any of it's sub gizmos are dragged */
  39075. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39076. /** Fires an event when any of it's sub gizmos are released from dragging */
  39077. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39078. _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);
  39079. _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);
  39080. _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);
  39081. // Create uniform scale gizmo
  39082. _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);
  39083. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  39084. _this.uniformScaleGizmo.uniformScaling = true;
  39085. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39086. uniformScalingMesh.scaling.scaleInPlace(0.02);
  39087. uniformScalingMesh.visibility = 0;
  39088. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39089. octahedron.scaling.scaleInPlace(0.007);
  39090. uniformScalingMesh.addChild(octahedron);
  39091. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  39092. // Relay drag events
  39093. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  39094. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39095. _this.onDragStartObservable.notifyObservers({});
  39096. });
  39097. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39098. _this.onDragEndObservable.notifyObservers({});
  39099. });
  39100. });
  39101. _this.attachedMesh = null;
  39102. return _this;
  39103. }
  39104. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  39105. set: function (mesh) {
  39106. if (this.xGizmo) {
  39107. this.xGizmo.attachedMesh = mesh;
  39108. this.yGizmo.attachedMesh = mesh;
  39109. this.zGizmo.attachedMesh = mesh;
  39110. this.uniformScaleGizmo.attachedMesh = mesh;
  39111. }
  39112. },
  39113. enumerable: true,
  39114. configurable: true
  39115. });
  39116. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39117. get: function () {
  39118. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39119. },
  39120. set: function (value) {
  39121. if (!value) {
  39122. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39123. }
  39124. if (this.xGizmo) {
  39125. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39126. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39127. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39128. }
  39129. },
  39130. enumerable: true,
  39131. configurable: true
  39132. });
  39133. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39134. get: function () {
  39135. return this.xGizmo.snapDistance;
  39136. },
  39137. /**
  39138. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39139. */
  39140. set: function (value) {
  39141. if (this.xGizmo) {
  39142. this.xGizmo.snapDistance = value;
  39143. this.yGizmo.snapDistance = value;
  39144. this.zGizmo.snapDistance = value;
  39145. this.uniformScaleGizmo.snapDistance = value;
  39146. }
  39147. },
  39148. enumerable: true,
  39149. configurable: true
  39150. });
  39151. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39152. get: function () {
  39153. return this.xGizmo.scaleRatio;
  39154. },
  39155. /**
  39156. * Ratio for the scale of the gizmo (Default: 1)
  39157. */
  39158. set: function (value) {
  39159. if (this.xGizmo) {
  39160. this.xGizmo.scaleRatio = value;
  39161. this.yGizmo.scaleRatio = value;
  39162. this.zGizmo.scaleRatio = value;
  39163. this.uniformScaleGizmo.scaleRatio = value;
  39164. }
  39165. },
  39166. enumerable: true,
  39167. configurable: true
  39168. });
  39169. /**
  39170. * Disposes of the gizmo
  39171. */
  39172. ScaleGizmo.prototype.dispose = function () {
  39173. this.xGizmo.dispose();
  39174. this.yGizmo.dispose();
  39175. this.zGizmo.dispose();
  39176. this.uniformScaleGizmo.dispose();
  39177. this.onDragStartObservable.clear();
  39178. this.onDragEndObservable.clear();
  39179. };
  39180. return ScaleGizmo;
  39181. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39182. /***/ }),
  39183. /***/ "./Helpers/environmentHelper.ts":
  39184. /*!**************************************!*\
  39185. !*** ./Helpers/environmentHelper.ts ***!
  39186. \**************************************/
  39187. /*! exports provided: EnvironmentHelper */
  39188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39189. "use strict";
  39190. __webpack_require__.r(__webpack_exports__);
  39191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39192. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39193. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39194. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39195. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39196. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39197. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39198. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39199. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39200. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39201. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39202. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39203. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39204. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39205. /**
  39206. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39207. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39208. * It also helps with the default setup of your imageProcessing configuration.
  39209. */
  39210. var EnvironmentHelper = /** @class */ (function () {
  39211. /**
  39212. * constructor
  39213. * @param options Defines the options we want to customize the helper
  39214. * @param scene The scene to add the material to
  39215. */
  39216. function EnvironmentHelper(options, scene) {
  39217. var _this = this;
  39218. this._errorHandler = function (message, exception) {
  39219. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39220. };
  39221. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39222. this._scene = scene;
  39223. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39224. this._setupBackground();
  39225. this._setupImageProcessing();
  39226. }
  39227. /**
  39228. * Creates the default options for the helper.
  39229. */
  39230. EnvironmentHelper._getDefaultOptions = function () {
  39231. return {
  39232. createGround: true,
  39233. groundSize: 15,
  39234. groundTexture: this._groundTextureCDNUrl,
  39235. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39236. groundOpacity: 0.9,
  39237. enableGroundShadow: true,
  39238. groundShadowLevel: 0.5,
  39239. enableGroundMirror: false,
  39240. groundMirrorSizeRatio: 0.3,
  39241. groundMirrorBlurKernel: 64,
  39242. groundMirrorAmount: 1,
  39243. groundMirrorFresnelWeight: 1,
  39244. groundMirrorFallOffDistance: 0,
  39245. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39246. groundYBias: 0.00001,
  39247. createSkybox: true,
  39248. skyboxSize: 20,
  39249. skyboxTexture: this._skyboxTextureCDNUrl,
  39250. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39251. backgroundYRotation: 0,
  39252. sizeAuto: true,
  39253. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39254. setupImageProcessing: true,
  39255. environmentTexture: this._environmentTextureCDNUrl,
  39256. cameraExposure: 0.8,
  39257. cameraContrast: 1.2,
  39258. toneMappingEnabled: true,
  39259. };
  39260. };
  39261. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39262. /**
  39263. * Gets the root mesh created by the helper.
  39264. */
  39265. get: function () {
  39266. return this._rootMesh;
  39267. },
  39268. enumerable: true,
  39269. configurable: true
  39270. });
  39271. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  39272. /**
  39273. * Gets the skybox created by the helper.
  39274. */
  39275. get: function () {
  39276. return this._skybox;
  39277. },
  39278. enumerable: true,
  39279. configurable: true
  39280. });
  39281. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  39282. /**
  39283. * Gets the skybox texture created by the helper.
  39284. */
  39285. get: function () {
  39286. return this._skyboxTexture;
  39287. },
  39288. enumerable: true,
  39289. configurable: true
  39290. });
  39291. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39292. /**
  39293. * Gets the skybox material created by the helper.
  39294. */
  39295. get: function () {
  39296. return this._skyboxMaterial;
  39297. },
  39298. enumerable: true,
  39299. configurable: true
  39300. });
  39301. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39302. /**
  39303. * Gets the ground mesh created by the helper.
  39304. */
  39305. get: function () {
  39306. return this._ground;
  39307. },
  39308. enumerable: true,
  39309. configurable: true
  39310. });
  39311. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39312. /**
  39313. * Gets the ground texture created by the helper.
  39314. */
  39315. get: function () {
  39316. return this._groundTexture;
  39317. },
  39318. enumerable: true,
  39319. configurable: true
  39320. });
  39321. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39322. /**
  39323. * Gets the ground mirror created by the helper.
  39324. */
  39325. get: function () {
  39326. return this._groundMirror;
  39327. },
  39328. enumerable: true,
  39329. configurable: true
  39330. });
  39331. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39332. /**
  39333. * Gets the ground mirror render list to helps pushing the meshes
  39334. * you wish in the ground reflection.
  39335. */
  39336. get: function () {
  39337. if (this._groundMirror) {
  39338. return this._groundMirror.renderList;
  39339. }
  39340. return null;
  39341. },
  39342. enumerable: true,
  39343. configurable: true
  39344. });
  39345. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39346. /**
  39347. * Gets the ground material created by the helper.
  39348. */
  39349. get: function () {
  39350. return this._groundMaterial;
  39351. },
  39352. enumerable: true,
  39353. configurable: true
  39354. });
  39355. /**
  39356. * Updates the background according to the new options
  39357. * @param options
  39358. */
  39359. EnvironmentHelper.prototype.updateOptions = function (options) {
  39360. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39361. if (this._ground && !newOptions.createGround) {
  39362. this._ground.dispose();
  39363. this._ground = null;
  39364. }
  39365. if (this._groundMaterial && !newOptions.createGround) {
  39366. this._groundMaterial.dispose();
  39367. this._groundMaterial = null;
  39368. }
  39369. if (this._groundTexture) {
  39370. if (this._options.groundTexture != newOptions.groundTexture) {
  39371. this._groundTexture.dispose();
  39372. this._groundTexture = null;
  39373. }
  39374. }
  39375. if (this._skybox && !newOptions.createSkybox) {
  39376. this._skybox.dispose();
  39377. this._skybox = null;
  39378. }
  39379. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39380. this._skyboxMaterial.dispose();
  39381. this._skyboxMaterial = null;
  39382. }
  39383. if (this._skyboxTexture) {
  39384. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39385. this._skyboxTexture.dispose();
  39386. this._skyboxTexture = null;
  39387. }
  39388. }
  39389. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39390. this._groundMirror.dispose();
  39391. this._groundMirror = null;
  39392. }
  39393. if (this._scene.environmentTexture) {
  39394. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39395. this._scene.environmentTexture.dispose();
  39396. }
  39397. }
  39398. this._options = newOptions;
  39399. this._setupBackground();
  39400. this._setupImageProcessing();
  39401. };
  39402. /**
  39403. * Sets the primary color of all the available elements.
  39404. * @param color the main color to affect to the ground and the background
  39405. */
  39406. EnvironmentHelper.prototype.setMainColor = function (color) {
  39407. if (this.groundMaterial) {
  39408. this.groundMaterial.primaryColor = color;
  39409. }
  39410. if (this.skyboxMaterial) {
  39411. this.skyboxMaterial.primaryColor = color;
  39412. }
  39413. if (this.groundMirror) {
  39414. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  39415. }
  39416. };
  39417. /**
  39418. * Setup the image processing according to the specified options.
  39419. */
  39420. EnvironmentHelper.prototype._setupImageProcessing = function () {
  39421. if (this._options.setupImageProcessing) {
  39422. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  39423. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  39424. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  39425. this._setupEnvironmentTexture();
  39426. }
  39427. };
  39428. /**
  39429. * Setup the environment texture according to the specified options.
  39430. */
  39431. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  39432. if (this._scene.environmentTexture) {
  39433. return;
  39434. }
  39435. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39436. this._scene.environmentTexture = this._options.environmentTexture;
  39437. return;
  39438. }
  39439. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  39440. this._scene.environmentTexture = environmentTexture;
  39441. };
  39442. /**
  39443. * Setup the background according to the specified options.
  39444. */
  39445. EnvironmentHelper.prototype._setupBackground = function () {
  39446. if (!this._rootMesh) {
  39447. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  39448. }
  39449. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  39450. var sceneSize = this._getSceneSize();
  39451. if (this._options.createGround) {
  39452. this._setupGround(sceneSize);
  39453. this._setupGroundMaterial();
  39454. this._setupGroundDiffuseTexture();
  39455. if (this._options.enableGroundMirror) {
  39456. this._setupGroundMirrorTexture(sceneSize);
  39457. }
  39458. this._setupMirrorInGroundMaterial();
  39459. }
  39460. if (this._options.createSkybox) {
  39461. this._setupSkybox(sceneSize);
  39462. this._setupSkyboxMaterial();
  39463. this._setupSkyboxReflectionTexture();
  39464. }
  39465. this._rootMesh.position.x = sceneSize.rootPosition.x;
  39466. this._rootMesh.position.z = sceneSize.rootPosition.z;
  39467. this._rootMesh.position.y = sceneSize.rootPosition.y;
  39468. };
  39469. /**
  39470. * Get the scene sizes according to the setup.
  39471. */
  39472. EnvironmentHelper.prototype._getSceneSize = function () {
  39473. var _this = this;
  39474. var groundSize = this._options.groundSize;
  39475. var skyboxSize = this._options.skyboxSize;
  39476. var rootPosition = this._options.rootPosition;
  39477. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  39478. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39479. }
  39480. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  39481. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  39482. });
  39483. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  39484. if (this._options.sizeAuto) {
  39485. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  39486. this._scene.activeCamera.upperRadiusLimit) {
  39487. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  39488. skyboxSize = groundSize;
  39489. }
  39490. var sceneDiagonalLenght = sceneDiagonal.length();
  39491. if (sceneDiagonalLenght > groundSize) {
  39492. groundSize = sceneDiagonalLenght * 2;
  39493. skyboxSize = groundSize;
  39494. }
  39495. // 10 % bigger.
  39496. groundSize *= 1.1;
  39497. skyboxSize *= 1.5;
  39498. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  39499. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  39500. }
  39501. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39502. };
  39503. /**
  39504. * Setup the ground according to the specified options.
  39505. */
  39506. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  39507. var _this = this;
  39508. if (!this._ground || this._ground.isDisposed()) {
  39509. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  39510. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  39511. this._ground.parent = this._rootMesh;
  39512. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  39513. }
  39514. this._ground.receiveShadows = this._options.enableGroundShadow;
  39515. };
  39516. /**
  39517. * Setup the ground material according to the specified options.
  39518. */
  39519. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  39520. if (!this._groundMaterial) {
  39521. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  39522. }
  39523. this._groundMaterial.alpha = this._options.groundOpacity;
  39524. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  39525. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  39526. this._groundMaterial.primaryColor = this._options.groundColor;
  39527. this._groundMaterial.useRGBColor = false;
  39528. this._groundMaterial.enableNoise = true;
  39529. if (this._ground) {
  39530. this._ground.material = this._groundMaterial;
  39531. }
  39532. };
  39533. /**
  39534. * Setup the ground diffuse texture according to the specified options.
  39535. */
  39536. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  39537. if (!this._groundMaterial) {
  39538. return;
  39539. }
  39540. if (this._groundTexture) {
  39541. return;
  39542. }
  39543. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39544. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  39545. return;
  39546. }
  39547. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39548. diffuseTexture.gammaSpace = false;
  39549. diffuseTexture.hasAlpha = true;
  39550. this._groundMaterial.diffuseTexture = diffuseTexture;
  39551. };
  39552. /**
  39553. * Setup the ground mirror texture according to the specified options.
  39554. */
  39555. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  39556. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  39557. if (!this._groundMirror) {
  39558. 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);
  39559. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  39560. this._groundMirror.anisotropicFilteringLevel = 1;
  39561. this._groundMirror.wrapU = wrapping;
  39562. this._groundMirror.wrapV = wrapping;
  39563. this._groundMirror.gammaSpace = false;
  39564. if (this._groundMirror.renderList) {
  39565. for (var i = 0; i < this._scene.meshes.length; i++) {
  39566. var mesh = this._scene.meshes[i];
  39567. if (mesh !== this._ground &&
  39568. mesh !== this._skybox &&
  39569. mesh !== this._rootMesh) {
  39570. this._groundMirror.renderList.push(mesh);
  39571. }
  39572. }
  39573. }
  39574. }
  39575. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  39576. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  39577. };
  39578. /**
  39579. * Setup the ground to receive the mirror texture.
  39580. */
  39581. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  39582. if (this._groundMaterial) {
  39583. this._groundMaterial.reflectionTexture = this._groundMirror;
  39584. this._groundMaterial.reflectionFresnel = true;
  39585. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  39586. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  39587. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  39588. }
  39589. };
  39590. /**
  39591. * Setup the skybox according to the specified options.
  39592. */
  39593. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  39594. var _this = this;
  39595. if (!this._skybox || this._skybox.isDisposed()) {
  39596. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  39597. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  39598. }
  39599. this._skybox.parent = this._rootMesh;
  39600. };
  39601. /**
  39602. * Setup the skybox material according to the specified options.
  39603. */
  39604. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  39605. if (!this._skybox) {
  39606. return;
  39607. }
  39608. if (!this._skyboxMaterial) {
  39609. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  39610. }
  39611. this._skyboxMaterial.useRGBColor = false;
  39612. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  39613. this._skyboxMaterial.enableNoise = true;
  39614. this._skybox.material = this._skyboxMaterial;
  39615. };
  39616. /**
  39617. * Setup the skybox reflection texture according to the specified options.
  39618. */
  39619. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  39620. if (!this._skyboxMaterial) {
  39621. return;
  39622. }
  39623. if (this._skyboxTexture) {
  39624. return;
  39625. }
  39626. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39627. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  39628. return;
  39629. }
  39630. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39631. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  39632. this._skyboxTexture.gammaSpace = false;
  39633. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  39634. };
  39635. /**
  39636. * Dispose all the elements created by the Helper.
  39637. */
  39638. EnvironmentHelper.prototype.dispose = function () {
  39639. if (this._groundMaterial) {
  39640. this._groundMaterial.dispose(true, true);
  39641. }
  39642. if (this._skyboxMaterial) {
  39643. this._skyboxMaterial.dispose(true, true);
  39644. }
  39645. this._rootMesh.dispose(false);
  39646. };
  39647. /**
  39648. * Default ground texture URL.
  39649. */
  39650. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  39651. /**
  39652. * Default skybox texture URL.
  39653. */
  39654. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  39655. /**
  39656. * Default environment texture URL.
  39657. */
  39658. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  39659. return EnvironmentHelper;
  39660. }());
  39661. /***/ }),
  39662. /***/ "./Helpers/index.ts":
  39663. /*!**************************!*\
  39664. !*** ./Helpers/index.ts ***!
  39665. \**************************/
  39666. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  39667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39668. "use strict";
  39669. __webpack_require__.r(__webpack_exports__);
  39670. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  39672. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  39673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  39674. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  39675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  39676. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  39677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  39678. /***/ }),
  39679. /***/ "./Helpers/photoDome.ts":
  39680. /*!******************************!*\
  39681. !*** ./Helpers/photoDome.ts ***!
  39682. \******************************/
  39683. /*! exports provided: PhotoDome */
  39684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39685. "use strict";
  39686. __webpack_require__.r(__webpack_exports__);
  39687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  39688. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39689. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39690. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39691. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39692. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39693. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39694. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39695. /**
  39696. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  39697. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  39698. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  39699. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39700. */
  39701. var PhotoDome = /** @class */ (function (_super) {
  39702. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  39703. /**
  39704. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  39705. * @param name Element's name, child elements will append suffixes for their own names.
  39706. * @param urlsOfPhoto defines the url of the photo to display
  39707. * @param options defines an object containing optional or exposed sub element properties
  39708. * @param onError defines a callback called when an error occured while loading the texture
  39709. */
  39710. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  39711. if (onError === void 0) { onError = null; }
  39712. var _this = _super.call(this, name, scene) || this;
  39713. _this._useDirectMapping = false;
  39714. /**
  39715. * Observable raised when an error occured while loading the 360 image
  39716. */
  39717. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39718. // set defaults and manage values
  39719. name = name || "photoDome";
  39720. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39721. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39722. if (options.useDirectMapping === undefined) {
  39723. _this._useDirectMapping = true;
  39724. }
  39725. else {
  39726. _this._useDirectMapping = options.useDirectMapping;
  39727. }
  39728. _this._setReady(false);
  39729. // create
  39730. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39731. _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);
  39732. // configure material
  39733. material.opacityFresnel = false;
  39734. material.useEquirectangularFOV = true;
  39735. material.fovMultiplier = 1.0;
  39736. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  39737. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  39738. if (onError) {
  39739. onError(message, exception);
  39740. }
  39741. });
  39742. _this.photoTexture.onLoadObservable.addOnce(function () {
  39743. _this._setReady(true);
  39744. });
  39745. // configure mesh
  39746. _this._mesh.material = material;
  39747. _this._mesh.parent = _this;
  39748. return _this;
  39749. }
  39750. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  39751. /**
  39752. * Gets or sets the texture being displayed on the sphere
  39753. */
  39754. get: function () {
  39755. return this._photoTexture;
  39756. },
  39757. set: function (value) {
  39758. if (this._photoTexture === value) {
  39759. return;
  39760. }
  39761. this._photoTexture = value;
  39762. if (this._useDirectMapping) {
  39763. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39764. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39765. this._material.diffuseTexture = this._photoTexture;
  39766. }
  39767. else {
  39768. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39769. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39770. this._material.reflectionTexture = this._photoTexture;
  39771. }
  39772. },
  39773. enumerable: true,
  39774. configurable: true
  39775. });
  39776. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  39777. /**
  39778. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39779. * Also see the options.resolution property.
  39780. */
  39781. get: function () {
  39782. return this._material.fovMultiplier;
  39783. },
  39784. set: function (value) {
  39785. this._material.fovMultiplier = value;
  39786. },
  39787. enumerable: true,
  39788. configurable: true
  39789. });
  39790. /**
  39791. * Releases resources associated with this node.
  39792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39794. */
  39795. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39796. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39797. this._photoTexture.dispose();
  39798. this._mesh.dispose();
  39799. this._material.dispose();
  39800. this.onLoadErrorObservable.clear();
  39801. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39802. };
  39803. return PhotoDome;
  39804. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  39805. /***/ }),
  39806. /***/ "./Helpers/sceneHelpers.ts":
  39807. /*!*********************************!*\
  39808. !*** ./Helpers/sceneHelpers.ts ***!
  39809. \*********************************/
  39810. /*! exports provided: _forceSceneHelpersToBundle */
  39811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39812. "use strict";
  39813. __webpack_require__.r(__webpack_exports__);
  39814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  39815. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39816. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  39817. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39818. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39819. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39820. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39821. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  39822. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39823. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39824. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  39825. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39826. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  39827. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  39828. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  39829. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  39830. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  39831. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39832. /** @hidden */
  39833. var _forceSceneHelpersToBundle = true;
  39834. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  39835. if (replace === void 0) { replace = false; }
  39836. // Dispose existing light in replace mode.
  39837. if (replace) {
  39838. if (this.lights) {
  39839. for (var i = 0; i < this.lights.length; i++) {
  39840. this.lights[i].dispose();
  39841. }
  39842. }
  39843. }
  39844. // Light
  39845. if (this.lights.length === 0) {
  39846. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  39847. }
  39848. };
  39849. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  39850. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39851. if (replace === void 0) { replace = false; }
  39852. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39853. // Dispose existing camera in replace mode.
  39854. if (replace) {
  39855. if (this.activeCamera) {
  39856. this.activeCamera.dispose();
  39857. this.activeCamera = null;
  39858. }
  39859. }
  39860. // Camera
  39861. if (!this.activeCamera) {
  39862. var worldExtends = this.getWorldExtends();
  39863. var worldSize = worldExtends.max.subtract(worldExtends.min);
  39864. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  39865. var camera;
  39866. var radius = worldSize.length() * 1.5;
  39867. // empty scene scenario!
  39868. if (!isFinite(radius)) {
  39869. radius = 1;
  39870. worldCenter.copyFromFloats(0, 0, 0);
  39871. }
  39872. if (createArcRotateCamera) {
  39873. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  39874. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  39875. arcRotateCamera.wheelPrecision = 100 / radius;
  39876. camera = arcRotateCamera;
  39877. }
  39878. else {
  39879. 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);
  39880. freeCamera.setTarget(worldCenter);
  39881. camera = freeCamera;
  39882. }
  39883. camera.minZ = radius * 0.01;
  39884. camera.maxZ = radius * 1000;
  39885. camera.speed = radius * 0.2;
  39886. this.activeCamera = camera;
  39887. var canvas = this.getEngine().getRenderingCanvas();
  39888. if (attachCameraControls && canvas) {
  39889. camera.attachControl(canvas);
  39890. }
  39891. }
  39892. };
  39893. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  39894. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39895. if (replace === void 0) { replace = false; }
  39896. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39897. this.createDefaultLight(replace);
  39898. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  39899. };
  39900. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  39901. if (pbr === void 0) { pbr = false; }
  39902. if (scale === void 0) { scale = 1000; }
  39903. if (blur === void 0) { blur = 0; }
  39904. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  39905. if (!environmentTexture) {
  39906. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  39907. return null;
  39908. }
  39909. if (setGlobalEnvTexture) {
  39910. if (environmentTexture) {
  39911. this.environmentTexture = environmentTexture;
  39912. }
  39913. }
  39914. // Skybox
  39915. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  39916. if (pbr) {
  39917. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  39918. hdrSkyboxMaterial.backFaceCulling = false;
  39919. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  39920. if (hdrSkyboxMaterial.reflectionTexture) {
  39921. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39922. }
  39923. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  39924. hdrSkyboxMaterial.disableLighting = true;
  39925. hdrSkyboxMaterial.twoSidedLighting = true;
  39926. hdrSkybox.infiniteDistance = true;
  39927. hdrSkybox.material = hdrSkyboxMaterial;
  39928. }
  39929. else {
  39930. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  39931. skyboxMaterial.backFaceCulling = false;
  39932. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  39933. if (skyboxMaterial.reflectionTexture) {
  39934. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39935. }
  39936. skyboxMaterial.disableLighting = true;
  39937. hdrSkybox.infiniteDistance = true;
  39938. hdrSkybox.material = skyboxMaterial;
  39939. }
  39940. hdrSkybox.isPickable = false;
  39941. return hdrSkybox;
  39942. };
  39943. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  39944. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  39945. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  39946. }
  39947. return null;
  39948. };
  39949. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  39950. if (webVROptions === void 0) { webVROptions = {}; }
  39951. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  39952. };
  39953. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  39954. var _this = this;
  39955. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  39956. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  39957. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  39958. .then(function (ui) {
  39959. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  39960. return helper;
  39961. });
  39962. });
  39963. };
  39964. /***/ }),
  39965. /***/ "./Helpers/videoDome.ts":
  39966. /*!******************************!*\
  39967. !*** ./Helpers/videoDome.ts ***!
  39968. \******************************/
  39969. /*! exports provided: VideoDome */
  39970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39971. "use strict";
  39972. __webpack_require__.r(__webpack_exports__);
  39973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  39974. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39975. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39976. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39977. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39978. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  39979. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39980. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39981. /**
  39982. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  39983. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  39984. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  39985. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39986. */
  39987. var VideoDome = /** @class */ (function (_super) {
  39988. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  39989. /**
  39990. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  39991. * @param name Element's name, child elements will append suffixes for their own names.
  39992. * @param urlsOrVideo defines the url(s) or the video element to use
  39993. * @param options An object containing optional or exposed sub element properties
  39994. */
  39995. function VideoDome(name, urlsOrVideo, options, scene) {
  39996. var _this = _super.call(this, name, scene) || this;
  39997. _this._useDirectMapping = false;
  39998. // set defaults and manage values
  39999. name = name || "videoDome";
  40000. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40001. options.clickToPlay = Boolean(options.clickToPlay);
  40002. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  40003. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  40004. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40005. if (options.useDirectMapping === undefined) {
  40006. _this._useDirectMapping = true;
  40007. }
  40008. else {
  40009. _this._useDirectMapping = options.useDirectMapping;
  40010. }
  40011. _this._setReady(false);
  40012. // create
  40013. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  40014. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40015. 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);
  40016. _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);
  40017. texture.onLoadObservable.addOnce(function () {
  40018. _this._setReady(true);
  40019. });
  40020. // configure material
  40021. material.useEquirectangularFOV = true;
  40022. material.fovMultiplier = 1.0;
  40023. material.opacityFresnel = false;
  40024. if (_this._useDirectMapping) {
  40025. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40026. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40027. material.diffuseTexture = texture;
  40028. }
  40029. else {
  40030. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40031. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40032. material.reflectionTexture = texture;
  40033. }
  40034. // configure mesh
  40035. _this._mesh.material = material;
  40036. _this._mesh.parent = _this;
  40037. // optional configuration
  40038. if (options.clickToPlay) {
  40039. scene.onPointerUp = function () {
  40040. _this._videoTexture.video.play();
  40041. };
  40042. }
  40043. return _this;
  40044. }
  40045. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  40046. /**
  40047. * Gets the video texture being displayed on the sphere
  40048. */
  40049. get: function () {
  40050. return this._videoTexture;
  40051. },
  40052. enumerable: true,
  40053. configurable: true
  40054. });
  40055. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  40056. /**
  40057. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40058. * Also see the options.resolution property.
  40059. */
  40060. get: function () {
  40061. return this._material.fovMultiplier;
  40062. },
  40063. set: function (value) {
  40064. this._material.fovMultiplier = value;
  40065. },
  40066. enumerable: true,
  40067. configurable: true
  40068. });
  40069. /**
  40070. * Releases resources associated with this node.
  40071. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40072. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40073. */
  40074. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40075. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40076. this._videoTexture.dispose();
  40077. this._mesh.dispose();
  40078. this._material.dispose();
  40079. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40080. };
  40081. return VideoDome;
  40082. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  40083. /***/ }),
  40084. /***/ "./Instrumentation/engineInstrumentation.ts":
  40085. /*!**************************************************!*\
  40086. !*** ./Instrumentation/engineInstrumentation.ts ***!
  40087. \**************************************************/
  40088. /*! exports provided: EngineInstrumentation */
  40089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40090. "use strict";
  40091. __webpack_require__.r(__webpack_exports__);
  40092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  40093. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40094. /**
  40095. * This class can be used to get instrumentation data from a Babylon engine
  40096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40097. */
  40098. var EngineInstrumentation = /** @class */ (function () {
  40099. /**
  40100. * Instantiates a new engine instrumentation.
  40101. * This class can be used to get instrumentation data from a Babylon engine
  40102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40103. * @param engine Defines the engine to instrument
  40104. */
  40105. function EngineInstrumentation(
  40106. /**
  40107. * Define the instrumented engine.
  40108. */
  40109. engine) {
  40110. this.engine = engine;
  40111. this._captureGPUFrameTime = false;
  40112. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40113. this._captureShaderCompilationTime = false;
  40114. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40115. // Observers
  40116. this._onBeginFrameObserver = null;
  40117. this._onEndFrameObserver = null;
  40118. this._onBeforeShaderCompilationObserver = null;
  40119. this._onAfterShaderCompilationObserver = null;
  40120. }
  40121. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40122. // Properties
  40123. /**
  40124. * Gets the perf counter used for GPU frame time
  40125. */
  40126. get: function () {
  40127. return this._gpuFrameTime;
  40128. },
  40129. enumerable: true,
  40130. configurable: true
  40131. });
  40132. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40133. /**
  40134. * Gets the GPU frame time capture status
  40135. */
  40136. get: function () {
  40137. return this._captureGPUFrameTime;
  40138. },
  40139. /**
  40140. * Enable or disable the GPU frame time capture
  40141. */
  40142. set: function (value) {
  40143. var _this = this;
  40144. if (value === this._captureGPUFrameTime) {
  40145. return;
  40146. }
  40147. this._captureGPUFrameTime = value;
  40148. if (value) {
  40149. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40150. if (!_this._gpuFrameTimeToken) {
  40151. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40152. }
  40153. });
  40154. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40155. if (!_this._gpuFrameTimeToken) {
  40156. return;
  40157. }
  40158. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40159. if (time > -1) {
  40160. _this._gpuFrameTimeToken = null;
  40161. _this._gpuFrameTime.fetchNewFrame();
  40162. _this._gpuFrameTime.addCount(time, true);
  40163. }
  40164. });
  40165. }
  40166. else {
  40167. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40168. this._onBeginFrameObserver = null;
  40169. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40170. this._onEndFrameObserver = null;
  40171. }
  40172. },
  40173. enumerable: true,
  40174. configurable: true
  40175. });
  40176. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40177. /**
  40178. * Gets the perf counter used for shader compilation time
  40179. */
  40180. get: function () {
  40181. return this._shaderCompilationTime;
  40182. },
  40183. enumerable: true,
  40184. configurable: true
  40185. });
  40186. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  40187. /**
  40188. * Gets the shader compilation time capture status
  40189. */
  40190. get: function () {
  40191. return this._captureShaderCompilationTime;
  40192. },
  40193. /**
  40194. * Enable or disable the shader compilation time capture
  40195. */
  40196. set: function (value) {
  40197. var _this = this;
  40198. if (value === this._captureShaderCompilationTime) {
  40199. return;
  40200. }
  40201. this._captureShaderCompilationTime = value;
  40202. if (value) {
  40203. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  40204. _this._shaderCompilationTime.fetchNewFrame();
  40205. _this._shaderCompilationTime.beginMonitoring();
  40206. });
  40207. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  40208. _this._shaderCompilationTime.endMonitoring();
  40209. });
  40210. }
  40211. else {
  40212. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40213. this._onBeforeShaderCompilationObserver = null;
  40214. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40215. this._onAfterShaderCompilationObserver = null;
  40216. }
  40217. },
  40218. enumerable: true,
  40219. configurable: true
  40220. });
  40221. /**
  40222. * Dispose and release associated resources.
  40223. */
  40224. EngineInstrumentation.prototype.dispose = function () {
  40225. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40226. this._onBeginFrameObserver = null;
  40227. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40228. this._onEndFrameObserver = null;
  40229. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40230. this._onBeforeShaderCompilationObserver = null;
  40231. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40232. this._onAfterShaderCompilationObserver = null;
  40233. this.engine = null;
  40234. };
  40235. return EngineInstrumentation;
  40236. }());
  40237. /***/ }),
  40238. /***/ "./Instrumentation/index.ts":
  40239. /*!**********************************!*\
  40240. !*** ./Instrumentation/index.ts ***!
  40241. \**********************************/
  40242. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  40243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40244. "use strict";
  40245. __webpack_require__.r(__webpack_exports__);
  40246. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  40247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  40248. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  40249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  40250. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  40251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  40252. /***/ }),
  40253. /***/ "./Instrumentation/sceneInstrumentation.ts":
  40254. /*!*************************************************!*\
  40255. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  40256. \*************************************************/
  40257. /*! exports provided: SceneInstrumentation */
  40258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40259. "use strict";
  40260. __webpack_require__.r(__webpack_exports__);
  40261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  40262. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40263. /**
  40264. * This class can be used to get instrumentation data from a Babylon engine
  40265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40266. */
  40267. var SceneInstrumentation = /** @class */ (function () {
  40268. /**
  40269. * Instantiates a new scene instrumentation.
  40270. * This class can be used to get instrumentation data from a Babylon engine
  40271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40272. * @param scene Defines the scene to instrument
  40273. */
  40274. function SceneInstrumentation(
  40275. /**
  40276. * Defines the scene to instrument
  40277. */
  40278. scene) {
  40279. var _this = this;
  40280. this.scene = scene;
  40281. this._captureActiveMeshesEvaluationTime = false;
  40282. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40283. this._captureRenderTargetsRenderTime = false;
  40284. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40285. this._captureFrameTime = false;
  40286. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40287. this._captureRenderTime = false;
  40288. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40289. this._captureInterFrameTime = false;
  40290. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40291. this._captureParticlesRenderTime = false;
  40292. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40293. this._captureSpritesRenderTime = false;
  40294. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40295. this._capturePhysicsTime = false;
  40296. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40297. this._captureAnimationsTime = false;
  40298. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40299. this._captureCameraRenderTime = false;
  40300. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40301. // Observers
  40302. this._onBeforeActiveMeshesEvaluationObserver = null;
  40303. this._onAfterActiveMeshesEvaluationObserver = null;
  40304. this._onBeforeRenderTargetsRenderObserver = null;
  40305. this._onAfterRenderTargetsRenderObserver = null;
  40306. this._onAfterRenderObserver = null;
  40307. this._onBeforeDrawPhaseObserver = null;
  40308. this._onAfterDrawPhaseObserver = null;
  40309. this._onBeforeAnimationsObserver = null;
  40310. this._onBeforeParticlesRenderingObserver = null;
  40311. this._onAfterParticlesRenderingObserver = null;
  40312. this._onBeforeSpritesRenderingObserver = null;
  40313. this._onAfterSpritesRenderingObserver = null;
  40314. this._onBeforePhysicsObserver = null;
  40315. this._onAfterPhysicsObserver = null;
  40316. this._onAfterAnimationsObserver = null;
  40317. this._onBeforeCameraRenderObserver = null;
  40318. this._onAfterCameraRenderObserver = null;
  40319. // Before render
  40320. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  40321. if (_this._captureActiveMeshesEvaluationTime) {
  40322. _this._activeMeshesEvaluationTime.fetchNewFrame();
  40323. }
  40324. if (_this._captureRenderTargetsRenderTime) {
  40325. _this._renderTargetsRenderTime.fetchNewFrame();
  40326. }
  40327. if (_this._captureFrameTime) {
  40328. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  40329. _this._frameTime.beginMonitoring();
  40330. }
  40331. if (_this._captureInterFrameTime) {
  40332. _this._interFrameTime.endMonitoring();
  40333. }
  40334. if (_this._captureParticlesRenderTime) {
  40335. _this._particlesRenderTime.fetchNewFrame();
  40336. }
  40337. if (_this._captureSpritesRenderTime) {
  40338. _this._spritesRenderTime.fetchNewFrame();
  40339. }
  40340. if (_this._captureAnimationsTime) {
  40341. _this._animationsTime.beginMonitoring();
  40342. }
  40343. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  40344. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  40345. });
  40346. // After render
  40347. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  40348. if (_this._captureFrameTime) {
  40349. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  40350. _this._frameTime.endMonitoring();
  40351. }
  40352. if (_this._captureRenderTime) {
  40353. _this._renderTime.endMonitoring(false);
  40354. }
  40355. if (_this._captureInterFrameTime) {
  40356. _this._interFrameTime.beginMonitoring();
  40357. }
  40358. });
  40359. }
  40360. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  40361. // Properties
  40362. /**
  40363. * Gets the perf counter used for active meshes evaluation time
  40364. */
  40365. get: function () {
  40366. return this._activeMeshesEvaluationTime;
  40367. },
  40368. enumerable: true,
  40369. configurable: true
  40370. });
  40371. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  40372. /**
  40373. * Gets the active meshes evaluation time capture status
  40374. */
  40375. get: function () {
  40376. return this._captureActiveMeshesEvaluationTime;
  40377. },
  40378. /**
  40379. * Enable or disable the active meshes evaluation time capture
  40380. */
  40381. set: function (value) {
  40382. var _this = this;
  40383. if (value === this._captureActiveMeshesEvaluationTime) {
  40384. return;
  40385. }
  40386. this._captureActiveMeshesEvaluationTime = value;
  40387. if (value) {
  40388. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  40389. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  40390. _this._activeMeshesEvaluationTime.beginMonitoring();
  40391. });
  40392. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  40393. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  40394. _this._activeMeshesEvaluationTime.endMonitoring();
  40395. });
  40396. }
  40397. else {
  40398. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40399. this._onBeforeActiveMeshesEvaluationObserver = null;
  40400. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40401. this._onAfterActiveMeshesEvaluationObserver = null;
  40402. }
  40403. },
  40404. enumerable: true,
  40405. configurable: true
  40406. });
  40407. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  40408. /**
  40409. * Gets the perf counter used for render targets render time
  40410. */
  40411. get: function () {
  40412. return this._renderTargetsRenderTime;
  40413. },
  40414. enumerable: true,
  40415. configurable: true
  40416. });
  40417. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  40418. /**
  40419. * Gets the render targets render time capture status
  40420. */
  40421. get: function () {
  40422. return this._captureRenderTargetsRenderTime;
  40423. },
  40424. /**
  40425. * Enable or disable the render targets render time capture
  40426. */
  40427. set: function (value) {
  40428. var _this = this;
  40429. if (value === this._captureRenderTargetsRenderTime) {
  40430. return;
  40431. }
  40432. this._captureRenderTargetsRenderTime = value;
  40433. if (value) {
  40434. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  40435. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  40436. _this._renderTargetsRenderTime.beginMonitoring();
  40437. });
  40438. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  40439. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  40440. _this._renderTargetsRenderTime.endMonitoring(false);
  40441. });
  40442. }
  40443. else {
  40444. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40445. this._onBeforeRenderTargetsRenderObserver = null;
  40446. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40447. this._onAfterRenderTargetsRenderObserver = null;
  40448. }
  40449. },
  40450. enumerable: true,
  40451. configurable: true
  40452. });
  40453. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  40454. /**
  40455. * Gets the perf counter used for particles render time
  40456. */
  40457. get: function () {
  40458. return this._particlesRenderTime;
  40459. },
  40460. enumerable: true,
  40461. configurable: true
  40462. });
  40463. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  40464. /**
  40465. * Gets the particles render time capture status
  40466. */
  40467. get: function () {
  40468. return this._captureParticlesRenderTime;
  40469. },
  40470. /**
  40471. * Enable or disable the particles render time capture
  40472. */
  40473. set: function (value) {
  40474. var _this = this;
  40475. if (value === this._captureParticlesRenderTime) {
  40476. return;
  40477. }
  40478. this._captureParticlesRenderTime = value;
  40479. if (value) {
  40480. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  40481. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  40482. _this._particlesRenderTime.beginMonitoring();
  40483. });
  40484. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  40485. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  40486. _this._particlesRenderTime.endMonitoring(false);
  40487. });
  40488. }
  40489. else {
  40490. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40491. this._onBeforeParticlesRenderingObserver = null;
  40492. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40493. this._onAfterParticlesRenderingObserver = null;
  40494. }
  40495. },
  40496. enumerable: true,
  40497. configurable: true
  40498. });
  40499. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  40500. /**
  40501. * Gets the perf counter used for sprites render time
  40502. */
  40503. get: function () {
  40504. return this._spritesRenderTime;
  40505. },
  40506. enumerable: true,
  40507. configurable: true
  40508. });
  40509. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  40510. /**
  40511. * Gets the sprites render time capture status
  40512. */
  40513. get: function () {
  40514. return this._captureSpritesRenderTime;
  40515. },
  40516. /**
  40517. * Enable or disable the sprites render time capture
  40518. */
  40519. set: function (value) {
  40520. var _this = this;
  40521. if (value === this._captureSpritesRenderTime) {
  40522. return;
  40523. }
  40524. this._captureSpritesRenderTime = value;
  40525. if (!this.scene.spriteManagers) {
  40526. return;
  40527. }
  40528. if (value) {
  40529. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  40530. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  40531. _this._spritesRenderTime.beginMonitoring();
  40532. });
  40533. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  40534. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  40535. _this._spritesRenderTime.endMonitoring(false);
  40536. });
  40537. }
  40538. else {
  40539. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40540. this._onBeforeSpritesRenderingObserver = null;
  40541. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40542. this._onAfterSpritesRenderingObserver = null;
  40543. }
  40544. },
  40545. enumerable: true,
  40546. configurable: true
  40547. });
  40548. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  40549. /**
  40550. * Gets the perf counter used for physics time
  40551. */
  40552. get: function () {
  40553. return this._physicsTime;
  40554. },
  40555. enumerable: true,
  40556. configurable: true
  40557. });
  40558. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  40559. /**
  40560. * Gets the physics time capture status
  40561. */
  40562. get: function () {
  40563. return this._capturePhysicsTime;
  40564. },
  40565. /**
  40566. * Enable or disable the physics time capture
  40567. */
  40568. set: function (value) {
  40569. var _this = this;
  40570. if (value === this._capturePhysicsTime) {
  40571. return;
  40572. }
  40573. if (!this.scene.onBeforePhysicsObservable) {
  40574. return;
  40575. }
  40576. this._capturePhysicsTime = value;
  40577. if (value) {
  40578. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  40579. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  40580. _this._physicsTime.beginMonitoring();
  40581. });
  40582. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  40583. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  40584. _this._physicsTime.endMonitoring();
  40585. });
  40586. }
  40587. else {
  40588. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40589. this._onBeforePhysicsObserver = null;
  40590. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40591. this._onAfterPhysicsObserver = null;
  40592. }
  40593. },
  40594. enumerable: true,
  40595. configurable: true
  40596. });
  40597. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  40598. /**
  40599. * Gets the perf counter used for animations time
  40600. */
  40601. get: function () {
  40602. return this._animationsTime;
  40603. },
  40604. enumerable: true,
  40605. configurable: true
  40606. });
  40607. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  40608. /**
  40609. * Gets the animations time capture status
  40610. */
  40611. get: function () {
  40612. return this._captureAnimationsTime;
  40613. },
  40614. /**
  40615. * Enable or disable the animations time capture
  40616. */
  40617. set: function (value) {
  40618. var _this = this;
  40619. if (value === this._captureAnimationsTime) {
  40620. return;
  40621. }
  40622. this._captureAnimationsTime = value;
  40623. if (value) {
  40624. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  40625. _this._animationsTime.endMonitoring();
  40626. });
  40627. }
  40628. else {
  40629. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40630. this._onAfterAnimationsObserver = null;
  40631. }
  40632. },
  40633. enumerable: true,
  40634. configurable: true
  40635. });
  40636. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  40637. /**
  40638. * Gets the perf counter used for frame time capture
  40639. */
  40640. get: function () {
  40641. return this._frameTime;
  40642. },
  40643. enumerable: true,
  40644. configurable: true
  40645. });
  40646. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  40647. /**
  40648. * Gets the frame time capture status
  40649. */
  40650. get: function () {
  40651. return this._captureFrameTime;
  40652. },
  40653. /**
  40654. * Enable or disable the frame time capture
  40655. */
  40656. set: function (value) {
  40657. this._captureFrameTime = value;
  40658. },
  40659. enumerable: true,
  40660. configurable: true
  40661. });
  40662. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  40663. /**
  40664. * Gets the perf counter used for inter-frames time capture
  40665. */
  40666. get: function () {
  40667. return this._interFrameTime;
  40668. },
  40669. enumerable: true,
  40670. configurable: true
  40671. });
  40672. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  40673. /**
  40674. * Gets the inter-frames time capture status
  40675. */
  40676. get: function () {
  40677. return this._captureInterFrameTime;
  40678. },
  40679. /**
  40680. * Enable or disable the inter-frames time capture
  40681. */
  40682. set: function (value) {
  40683. this._captureInterFrameTime = value;
  40684. },
  40685. enumerable: true,
  40686. configurable: true
  40687. });
  40688. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  40689. /**
  40690. * Gets the perf counter used for render time capture
  40691. */
  40692. get: function () {
  40693. return this._renderTime;
  40694. },
  40695. enumerable: true,
  40696. configurable: true
  40697. });
  40698. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  40699. /**
  40700. * Gets the render time capture status
  40701. */
  40702. get: function () {
  40703. return this._captureRenderTime;
  40704. },
  40705. /**
  40706. * Enable or disable the render time capture
  40707. */
  40708. set: function (value) {
  40709. var _this = this;
  40710. if (value === this._captureRenderTime) {
  40711. return;
  40712. }
  40713. this._captureRenderTime = value;
  40714. if (value) {
  40715. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  40716. _this._renderTime.beginMonitoring();
  40717. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  40718. });
  40719. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  40720. _this._renderTime.endMonitoring(false);
  40721. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  40722. });
  40723. }
  40724. else {
  40725. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40726. this._onBeforeDrawPhaseObserver = null;
  40727. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40728. this._onAfterDrawPhaseObserver = null;
  40729. }
  40730. },
  40731. enumerable: true,
  40732. configurable: true
  40733. });
  40734. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  40735. /**
  40736. * Gets the perf counter used for camera render time capture
  40737. */
  40738. get: function () {
  40739. return this._cameraRenderTime;
  40740. },
  40741. enumerable: true,
  40742. configurable: true
  40743. });
  40744. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  40745. /**
  40746. * Gets the camera render time capture status
  40747. */
  40748. get: function () {
  40749. return this._captureCameraRenderTime;
  40750. },
  40751. /**
  40752. * Enable or disable the camera render time capture
  40753. */
  40754. set: function (value) {
  40755. var _this = this;
  40756. if (value === this._captureCameraRenderTime) {
  40757. return;
  40758. }
  40759. this._captureCameraRenderTime = value;
  40760. if (value) {
  40761. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  40762. _this._cameraRenderTime.beginMonitoring();
  40763. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  40764. });
  40765. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  40766. _this._cameraRenderTime.endMonitoring(false);
  40767. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  40768. });
  40769. }
  40770. else {
  40771. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40772. this._onBeforeCameraRenderObserver = null;
  40773. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40774. this._onAfterCameraRenderObserver = null;
  40775. }
  40776. },
  40777. enumerable: true,
  40778. configurable: true
  40779. });
  40780. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  40781. /**
  40782. * Gets the perf counter used for draw calls
  40783. */
  40784. get: function () {
  40785. return this.scene.getEngine()._drawCalls;
  40786. },
  40787. enumerable: true,
  40788. configurable: true
  40789. });
  40790. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  40791. /**
  40792. * Gets the perf counter used for texture collisions
  40793. */
  40794. get: function () {
  40795. return this.scene.getEngine()._textureCollisions;
  40796. },
  40797. enumerable: true,
  40798. configurable: true
  40799. });
  40800. /**
  40801. * Dispose and release associated resources.
  40802. */
  40803. SceneInstrumentation.prototype.dispose = function () {
  40804. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  40805. this._onAfterRenderObserver = null;
  40806. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40807. this._onBeforeActiveMeshesEvaluationObserver = null;
  40808. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40809. this._onAfterActiveMeshesEvaluationObserver = null;
  40810. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40811. this._onBeforeRenderTargetsRenderObserver = null;
  40812. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40813. this._onAfterRenderTargetsRenderObserver = null;
  40814. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  40815. this._onBeforeAnimationsObserver = null;
  40816. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40817. this._onBeforeParticlesRenderingObserver = null;
  40818. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40819. this._onAfterParticlesRenderingObserver = null;
  40820. if (this._onBeforeSpritesRenderingObserver) {
  40821. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40822. this._onBeforeSpritesRenderingObserver = null;
  40823. }
  40824. if (this._onAfterSpritesRenderingObserver) {
  40825. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40826. this._onAfterSpritesRenderingObserver = null;
  40827. }
  40828. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40829. this._onBeforeDrawPhaseObserver = null;
  40830. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40831. this._onAfterDrawPhaseObserver = null;
  40832. if (this._onBeforePhysicsObserver) {
  40833. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40834. this._onBeforePhysicsObserver = null;
  40835. }
  40836. if (this._onAfterPhysicsObserver) {
  40837. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40838. this._onAfterPhysicsObserver = null;
  40839. }
  40840. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40841. this._onAfterAnimationsObserver = null;
  40842. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40843. this._onBeforeCameraRenderObserver = null;
  40844. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40845. this._onAfterCameraRenderObserver = null;
  40846. this.scene = null;
  40847. };
  40848. return SceneInstrumentation;
  40849. }());
  40850. /***/ }),
  40851. /***/ "./Instrumentation/timeToken.ts":
  40852. /*!**************************************!*\
  40853. !*** ./Instrumentation/timeToken.ts ***!
  40854. \**************************************/
  40855. /*! exports provided: _TimeToken */
  40856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40857. "use strict";
  40858. __webpack_require__.r(__webpack_exports__);
  40859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  40860. /**
  40861. * @hidden
  40862. **/
  40863. var _TimeToken = /** @class */ (function () {
  40864. function _TimeToken() {
  40865. this._timeElapsedQueryEnded = false;
  40866. }
  40867. return _TimeToken;
  40868. }());
  40869. /***/ }),
  40870. /***/ "./Layers/effectLayer.ts":
  40871. /*!*******************************!*\
  40872. !*** ./Layers/effectLayer.ts ***!
  40873. \*******************************/
  40874. /*! exports provided: EffectLayer */
  40875. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40876. "use strict";
  40877. __webpack_require__.r(__webpack_exports__);
  40878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  40879. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40880. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40881. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40882. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40883. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40884. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  40885. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40886. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40887. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40888. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40889. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  40890. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40891. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  40892. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  40893. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  40894. /**
  40895. * The effect layer Helps adding post process effect blended with the main pass.
  40896. *
  40897. * This can be for instance use to generate glow or higlight effects on the scene.
  40898. *
  40899. * The effect layer class can not be used directly and is intented to inherited from to be
  40900. * customized per effects.
  40901. */
  40902. var EffectLayer = /** @class */ (function () {
  40903. /**
  40904. * Instantiates a new effect Layer and references it in the scene.
  40905. * @param name The name of the layer
  40906. * @param scene The scene to use the layer in
  40907. */
  40908. function EffectLayer(
  40909. /** The Friendly of the effect in the scene */
  40910. name, scene) {
  40911. this._vertexBuffers = {};
  40912. this._maxSize = 0;
  40913. this._mainTextureDesiredSize = { width: 0, height: 0 };
  40914. this._shouldRender = true;
  40915. this._postProcesses = [];
  40916. this._textures = [];
  40917. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  40918. /**
  40919. * The clear color of the texture used to generate the glow map.
  40920. */
  40921. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  40922. /**
  40923. * Specifies wether the highlight layer is enabled or not.
  40924. */
  40925. this.isEnabled = true;
  40926. /**
  40927. * An event triggered when the effect layer has been disposed.
  40928. */
  40929. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40930. /**
  40931. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  40932. */
  40933. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40934. /**
  40935. * An event triggered when the generated texture is being merged in the scene.
  40936. */
  40937. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40938. /**
  40939. * An event triggered when the generated texture has been merged in the scene.
  40940. */
  40941. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40942. /**
  40943. * An event triggered when the efffect layer changes its size.
  40944. */
  40945. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40946. this.name = name;
  40947. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  40948. EffectLayer._SceneComponentInitialization(this._scene);
  40949. this._engine = this._scene.getEngine();
  40950. this._maxSize = this._engine.getCaps().maxTextureSize;
  40951. this._scene.effectLayers.push(this);
  40952. // Generate Buffers
  40953. this._generateIndexBuffer();
  40954. this._genrateVertexBuffer();
  40955. }
  40956. Object.defineProperty(EffectLayer.prototype, "camera", {
  40957. /**
  40958. * Gets the camera attached to the layer.
  40959. */
  40960. get: function () {
  40961. return this._effectLayerOptions.camera;
  40962. },
  40963. enumerable: true,
  40964. configurable: true
  40965. });
  40966. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  40967. /**
  40968. * Gets the rendering group id the layer should render in.
  40969. */
  40970. get: function () {
  40971. return this._effectLayerOptions.renderingGroupId;
  40972. },
  40973. enumerable: true,
  40974. configurable: true
  40975. });
  40976. /**
  40977. * Initializes the effect layer with the required options.
  40978. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  40979. */
  40980. EffectLayer.prototype._init = function (options) {
  40981. // Adapt options
  40982. 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);
  40983. this._setMainTextureSize();
  40984. this._createMainTexture();
  40985. this._createTextureAndPostProcesses();
  40986. this._mergeEffect = this._createMergeEffect();
  40987. };
  40988. /**
  40989. * Generates the index buffer of the full screen quad blending to the main canvas.
  40990. */
  40991. EffectLayer.prototype._generateIndexBuffer = function () {
  40992. // Indices
  40993. var indices = [];
  40994. indices.push(0);
  40995. indices.push(1);
  40996. indices.push(2);
  40997. indices.push(0);
  40998. indices.push(2);
  40999. indices.push(3);
  41000. this._indexBuffer = this._engine.createIndexBuffer(indices);
  41001. };
  41002. /**
  41003. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  41004. */
  41005. EffectLayer.prototype._genrateVertexBuffer = function () {
  41006. // VBO
  41007. var vertices = [];
  41008. vertices.push(1, 1);
  41009. vertices.push(-1, 1);
  41010. vertices.push(-1, -1);
  41011. vertices.push(1, -1);
  41012. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  41013. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  41014. };
  41015. /**
  41016. * Sets the main texture desired size which is the closest power of two
  41017. * of the engine canvas size.
  41018. */
  41019. EffectLayer.prototype._setMainTextureSize = function () {
  41020. if (this._effectLayerOptions.mainTextureFixedSize) {
  41021. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  41022. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  41023. }
  41024. else {
  41025. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  41026. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  41027. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  41028. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  41029. }
  41030. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  41031. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  41032. };
  41033. /**
  41034. * Creates the main texture for the effect layer.
  41035. */
  41036. EffectLayer.prototype._createMainTexture = function () {
  41037. var _this = this;
  41038. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  41039. width: this._mainTextureDesiredSize.width,
  41040. height: this._mainTextureDesiredSize.height
  41041. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  41042. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  41043. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41044. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41045. this._mainTexture.anisotropicFilteringLevel = 1;
  41046. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  41047. this._mainTexture.renderParticles = false;
  41048. this._mainTexture.renderList = null;
  41049. this._mainTexture.ignoreCameraViewport = true;
  41050. // Custom render function
  41051. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  41052. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  41053. var index;
  41054. var engine = _this._scene.getEngine();
  41055. if (depthOnlySubMeshes.length) {
  41056. engine.setColorWrite(false);
  41057. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  41058. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  41059. }
  41060. engine.setColorWrite(true);
  41061. }
  41062. for (index = 0; index < opaqueSubMeshes.length; index++) {
  41063. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  41064. }
  41065. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  41066. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  41067. }
  41068. for (index = 0; index < transparentSubMeshes.length; index++) {
  41069. _this._renderSubMesh(transparentSubMeshes.data[index]);
  41070. }
  41071. };
  41072. this._mainTexture.onClearObservable.add(function (engine) {
  41073. engine.clear(_this.neutralColor, true, true, true);
  41074. });
  41075. };
  41076. /**
  41077. * Adds specific effects defines.
  41078. * @param defines The defines to add specifics to.
  41079. */
  41080. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  41081. // Nothing to add by default.
  41082. };
  41083. /**
  41084. * Checks for the readiness of the element composing the layer.
  41085. * @param subMesh the mesh to check for
  41086. * @param useInstances specify wether or not to use instances to render the mesh
  41087. * @param emissiveTexture the associated emissive texture used to generate the glow
  41088. * @return true if ready otherwise, false
  41089. */
  41090. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  41091. var material = subMesh.getMaterial();
  41092. if (!material) {
  41093. return false;
  41094. }
  41095. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  41096. return false;
  41097. }
  41098. var defines = [];
  41099. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41100. var mesh = subMesh.getMesh();
  41101. var uv1 = false;
  41102. var uv2 = false;
  41103. // Diffuse
  41104. if (material) {
  41105. var needAlphaTest = material.needAlphaTesting();
  41106. var diffuseTexture = material.getAlphaTestTexture();
  41107. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41108. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41109. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41110. defines.push("#define DIFFUSE");
  41111. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41112. diffuseTexture.coordinatesIndex === 1) {
  41113. defines.push("#define DIFFUSEUV2");
  41114. uv2 = true;
  41115. }
  41116. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41117. defines.push("#define DIFFUSEUV1");
  41118. uv1 = true;
  41119. }
  41120. if (needAlphaTest) {
  41121. defines.push("#define ALPHATEST");
  41122. defines.push("#define ALPHATESTVALUE 0.4");
  41123. }
  41124. }
  41125. var opacityTexture = material.opacityTexture;
  41126. if (opacityTexture) {
  41127. defines.push("#define OPACITY");
  41128. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41129. opacityTexture.coordinatesIndex === 1) {
  41130. defines.push("#define OPACITYUV2");
  41131. uv2 = true;
  41132. }
  41133. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41134. defines.push("#define OPACITYUV1");
  41135. uv1 = true;
  41136. }
  41137. }
  41138. }
  41139. // Emissive
  41140. if (emissiveTexture) {
  41141. defines.push("#define EMISSIVE");
  41142. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41143. emissiveTexture.coordinatesIndex === 1) {
  41144. defines.push("#define EMISSIVEUV2");
  41145. uv2 = true;
  41146. }
  41147. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41148. defines.push("#define EMISSIVEUV1");
  41149. uv1 = true;
  41150. }
  41151. }
  41152. // Vertex
  41153. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41154. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41155. defines.push("#define VERTEXALPHA");
  41156. }
  41157. if (uv1) {
  41158. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41159. defines.push("#define UV1");
  41160. }
  41161. if (uv2) {
  41162. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41163. defines.push("#define UV2");
  41164. }
  41165. // Bones
  41166. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41167. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41168. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41169. if (mesh.numBoneInfluencers > 4) {
  41170. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41171. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41172. }
  41173. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41174. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41175. }
  41176. else {
  41177. defines.push("#define NUM_BONE_INFLUENCERS 0");
  41178. }
  41179. // Morph targets
  41180. var manager = mesh.morphTargetManager;
  41181. var morphInfluencers = 0;
  41182. if (manager) {
  41183. if (manager.numInfluencers > 0) {
  41184. defines.push("#define MORPHTARGETS");
  41185. morphInfluencers = manager.numInfluencers;
  41186. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  41187. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  41188. }
  41189. }
  41190. // Instances
  41191. if (useInstances) {
  41192. defines.push("#define INSTANCES");
  41193. attribs.push("world0");
  41194. attribs.push("world1");
  41195. attribs.push("world2");
  41196. attribs.push("world3");
  41197. }
  41198. this._addCustomEffectDefines(defines);
  41199. // Get correct effect
  41200. var join = defines.join("\n");
  41201. if (this._cachedDefines !== join) {
  41202. this._cachedDefines = join;
  41203. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  41204. "color", "morphTargetInfluences",
  41205. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  41206. }
  41207. return this._effectLayerMapGenerationEffect.isReady();
  41208. };
  41209. /**
  41210. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  41211. */
  41212. EffectLayer.prototype.render = function () {
  41213. var currentEffect = this._mergeEffect;
  41214. // Check
  41215. if (!currentEffect.isReady()) {
  41216. return;
  41217. }
  41218. for (var i = 0; i < this._postProcesses.length; i++) {
  41219. if (!this._postProcesses[i].isReady()) {
  41220. return;
  41221. }
  41222. }
  41223. var engine = this._scene.getEngine();
  41224. this.onBeforeComposeObservable.notifyObservers(this);
  41225. // Render
  41226. engine.enableEffect(currentEffect);
  41227. engine.setState(false);
  41228. // VBOs
  41229. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41230. // Cache
  41231. var previousAlphaMode = engine.getAlphaMode();
  41232. // Go Blend.
  41233. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  41234. // Blends the map on the main canvas.
  41235. this._internalRender(currentEffect);
  41236. // Restore Alpha
  41237. engine.setAlphaMode(previousAlphaMode);
  41238. this.onAfterComposeObservable.notifyObservers(this);
  41239. // Handle size changes.
  41240. var size = this._mainTexture.getSize();
  41241. this._setMainTextureSize();
  41242. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  41243. // Recreate RTT and post processes on size change.
  41244. this.onSizeChangedObservable.notifyObservers(this);
  41245. this._disposeTextureAndPostProcesses();
  41246. this._createMainTexture();
  41247. this._createTextureAndPostProcesses();
  41248. }
  41249. };
  41250. /**
  41251. * Determine if a given mesh will be used in the current effect.
  41252. * @param mesh mesh to test
  41253. * @returns true if the mesh will be used
  41254. */
  41255. EffectLayer.prototype.hasMesh = function (mesh) {
  41256. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  41257. return true;
  41258. }
  41259. return false;
  41260. };
  41261. /**
  41262. * Returns true if the layer contains information to display, otherwise false.
  41263. * @returns true if the glow layer should be rendered
  41264. */
  41265. EffectLayer.prototype.shouldRender = function () {
  41266. return this.isEnabled && this._shouldRender;
  41267. };
  41268. /**
  41269. * Returns true if the mesh should render, otherwise false.
  41270. * @param mesh The mesh to render
  41271. * @returns true if it should render otherwise false
  41272. */
  41273. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  41274. return true;
  41275. };
  41276. /**
  41277. * Returns true if the mesh can be rendered, otherwise false.
  41278. * @param mesh The mesh to render
  41279. * @param material The material used on the mesh
  41280. * @returns true if it can be rendered otherwise false
  41281. */
  41282. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  41283. return !material.needAlphaBlendingForMesh(mesh);
  41284. };
  41285. /**
  41286. * Returns true if the mesh should render, otherwise false.
  41287. * @param mesh The mesh to render
  41288. * @returns true if it should render otherwise false
  41289. */
  41290. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41291. return true;
  41292. };
  41293. /**
  41294. * Renders the submesh passed in parameter to the generation map.
  41295. */
  41296. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41297. var _this = this;
  41298. if (!this.shouldRender()) {
  41299. return;
  41300. }
  41301. var material = subMesh.getMaterial();
  41302. var mesh = subMesh.getRenderingMesh();
  41303. var scene = this._scene;
  41304. var engine = scene.getEngine();
  41305. if (!material) {
  41306. return;
  41307. }
  41308. // Do not block in blend mode.
  41309. if (!this._canRenderMesh(mesh, material)) {
  41310. return;
  41311. }
  41312. // Culling
  41313. engine.setState(material.backFaceCulling);
  41314. // Managing instances
  41315. var batch = mesh._getInstancesRenderList(subMesh._id);
  41316. if (batch.mustReturn) {
  41317. return;
  41318. }
  41319. // Early Exit per mesh
  41320. if (!this._shouldRenderMesh(mesh)) {
  41321. return;
  41322. }
  41323. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  41324. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  41325. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  41326. engine.enableEffect(this._effectLayerMapGenerationEffect);
  41327. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  41328. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  41329. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  41330. var needAlphaTest = material.needAlphaTesting();
  41331. var diffuseTexture = material.getAlphaTestTexture();
  41332. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41333. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41334. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41335. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  41336. var textureMatrix = diffuseTexture.getTextureMatrix();
  41337. if (textureMatrix) {
  41338. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  41339. }
  41340. }
  41341. var opacityTexture = material.opacityTexture;
  41342. if (opacityTexture) {
  41343. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  41344. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  41345. var textureMatrix = opacityTexture.getTextureMatrix();
  41346. if (textureMatrix) {
  41347. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  41348. }
  41349. }
  41350. // Glow emissive only
  41351. if (this._emissiveTextureAndColor.texture) {
  41352. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  41353. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  41354. }
  41355. // Bones
  41356. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  41357. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  41358. }
  41359. // Morph targets
  41360. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  41361. // Draw
  41362. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  41363. }
  41364. else {
  41365. // Need to reset refresh rate of the main map
  41366. this._mainTexture.resetRefreshCounter();
  41367. }
  41368. };
  41369. /**
  41370. * Rebuild the required buffers.
  41371. * @hidden Internal use only.
  41372. */
  41373. EffectLayer.prototype._rebuild = function () {
  41374. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41375. if (vb) {
  41376. vb._rebuild();
  41377. }
  41378. this._generateIndexBuffer();
  41379. };
  41380. /**
  41381. * Dispose only the render target textures and post process.
  41382. */
  41383. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  41384. this._mainTexture.dispose();
  41385. for (var i = 0; i < this._postProcesses.length; i++) {
  41386. if (this._postProcesses[i]) {
  41387. this._postProcesses[i].dispose();
  41388. }
  41389. }
  41390. this._postProcesses = [];
  41391. for (var i = 0; i < this._textures.length; i++) {
  41392. if (this._textures[i]) {
  41393. this._textures[i].dispose();
  41394. }
  41395. }
  41396. this._textures = [];
  41397. };
  41398. /**
  41399. * Dispose the highlight layer and free resources.
  41400. */
  41401. EffectLayer.prototype.dispose = function () {
  41402. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41403. if (vertexBuffer) {
  41404. vertexBuffer.dispose();
  41405. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  41406. }
  41407. if (this._indexBuffer) {
  41408. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41409. this._indexBuffer = null;
  41410. }
  41411. // Clean textures and post processes
  41412. this._disposeTextureAndPostProcesses();
  41413. // Remove from scene
  41414. var index = this._scene.effectLayers.indexOf(this, 0);
  41415. if (index > -1) {
  41416. this._scene.effectLayers.splice(index, 1);
  41417. }
  41418. // Callback
  41419. this.onDisposeObservable.notifyObservers(this);
  41420. this.onDisposeObservable.clear();
  41421. this.onBeforeRenderMainTextureObservable.clear();
  41422. this.onBeforeComposeObservable.clear();
  41423. this.onAfterComposeObservable.clear();
  41424. this.onSizeChangedObservable.clear();
  41425. };
  41426. /**
  41427. * Gets the class name of the effect layer
  41428. * @returns the string with the class name of the effect layer
  41429. */
  41430. EffectLayer.prototype.getClassName = function () {
  41431. return "EffectLayer";
  41432. };
  41433. /**
  41434. * Creates an effect layer from parsed effect layer data
  41435. * @param parsedEffectLayer defines effect layer data
  41436. * @param scene defines the current scene
  41437. * @param rootUrl defines the root URL containing the effect layer information
  41438. * @returns a parsed effect Layer
  41439. */
  41440. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  41441. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  41442. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  41443. };
  41444. /** @hidden */
  41445. EffectLayer._SceneComponentInitialization = function (_) {
  41446. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  41447. };
  41448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41450. ], EffectLayer.prototype, "name", void 0);
  41451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  41453. ], EffectLayer.prototype, "neutralColor", void 0);
  41454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41456. ], EffectLayer.prototype, "isEnabled", void 0);
  41457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  41459. ], EffectLayer.prototype, "camera", null);
  41460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41462. ], EffectLayer.prototype, "renderingGroupId", null);
  41463. return EffectLayer;
  41464. }());
  41465. /***/ }),
  41466. /***/ "./Layers/effectLayerSceneComponent.ts":
  41467. /*!*********************************************!*\
  41468. !*** ./Layers/effectLayerSceneComponent.ts ***!
  41469. \*********************************************/
  41470. /*! exports provided: EffectLayerSceneComponent */
  41471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41472. "use strict";
  41473. __webpack_require__.r(__webpack_exports__);
  41474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  41475. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  41476. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41477. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41478. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41479. // Adds the parser to the scene parsers.
  41480. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  41481. if (parsedData.effectLayers) {
  41482. if (!container.effectLayers) {
  41483. container.effectLayers = new Array();
  41484. }
  41485. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  41486. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  41487. container.effectLayers.push(effectLayer);
  41488. }
  41489. }
  41490. });
  41491. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  41492. var index = this.effectLayers.indexOf(toRemove);
  41493. if (index !== -1) {
  41494. this.effectLayers.splice(index, 1);
  41495. }
  41496. return index;
  41497. };
  41498. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  41499. this.effectLayers.push(newEffectLayer);
  41500. };
  41501. /**
  41502. * Defines the layer scene component responsible to manage any effect layers
  41503. * in a given scene.
  41504. */
  41505. var EffectLayerSceneComponent = /** @class */ (function () {
  41506. /**
  41507. * Creates a new instance of the component for the given scene
  41508. * @param scene Defines the scene to register the component in
  41509. */
  41510. function EffectLayerSceneComponent(scene) {
  41511. /**
  41512. * The component name helpfull to identify the component in the list of scene components.
  41513. */
  41514. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  41515. this._renderEffects = false;
  41516. this._needStencil = false;
  41517. this._previousStencilState = false;
  41518. this.scene = scene;
  41519. this._engine = scene.getEngine();
  41520. scene.effectLayers = new Array();
  41521. }
  41522. /**
  41523. * Registers the component in a given scene
  41524. */
  41525. EffectLayerSceneComponent.prototype.register = function () {
  41526. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  41527. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  41528. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  41529. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  41530. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  41531. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  41532. };
  41533. /**
  41534. * Rebuilds the elements related to this component in case of
  41535. * context lost for instance.
  41536. */
  41537. EffectLayerSceneComponent.prototype.rebuild = function () {
  41538. var layers = this.scene.effectLayers;
  41539. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  41540. var effectLayer = layers_1[_i];
  41541. effectLayer._rebuild();
  41542. }
  41543. };
  41544. /**
  41545. * Serializes the component data to the specified json object
  41546. * @param serializationObject The object to serialize to
  41547. */
  41548. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  41549. // Effect layers
  41550. serializationObject.effectLayers = [];
  41551. var layers = this.scene.effectLayers;
  41552. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  41553. var effectLayer = layers_2[_i];
  41554. if (effectLayer.serialize) {
  41555. serializationObject.effectLayers.push(effectLayer.serialize());
  41556. }
  41557. }
  41558. };
  41559. /**
  41560. * Adds all the element from the container to the scene
  41561. * @param container the container holding the elements
  41562. */
  41563. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  41564. var _this = this;
  41565. if (!container.effectLayers) {
  41566. return;
  41567. }
  41568. container.effectLayers.forEach(function (o) {
  41569. _this.scene.addEffectLayer(o);
  41570. });
  41571. };
  41572. /**
  41573. * Removes all the elements in the container from the scene
  41574. * @param container contains the elements to remove
  41575. */
  41576. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  41577. var _this = this;
  41578. if (!container.effectLayers) {
  41579. return;
  41580. }
  41581. container.effectLayers.forEach(function (o) {
  41582. _this.scene.removeEffectLayer(o);
  41583. });
  41584. };
  41585. /**
  41586. * Disposes the component and the associated ressources.
  41587. */
  41588. EffectLayerSceneComponent.prototype.dispose = function () {
  41589. var layers = this.scene.effectLayers;
  41590. while (layers.length) {
  41591. layers[0].dispose();
  41592. }
  41593. };
  41594. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  41595. var layers = this.scene.effectLayers;
  41596. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  41597. var layer = layers_3[_i];
  41598. if (!layer.hasMesh(mesh)) {
  41599. continue;
  41600. }
  41601. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  41602. var subMesh = _b[_a];
  41603. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  41604. return false;
  41605. }
  41606. }
  41607. }
  41608. return true;
  41609. };
  41610. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  41611. this._renderEffects = false;
  41612. this._needStencil = false;
  41613. var layers = this.scene.effectLayers;
  41614. if (layers && layers.length > 0) {
  41615. this._previousStencilState = this._engine.getStencilBuffer();
  41616. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  41617. var effectLayer = layers_4[_i];
  41618. if (effectLayer.shouldRender() &&
  41619. (!effectLayer.camera ||
  41620. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  41621. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  41622. this._renderEffects = true;
  41623. this._needStencil = this._needStencil || effectLayer.needStencil();
  41624. var renderTarget = effectLayer._mainTexture;
  41625. if (renderTarget._shouldRender()) {
  41626. this.scene.incrementRenderId();
  41627. renderTarget.render(false, false);
  41628. }
  41629. }
  41630. }
  41631. this.scene.incrementRenderId();
  41632. }
  41633. };
  41634. EffectLayerSceneComponent.prototype._setStencil = function () {
  41635. // Activate effect Layer stencil
  41636. if (this._needStencil) {
  41637. this._engine.setStencilBuffer(true);
  41638. }
  41639. };
  41640. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  41641. // Restore effect Layer stencil
  41642. if (this._needStencil) {
  41643. this._engine.setStencilBuffer(this._previousStencilState);
  41644. }
  41645. };
  41646. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  41647. if (this._renderEffects) {
  41648. this._engine.setDepthBuffer(false);
  41649. var layers = this.scene.effectLayers;
  41650. for (var i = 0; i < layers.length; i++) {
  41651. var effectLayer = layers[i];
  41652. if (effectLayer.renderingGroupId === renderingGroupId) {
  41653. if (effectLayer.shouldRender()) {
  41654. effectLayer.render();
  41655. }
  41656. }
  41657. }
  41658. this._engine.setDepthBuffer(true);
  41659. }
  41660. };
  41661. EffectLayerSceneComponent.prototype._drawCamera = function () {
  41662. if (this._renderEffects) {
  41663. this._draw(-1);
  41664. }
  41665. };
  41666. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  41667. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  41668. this._draw(index);
  41669. }
  41670. };
  41671. return EffectLayerSceneComponent;
  41672. }());
  41673. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  41674. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  41675. if (!component) {
  41676. component = new EffectLayerSceneComponent(scene);
  41677. scene._addComponent(component);
  41678. }
  41679. };
  41680. /***/ }),
  41681. /***/ "./Layers/glowLayer.ts":
  41682. /*!*****************************!*\
  41683. !*** ./Layers/glowLayer.ts ***!
  41684. \*****************************/
  41685. /*! exports provided: GlowLayer */
  41686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41687. "use strict";
  41688. __webpack_require__.r(__webpack_exports__);
  41689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  41690. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41691. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41692. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41693. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41694. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41695. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41696. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41697. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41698. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41699. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41700. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41701. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41702. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41703. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41704. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41705. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  41706. for (var index = 0; index < this.effectLayers.length; index++) {
  41707. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  41708. return this.effectLayers[index];
  41709. }
  41710. }
  41711. return null;
  41712. };
  41713. /**
  41714. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  41715. *
  41716. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41717. * glowy meshes to your scene.
  41718. *
  41719. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  41720. */
  41721. var GlowLayer = /** @class */ (function (_super) {
  41722. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  41723. /**
  41724. * Instantiates a new glow Layer and references it to the scene.
  41725. * @param name The name of the layer
  41726. * @param scene The scene to use the layer in
  41727. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  41728. */
  41729. function GlowLayer(name, scene, options) {
  41730. var _this = _super.call(this, name, scene) || this;
  41731. _this._intensity = 1.0;
  41732. _this._includedOnlyMeshes = [];
  41733. _this._excludedMeshes = [];
  41734. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  41735. // Adapt options
  41736. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  41737. // Initialize the layer
  41738. _this._init({
  41739. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  41740. camera: _this._options.camera,
  41741. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41742. mainTextureRatio: _this._options.mainTextureRatio,
  41743. renderingGroupId: _this._options.renderingGroupId
  41744. });
  41745. return _this;
  41746. }
  41747. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  41748. /**
  41749. * Gets the kernel size of the blur.
  41750. */
  41751. get: function () {
  41752. return this._horizontalBlurPostprocess1.kernel;
  41753. },
  41754. /**
  41755. * Sets the kernel size of the blur.
  41756. */
  41757. set: function (value) {
  41758. this._horizontalBlurPostprocess1.kernel = value;
  41759. this._verticalBlurPostprocess1.kernel = value;
  41760. this._horizontalBlurPostprocess2.kernel = value;
  41761. this._verticalBlurPostprocess2.kernel = value;
  41762. },
  41763. enumerable: true,
  41764. configurable: true
  41765. });
  41766. Object.defineProperty(GlowLayer.prototype, "intensity", {
  41767. /**
  41768. * Gets the glow intensity.
  41769. */
  41770. get: function () {
  41771. return this._intensity;
  41772. },
  41773. /**
  41774. * Sets the glow intensity.
  41775. */
  41776. set: function (value) {
  41777. this._intensity = value;
  41778. },
  41779. enumerable: true,
  41780. configurable: true
  41781. });
  41782. /**
  41783. * Get the effect name of the layer.
  41784. * @return The effect name
  41785. */
  41786. GlowLayer.prototype.getEffectName = function () {
  41787. return GlowLayer.EffectName;
  41788. };
  41789. /**
  41790. * Create the merge effect. This is the shader use to blit the information back
  41791. * to the main canvas at the end of the scene rendering.
  41792. */
  41793. GlowLayer.prototype._createMergeEffect = function () {
  41794. // Effect
  41795. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  41796. };
  41797. /**
  41798. * Creates the render target textures and post processes used in the glow layer.
  41799. */
  41800. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  41801. var _this = this;
  41802. var blurTextureWidth = this._mainTextureDesiredSize.width;
  41803. var blurTextureHeight = this._mainTextureDesiredSize.height;
  41804. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41805. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41806. var textureType = 0;
  41807. if (this._engine.getCaps().textureHalfFloatRender) {
  41808. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41809. }
  41810. else {
  41811. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41812. }
  41813. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  41814. width: blurTextureWidth,
  41815. height: blurTextureHeight
  41816. }, this._scene, false, true, textureType);
  41817. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41818. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41819. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41820. this._blurTexture1.renderParticles = false;
  41821. this._blurTexture1.ignoreCameraViewport = true;
  41822. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  41823. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  41824. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  41825. width: blurTextureWidth2,
  41826. height: blurTextureHeight2
  41827. }, this._scene, false, true, textureType);
  41828. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41829. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41830. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41831. this._blurTexture2.renderParticles = false;
  41832. this._blurTexture2.ignoreCameraViewport = true;
  41833. this._textures = [this._blurTexture1, this._blurTexture2];
  41834. 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, {
  41835. width: blurTextureWidth,
  41836. height: blurTextureHeight
  41837. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41838. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  41839. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  41840. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  41841. effect.setTexture("textureSampler", _this._mainTexture);
  41842. });
  41843. 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, {
  41844. width: blurTextureWidth,
  41845. height: blurTextureHeight
  41846. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41847. 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, {
  41848. width: blurTextureWidth2,
  41849. height: blurTextureHeight2
  41850. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41851. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  41852. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  41853. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  41854. effect.setTexture("textureSampler", _this._blurTexture1);
  41855. });
  41856. 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, {
  41857. width: blurTextureWidth2,
  41858. height: blurTextureHeight2
  41859. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41860. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41861. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  41862. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41863. this._mainTexture.samples = this._options.mainTextureSamples;
  41864. this._mainTexture.onAfterUnbindObservable.add(function () {
  41865. var internalTexture = _this._blurTexture1.getInternalTexture();
  41866. if (internalTexture) {
  41867. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  41868. internalTexture = _this._blurTexture2.getInternalTexture();
  41869. if (internalTexture) {
  41870. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  41871. }
  41872. }
  41873. });
  41874. // Prevent autoClear.
  41875. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41876. };
  41877. /**
  41878. * Checks for the readiness of the element composing the layer.
  41879. * @param subMesh the mesh to check for
  41880. * @param useInstances specify wether or not to use instances to render the mesh
  41881. * @param emissiveTexture the associated emissive texture used to generate the glow
  41882. * @return true if ready otherwise, false
  41883. */
  41884. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  41885. var material = subMesh.getMaterial();
  41886. var mesh = subMesh.getRenderingMesh();
  41887. if (!material || !mesh) {
  41888. return false;
  41889. }
  41890. var emissiveTexture = material.emissiveTexture;
  41891. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41892. };
  41893. /**
  41894. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41895. */
  41896. GlowLayer.prototype.needStencil = function () {
  41897. return false;
  41898. };
  41899. /**
  41900. * Returns true if the mesh can be rendered, otherwise false.
  41901. * @param mesh The mesh to render
  41902. * @param material The material used on the mesh
  41903. * @returns true if it can be rendered otherwise false
  41904. */
  41905. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  41906. return true;
  41907. };
  41908. /**
  41909. * Implementation specific of rendering the generating effect on the main canvas.
  41910. * @param effect The effect used to render through
  41911. */
  41912. GlowLayer.prototype._internalRender = function (effect) {
  41913. // Texture
  41914. effect.setTexture("textureSampler", this._blurTexture1);
  41915. effect.setTexture("textureSampler2", this._blurTexture2);
  41916. effect.setFloat("offset", this._intensity);
  41917. // Cache
  41918. var engine = this._engine;
  41919. var previousStencilBuffer = engine.getStencilBuffer();
  41920. // Draw order
  41921. engine.setStencilBuffer(false);
  41922. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  41923. // Draw order
  41924. engine.setStencilBuffer(previousStencilBuffer);
  41925. };
  41926. /**
  41927. * Sets the required values for both the emissive texture and and the main color.
  41928. */
  41929. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41930. var textureLevel = 1.0;
  41931. if (this.customEmissiveTextureSelector) {
  41932. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  41933. }
  41934. else {
  41935. if (material) {
  41936. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41937. if (this._emissiveTextureAndColor.texture) {
  41938. textureLevel = this._emissiveTextureAndColor.texture.level;
  41939. }
  41940. }
  41941. else {
  41942. this._emissiveTextureAndColor.texture = null;
  41943. }
  41944. }
  41945. if (this.customEmissiveColorSelector) {
  41946. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  41947. }
  41948. else {
  41949. if (material.emissiveColor) {
  41950. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  41951. }
  41952. else {
  41953. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41954. }
  41955. }
  41956. };
  41957. /**
  41958. * Returns true if the mesh should render, otherwise false.
  41959. * @param mesh The mesh to render
  41960. * @returns true if it should render otherwise false
  41961. */
  41962. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  41963. return this.hasMesh(mesh);
  41964. };
  41965. /**
  41966. * Adds specific effects defines.
  41967. * @param defines The defines to add specifics to.
  41968. */
  41969. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  41970. defines.push("#define GLOW");
  41971. };
  41972. /**
  41973. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  41974. * @param mesh The mesh to exclude from the glow layer
  41975. */
  41976. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  41977. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  41978. this._excludedMeshes.push(mesh.uniqueId);
  41979. }
  41980. };
  41981. /**
  41982. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  41983. * @param mesh The mesh to remove
  41984. */
  41985. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  41986. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  41987. if (index !== -1) {
  41988. this._excludedMeshes.splice(index, 1);
  41989. }
  41990. };
  41991. /**
  41992. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  41993. * @param mesh The mesh to include in the glow layer
  41994. */
  41995. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  41996. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  41997. this._includedOnlyMeshes.push(mesh.uniqueId);
  41998. }
  41999. };
  42000. /**
  42001. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  42002. * @param mesh The mesh to remove
  42003. */
  42004. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  42005. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  42006. if (index !== -1) {
  42007. this._includedOnlyMeshes.splice(index, 1);
  42008. }
  42009. };
  42010. /**
  42011. * Determine if a given mesh will be used in the glow layer
  42012. * @param mesh The mesh to test
  42013. * @returns true if the mesh will be highlighted by the current glow layer
  42014. */
  42015. GlowLayer.prototype.hasMesh = function (mesh) {
  42016. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42017. return false;
  42018. }
  42019. // Included Mesh
  42020. if (this._includedOnlyMeshes.length) {
  42021. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  42022. }
  42023. // Excluded Mesh
  42024. if (this._excludedMeshes.length) {
  42025. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  42026. }
  42027. return true;
  42028. };
  42029. /**
  42030. * Free any resources and references associated to a mesh.
  42031. * Internal use
  42032. * @param mesh The mesh to free.
  42033. * @hidden
  42034. */
  42035. GlowLayer.prototype._disposeMesh = function (mesh) {
  42036. this.removeIncludedOnlyMesh(mesh);
  42037. this.removeExcludedMesh(mesh);
  42038. };
  42039. /**
  42040. * Gets the class name of the effect layer
  42041. * @returns the string with the class name of the effect layer
  42042. */
  42043. GlowLayer.prototype.getClassName = function () {
  42044. return "GlowLayer";
  42045. };
  42046. /**
  42047. * Serializes this glow layer
  42048. * @returns a serialized glow layer object
  42049. */
  42050. GlowLayer.prototype.serialize = function () {
  42051. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42052. serializationObject.customType = "BABYLON.GlowLayer";
  42053. var index;
  42054. // Included meshes
  42055. serializationObject.includedMeshes = [];
  42056. if (this._includedOnlyMeshes.length) {
  42057. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  42058. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  42059. if (mesh) {
  42060. serializationObject.includedMeshes.push(mesh.id);
  42061. }
  42062. }
  42063. }
  42064. // Excluded meshes
  42065. serializationObject.excludedMeshes = [];
  42066. if (this._excludedMeshes.length) {
  42067. for (index = 0; index < this._excludedMeshes.length; index++) {
  42068. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  42069. if (mesh) {
  42070. serializationObject.excludedMeshes.push(mesh.id);
  42071. }
  42072. }
  42073. }
  42074. return serializationObject;
  42075. };
  42076. /**
  42077. * Creates a Glow Layer from parsed glow layer data
  42078. * @param parsedGlowLayer defines glow layer data
  42079. * @param scene defines the current scene
  42080. * @param rootUrl defines the root URL containing the glow layer information
  42081. * @returns a parsed Glow Layer
  42082. */
  42083. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  42084. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  42085. var index;
  42086. // Excluded meshes
  42087. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  42088. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  42089. if (mesh) {
  42090. gl.addExcludedMesh(mesh);
  42091. }
  42092. }
  42093. // Included meshes
  42094. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  42095. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  42096. if (mesh) {
  42097. gl.addIncludedOnlyMesh(mesh);
  42098. }
  42099. }
  42100. return gl;
  42101. };
  42102. /**
  42103. * Effect Name of the layer.
  42104. */
  42105. GlowLayer.EffectName = "GlowLayer";
  42106. /**
  42107. * The default blur kernel size used for the glow.
  42108. */
  42109. GlowLayer.DefaultBlurKernelSize = 32;
  42110. /**
  42111. * The default texture size ratio used for the glow.
  42112. */
  42113. GlowLayer.DefaultTextureRatio = 0.5;
  42114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42116. ], GlowLayer.prototype, "blurKernelSize", null);
  42117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42119. ], GlowLayer.prototype, "intensity", null);
  42120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42122. ], GlowLayer.prototype, "_options", void 0);
  42123. return GlowLayer;
  42124. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42125. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42126. /***/ }),
  42127. /***/ "./Layers/highlightLayer.ts":
  42128. /*!**********************************!*\
  42129. !*** ./Layers/highlightLayer.ts ***!
  42130. \**********************************/
  42131. /*! exports provided: HighlightLayer */
  42132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42133. "use strict";
  42134. __webpack_require__.r(__webpack_exports__);
  42135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42137. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42138. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42139. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42140. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42141. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42142. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42143. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42144. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42145. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42146. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42147. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42148. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42149. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42150. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42151. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42152. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42153. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42154. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42155. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42156. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42157. for (var index = 0; index < this.effectLayers.length; index++) {
  42158. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42159. return this.effectLayers[index];
  42160. }
  42161. }
  42162. return null;
  42163. };
  42164. /**
  42165. * Special Glow Blur post process only blurring the alpha channel
  42166. * It enforces keeping the most luminous color in the color channel.
  42167. */
  42168. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42169. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42170. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42171. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42172. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  42173. _this.direction = direction;
  42174. _this.kernel = kernel;
  42175. _this.onApplyObservable.add(function (effect) {
  42176. effect.setFloat2("screenSize", _this.width, _this.height);
  42177. effect.setVector2("direction", _this.direction);
  42178. effect.setFloat("blurWidth", _this.kernel);
  42179. });
  42180. return _this;
  42181. }
  42182. return GlowBlurPostProcess;
  42183. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  42184. /**
  42185. * The highlight layer Helps adding a glow effect around a mesh.
  42186. *
  42187. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42188. * glowy meshes to your scene.
  42189. *
  42190. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  42191. */
  42192. var HighlightLayer = /** @class */ (function (_super) {
  42193. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  42194. /**
  42195. * Instantiates a new highlight Layer and references it to the scene..
  42196. * @param name The name of the layer
  42197. * @param scene The scene to use the layer in
  42198. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  42199. */
  42200. function HighlightLayer(name, scene, options) {
  42201. var _this = _super.call(this, name, scene) || this;
  42202. _this.name = name;
  42203. /**
  42204. * Specifies whether or not the inner glow is ACTIVE in the layer.
  42205. */
  42206. _this.innerGlow = true;
  42207. /**
  42208. * Specifies whether or not the outer glow is ACTIVE in the layer.
  42209. */
  42210. _this.outerGlow = true;
  42211. /**
  42212. * An event triggered when the highlight layer is being blurred.
  42213. */
  42214. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42215. /**
  42216. * An event triggered when the highlight layer has been blurred.
  42217. */
  42218. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42219. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  42220. _this._meshes = {};
  42221. _this._excludedMeshes = {};
  42222. _this.neutralColor = HighlightLayer.NeutralColor;
  42223. // Warn on stencil
  42224. if (!_this._engine.isStencilEnable) {
  42225. _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 }");
  42226. }
  42227. // Adapt options
  42228. _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);
  42229. // Initialize the layer
  42230. _this._init({
  42231. alphaBlendingMode: _this._options.alphaBlendingMode,
  42232. camera: _this._options.camera,
  42233. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42234. mainTextureRatio: _this._options.mainTextureRatio,
  42235. renderingGroupId: _this._options.renderingGroupId
  42236. });
  42237. // Do not render as long as no meshes have been added
  42238. _this._shouldRender = false;
  42239. return _this;
  42240. }
  42241. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  42242. /**
  42243. * Gets the horizontal size of the blur.
  42244. */
  42245. get: function () {
  42246. return this._horizontalBlurPostprocess.kernel;
  42247. },
  42248. /**
  42249. * Specifies the horizontal size of the blur.
  42250. */
  42251. set: function (value) {
  42252. this._horizontalBlurPostprocess.kernel = value;
  42253. },
  42254. enumerable: true,
  42255. configurable: true
  42256. });
  42257. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  42258. /**
  42259. * Gets the vertical size of the blur.
  42260. */
  42261. get: function () {
  42262. return this._verticalBlurPostprocess.kernel;
  42263. },
  42264. /**
  42265. * Specifies the vertical size of the blur.
  42266. */
  42267. set: function (value) {
  42268. this._verticalBlurPostprocess.kernel = value;
  42269. },
  42270. enumerable: true,
  42271. configurable: true
  42272. });
  42273. /**
  42274. * Get the effect name of the layer.
  42275. * @return The effect name
  42276. */
  42277. HighlightLayer.prototype.getEffectName = function () {
  42278. return HighlightLayer.EffectName;
  42279. };
  42280. /**
  42281. * Create the merge effect. This is the shader use to blit the information back
  42282. * to the main canvas at the end of the scene rendering.
  42283. */
  42284. HighlightLayer.prototype._createMergeEffect = function () {
  42285. // Effect
  42286. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  42287. };
  42288. /**
  42289. * Creates the render target textures and post processes used in the highlight layer.
  42290. */
  42291. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42292. var _this = this;
  42293. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42294. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42295. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42296. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42297. var textureType = 0;
  42298. if (this._engine.getCaps().textureHalfFloatRender) {
  42299. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42300. }
  42301. else {
  42302. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42303. }
  42304. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42305. width: blurTextureWidth,
  42306. height: blurTextureHeight
  42307. }, this._scene, false, true, textureType);
  42308. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42309. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42310. this._blurTexture.anisotropicFilteringLevel = 16;
  42311. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  42312. this._blurTexture.renderParticles = false;
  42313. this._blurTexture.ignoreCameraViewport = true;
  42314. this._textures = [this._blurTexture];
  42315. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  42316. 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());
  42317. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  42318. effect.setTexture("textureSampler", _this._mainTexture);
  42319. });
  42320. 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());
  42321. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42322. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42323. });
  42324. 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());
  42325. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  42326. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42327. });
  42328. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42329. }
  42330. else {
  42331. 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, {
  42332. width: blurTextureWidth,
  42333. height: blurTextureHeight
  42334. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42335. this._horizontalBlurPostprocess.width = blurTextureWidth;
  42336. this._horizontalBlurPostprocess.height = blurTextureHeight;
  42337. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42338. effect.setTexture("textureSampler", _this._mainTexture);
  42339. });
  42340. 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, {
  42341. width: blurTextureWidth,
  42342. height: blurTextureHeight
  42343. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42344. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42345. }
  42346. this._mainTexture.onAfterUnbindObservable.add(function () {
  42347. _this.onBeforeBlurObservable.notifyObservers(_this);
  42348. var internalTexture = _this._blurTexture.getInternalTexture();
  42349. if (internalTexture) {
  42350. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  42351. }
  42352. _this.onAfterBlurObservable.notifyObservers(_this);
  42353. });
  42354. // Prevent autoClear.
  42355. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42356. };
  42357. /**
  42358. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42359. */
  42360. HighlightLayer.prototype.needStencil = function () {
  42361. return true;
  42362. };
  42363. /**
  42364. * Checks for the readiness of the element composing the layer.
  42365. * @param subMesh the mesh to check for
  42366. * @param useInstances specify wether or not to use instances to render the mesh
  42367. * @param emissiveTexture the associated emissive texture used to generate the glow
  42368. * @return true if ready otherwise, false
  42369. */
  42370. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  42371. var material = subMesh.getMaterial();
  42372. var mesh = subMesh.getRenderingMesh();
  42373. if (!material || !mesh || !this._meshes) {
  42374. return false;
  42375. }
  42376. var emissiveTexture = null;
  42377. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42378. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42379. emissiveTexture = material.emissiveTexture;
  42380. }
  42381. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42382. };
  42383. /**
  42384. * Implementation specific of rendering the generating effect on the main canvas.
  42385. * @param effect The effect used to render through
  42386. */
  42387. HighlightLayer.prototype._internalRender = function (effect) {
  42388. // Texture
  42389. effect.setTexture("textureSampler", this._blurTexture);
  42390. // Cache
  42391. var engine = this._engine;
  42392. var previousStencilBuffer = engine.getStencilBuffer();
  42393. var previousStencilFunction = engine.getStencilFunction();
  42394. var previousStencilMask = engine.getStencilMask();
  42395. var previousStencilOperationPass = engine.getStencilOperationPass();
  42396. var previousStencilOperationFail = engine.getStencilOperationFail();
  42397. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  42398. var previousStencilReference = engine.getStencilFunctionReference();
  42399. // Stencil operations
  42400. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  42401. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42402. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42403. // Draw order
  42404. engine.setStencilMask(0x00);
  42405. engine.setStencilBuffer(true);
  42406. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  42407. // 2 passes inner outer
  42408. if (this.outerGlow) {
  42409. effect.setFloat("offset", 0);
  42410. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  42411. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42412. }
  42413. if (this.innerGlow) {
  42414. effect.setFloat("offset", 1);
  42415. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  42416. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42417. }
  42418. // Restore Cache
  42419. engine.setStencilFunction(previousStencilFunction);
  42420. engine.setStencilMask(previousStencilMask);
  42421. engine.setStencilBuffer(previousStencilBuffer);
  42422. engine.setStencilOperationPass(previousStencilOperationPass);
  42423. engine.setStencilOperationFail(previousStencilOperationFail);
  42424. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  42425. engine.setStencilFunctionReference(previousStencilReference);
  42426. };
  42427. /**
  42428. * Returns true if the layer contains information to display, otherwise false.
  42429. */
  42430. HighlightLayer.prototype.shouldRender = function () {
  42431. if (_super.prototype.shouldRender.call(this)) {
  42432. return this._meshes ? true : false;
  42433. }
  42434. return false;
  42435. };
  42436. /**
  42437. * Returns true if the mesh should render, otherwise false.
  42438. * @param mesh The mesh to render
  42439. * @returns true if it should render otherwise false
  42440. */
  42441. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  42442. // Excluded Mesh
  42443. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  42444. return false;
  42445. }
  42446. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42447. return false;
  42448. }
  42449. return true;
  42450. };
  42451. /**
  42452. * Sets the required values for both the emissive texture and and the main color.
  42453. */
  42454. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42455. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42456. if (highlightLayerMesh) {
  42457. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  42458. }
  42459. else {
  42460. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42461. }
  42462. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42463. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42464. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  42465. }
  42466. else {
  42467. this._emissiveTextureAndColor.texture = null;
  42468. }
  42469. };
  42470. /**
  42471. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  42472. * @param mesh The mesh to exclude from the highlight layer
  42473. */
  42474. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  42475. if (!this._excludedMeshes) {
  42476. return;
  42477. }
  42478. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42479. if (!meshExcluded) {
  42480. this._excludedMeshes[mesh.uniqueId] = {
  42481. mesh: mesh,
  42482. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  42483. mesh.getEngine().setStencilBuffer(false);
  42484. }),
  42485. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  42486. mesh.getEngine().setStencilBuffer(true);
  42487. }),
  42488. };
  42489. }
  42490. };
  42491. /**
  42492. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  42493. * @param mesh The mesh to highlight
  42494. */
  42495. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  42496. if (!this._excludedMeshes) {
  42497. return;
  42498. }
  42499. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42500. if (meshExcluded) {
  42501. if (meshExcluded.beforeBind) {
  42502. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  42503. }
  42504. if (meshExcluded.afterRender) {
  42505. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  42506. }
  42507. }
  42508. this._excludedMeshes[mesh.uniqueId] = null;
  42509. };
  42510. /**
  42511. * Determine if a given mesh will be highlighted by the current HighlightLayer
  42512. * @param mesh mesh to test
  42513. * @returns true if the mesh will be highlighted by the current HighlightLayer
  42514. */
  42515. HighlightLayer.prototype.hasMesh = function (mesh) {
  42516. if (!this._meshes) {
  42517. return false;
  42518. }
  42519. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42520. return false;
  42521. }
  42522. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  42523. };
  42524. /**
  42525. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  42526. * @param mesh The mesh to highlight
  42527. * @param color The color of the highlight
  42528. * @param glowEmissiveOnly Extract the glow from the emissive texture
  42529. */
  42530. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  42531. var _this = this;
  42532. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  42533. if (!this._meshes) {
  42534. return;
  42535. }
  42536. var meshHighlight = this._meshes[mesh.uniqueId];
  42537. if (meshHighlight) {
  42538. meshHighlight.color = color;
  42539. }
  42540. else {
  42541. this._meshes[mesh.uniqueId] = {
  42542. mesh: mesh,
  42543. color: color,
  42544. // Lambda required for capture due to Observable this context
  42545. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  42546. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  42547. _this._defaultStencilReference(mesh);
  42548. }
  42549. else {
  42550. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  42551. }
  42552. }),
  42553. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  42554. glowEmissiveOnly: glowEmissiveOnly
  42555. };
  42556. mesh.onDisposeObservable.add(function () {
  42557. _this._disposeMesh(mesh);
  42558. });
  42559. }
  42560. this._shouldRender = true;
  42561. };
  42562. /**
  42563. * Remove a mesh from the highlight layer in order to make it stop glowing.
  42564. * @param mesh The mesh to highlight
  42565. */
  42566. HighlightLayer.prototype.removeMesh = function (mesh) {
  42567. if (!this._meshes) {
  42568. return;
  42569. }
  42570. var meshHighlight = this._meshes[mesh.uniqueId];
  42571. if (meshHighlight) {
  42572. if (meshHighlight.observerHighlight) {
  42573. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42574. }
  42575. if (meshHighlight.observerDefault) {
  42576. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42577. }
  42578. delete this._meshes[mesh.uniqueId];
  42579. }
  42580. this._shouldRender = false;
  42581. for (var meshHighlightToCheck in this._meshes) {
  42582. if (this._meshes[meshHighlightToCheck]) {
  42583. this._shouldRender = true;
  42584. break;
  42585. }
  42586. }
  42587. };
  42588. /**
  42589. * Force the stencil to the normal expected value for none glowing parts
  42590. */
  42591. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  42592. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  42593. };
  42594. /**
  42595. * Free any resources and references associated to a mesh.
  42596. * Internal use
  42597. * @param mesh The mesh to free.
  42598. * @hidden
  42599. */
  42600. HighlightLayer.prototype._disposeMesh = function (mesh) {
  42601. this.removeMesh(mesh);
  42602. this.removeExcludedMesh(mesh);
  42603. };
  42604. /**
  42605. * Dispose the highlight layer and free resources.
  42606. */
  42607. HighlightLayer.prototype.dispose = function () {
  42608. if (this._meshes) {
  42609. // Clean mesh references
  42610. for (var id in this._meshes) {
  42611. var meshHighlight = this._meshes[id];
  42612. if (meshHighlight && meshHighlight.mesh) {
  42613. if (meshHighlight.observerHighlight) {
  42614. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42615. }
  42616. if (meshHighlight.observerDefault) {
  42617. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42618. }
  42619. }
  42620. }
  42621. this._meshes = null;
  42622. }
  42623. if (this._excludedMeshes) {
  42624. for (var id in this._excludedMeshes) {
  42625. var meshHighlight = this._excludedMeshes[id];
  42626. if (meshHighlight) {
  42627. if (meshHighlight.beforeBind) {
  42628. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  42629. }
  42630. if (meshHighlight.afterRender) {
  42631. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  42632. }
  42633. }
  42634. }
  42635. this._excludedMeshes = null;
  42636. }
  42637. _super.prototype.dispose.call(this);
  42638. };
  42639. /**
  42640. * Gets the class name of the effect layer
  42641. * @returns the string with the class name of the effect layer
  42642. */
  42643. HighlightLayer.prototype.getClassName = function () {
  42644. return "HighlightLayer";
  42645. };
  42646. /**
  42647. * Serializes this Highlight layer
  42648. * @returns a serialized Highlight layer object
  42649. */
  42650. HighlightLayer.prototype.serialize = function () {
  42651. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42652. serializationObject.customType = "BABYLON.HighlightLayer";
  42653. // Highlighted meshes
  42654. serializationObject.meshes = [];
  42655. if (this._meshes) {
  42656. for (var m in this._meshes) {
  42657. var mesh = this._meshes[m];
  42658. if (mesh) {
  42659. serializationObject.meshes.push({
  42660. glowEmissiveOnly: mesh.glowEmissiveOnly,
  42661. color: mesh.color.asArray(),
  42662. meshId: mesh.mesh.id
  42663. });
  42664. }
  42665. }
  42666. }
  42667. // Excluded meshes
  42668. serializationObject.excludedMeshes = [];
  42669. if (this._excludedMeshes) {
  42670. for (var e in this._excludedMeshes) {
  42671. var excludedMesh = this._excludedMeshes[e];
  42672. if (excludedMesh) {
  42673. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  42674. }
  42675. }
  42676. }
  42677. return serializationObject;
  42678. };
  42679. /**
  42680. * Creates a Highlight layer from parsed Highlight layer data
  42681. * @param parsedHightlightLayer defines the Highlight layer data
  42682. * @param scene defines the current scene
  42683. * @param rootUrl defines the root URL containing the Highlight layer information
  42684. * @returns a parsed Highlight layer
  42685. */
  42686. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  42687. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  42688. var index;
  42689. // Excluded meshes
  42690. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  42691. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  42692. if (mesh) {
  42693. hl.addExcludedMesh(mesh);
  42694. }
  42695. }
  42696. // Included meshes
  42697. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  42698. var highlightedMesh = parsedHightlightLayer.meshes[index];
  42699. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  42700. if (mesh) {
  42701. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  42702. }
  42703. }
  42704. return hl;
  42705. };
  42706. /**
  42707. * Effect Name of the highlight layer.
  42708. */
  42709. HighlightLayer.EffectName = "HighlightLayer";
  42710. /**
  42711. * The neutral color used during the preparation of the glow effect.
  42712. * This is black by default as the blend operation is a blend operation.
  42713. */
  42714. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  42715. /**
  42716. * Stencil value used for glowing meshes.
  42717. */
  42718. HighlightLayer.GlowingMeshStencilReference = 0x02;
  42719. /**
  42720. * Stencil value used for the other meshes in the scene.
  42721. */
  42722. HighlightLayer.NormalMeshStencilReference = 0x01;
  42723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42725. ], HighlightLayer.prototype, "innerGlow", void 0);
  42726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42728. ], HighlightLayer.prototype, "outerGlow", void 0);
  42729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42730. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42731. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  42732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42734. ], HighlightLayer.prototype, "blurVerticalSize", null);
  42735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42737. ], HighlightLayer.prototype, "_options", void 0);
  42738. return HighlightLayer;
  42739. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  42740. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  42741. /***/ }),
  42742. /***/ "./Layers/index.ts":
  42743. /*!*************************!*\
  42744. !*** ./Layers/index.ts ***!
  42745. \*************************/
  42746. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  42747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42748. "use strict";
  42749. __webpack_require__.r(__webpack_exports__);
  42750. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42752. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  42754. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  42755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  42756. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  42757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  42758. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  42759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  42760. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  42762. /***/ }),
  42763. /***/ "./Layers/layer.ts":
  42764. /*!*************************!*\
  42765. !*** ./Layers/layer.ts ***!
  42766. \*************************/
  42767. /*! exports provided: Layer */
  42768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42769. "use strict";
  42770. __webpack_require__.r(__webpack_exports__);
  42771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  42772. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42773. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42774. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42775. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42776. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42777. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42778. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42779. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42780. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42781. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  42782. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  42783. /**
  42784. * This represents a full screen 2d layer.
  42785. * This can be useful to display a picture in the background of your scene for instance.
  42786. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42787. */
  42788. var Layer = /** @class */ (function () {
  42789. /**
  42790. * Instantiates a new layer.
  42791. * This represents a full screen 2d layer.
  42792. * This can be useful to display a picture in the background of your scene for instance.
  42793. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42794. * @param name Define the name of the layer in the scene
  42795. * @param imgUrl Define the url of the texture to display in the layer
  42796. * @param scene Define the scene the layer belongs to
  42797. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  42798. * @param color Defines a color for the layer
  42799. */
  42800. function Layer(
  42801. /**
  42802. * Define the name of the layer.
  42803. */
  42804. name, imgUrl, scene, isBackground, color) {
  42805. this.name = name;
  42806. /**
  42807. * Define the scale of the layer in order to zoom in out of the texture.
  42808. */
  42809. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  42810. /**
  42811. * Define an offset for the layer in order to shift the texture.
  42812. */
  42813. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  42814. /**
  42815. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  42816. */
  42817. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  42818. /**
  42819. * Define a mask to restrict the layer to only some of the scene cameras.
  42820. */
  42821. this.layerMask = 0x0FFFFFFF;
  42822. /**
  42823. * Define the list of render target the layer is visible into.
  42824. */
  42825. this.renderTargetTextures = [];
  42826. /**
  42827. * Define if the layer is only used in renderTarget or if it also
  42828. * renders in the main frame buffer of the canvas.
  42829. */
  42830. this.renderOnlyInRenderTargetTextures = false;
  42831. this._vertexBuffers = {};
  42832. /**
  42833. * An event triggered when the layer is disposed.
  42834. */
  42835. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42836. /**
  42837. * An event triggered before rendering the scene
  42838. */
  42839. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42840. /**
  42841. * An event triggered after rendering the scene
  42842. */
  42843. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42844. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  42845. this.isBackground = isBackground === undefined ? true : isBackground;
  42846. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  42847. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  42848. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  42849. if (!layerComponent) {
  42850. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  42851. this._scene._addComponent(layerComponent);
  42852. }
  42853. this._scene.layers.push(this);
  42854. var engine = this._scene.getEngine();
  42855. // VBO
  42856. var vertices = [];
  42857. vertices.push(1, 1);
  42858. vertices.push(-1, 1);
  42859. vertices.push(-1, -1);
  42860. vertices.push(1, -1);
  42861. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  42862. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  42863. this._createIndexBuffer();
  42864. // Effects
  42865. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  42866. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  42867. }
  42868. Object.defineProperty(Layer.prototype, "onDispose", {
  42869. /**
  42870. * Back compatibility with callback before the onDisposeObservable existed.
  42871. * The set callback will be triggered when the layer has been disposed.
  42872. */
  42873. set: function (callback) {
  42874. if (this._onDisposeObserver) {
  42875. this.onDisposeObservable.remove(this._onDisposeObserver);
  42876. }
  42877. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  42878. },
  42879. enumerable: true,
  42880. configurable: true
  42881. });
  42882. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  42883. /**
  42884. * Back compatibility with callback before the onBeforeRenderObservable existed.
  42885. * The set callback will be triggered just before rendering the layer.
  42886. */
  42887. set: function (callback) {
  42888. if (this._onBeforeRenderObserver) {
  42889. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  42890. }
  42891. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  42892. },
  42893. enumerable: true,
  42894. configurable: true
  42895. });
  42896. Object.defineProperty(Layer.prototype, "onAfterRender", {
  42897. /**
  42898. * Back compatibility with callback before the onAfterRenderObservable existed.
  42899. * The set callback will be triggered just after rendering the layer.
  42900. */
  42901. set: function (callback) {
  42902. if (this._onAfterRenderObserver) {
  42903. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  42904. }
  42905. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  42906. },
  42907. enumerable: true,
  42908. configurable: true
  42909. });
  42910. Layer.prototype._createIndexBuffer = function () {
  42911. var engine = this._scene.getEngine();
  42912. // Indices
  42913. var indices = [];
  42914. indices.push(0);
  42915. indices.push(1);
  42916. indices.push(2);
  42917. indices.push(0);
  42918. indices.push(2);
  42919. indices.push(3);
  42920. this._indexBuffer = engine.createIndexBuffer(indices);
  42921. };
  42922. /** @hidden */
  42923. Layer.prototype._rebuild = function () {
  42924. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42925. if (vb) {
  42926. vb._rebuild();
  42927. }
  42928. this._createIndexBuffer();
  42929. };
  42930. /**
  42931. * Renders the layer in the scene.
  42932. */
  42933. Layer.prototype.render = function () {
  42934. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  42935. // Check
  42936. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  42937. return;
  42938. }
  42939. var engine = this._scene.getEngine();
  42940. this.onBeforeRenderObservable.notifyObservers(this);
  42941. // Render
  42942. engine.enableEffect(currentEffect);
  42943. engine.setState(false);
  42944. // Texture
  42945. currentEffect.setTexture("textureSampler", this.texture);
  42946. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  42947. // Color
  42948. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  42949. // Scale / offset
  42950. currentEffect.setVector2("offset", this.offset);
  42951. currentEffect.setVector2("scale", this.scale);
  42952. // VBOs
  42953. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42954. // Draw order
  42955. if (!this.alphaTest) {
  42956. engine.setAlphaMode(this.alphaBlendingMode);
  42957. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42958. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42959. }
  42960. else {
  42961. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42962. }
  42963. this.onAfterRenderObservable.notifyObservers(this);
  42964. };
  42965. /**
  42966. * Disposes and releases the associated ressources.
  42967. */
  42968. Layer.prototype.dispose = function () {
  42969. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42970. if (vertexBuffer) {
  42971. vertexBuffer.dispose();
  42972. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  42973. }
  42974. if (this._indexBuffer) {
  42975. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42976. this._indexBuffer = null;
  42977. }
  42978. if (this.texture) {
  42979. this.texture.dispose();
  42980. this.texture = null;
  42981. }
  42982. // Clean RTT list
  42983. this.renderTargetTextures = [];
  42984. // Remove from scene
  42985. var index = this._scene.layers.indexOf(this);
  42986. this._scene.layers.splice(index, 1);
  42987. // Callback
  42988. this.onDisposeObservable.notifyObservers(this);
  42989. this.onDisposeObservable.clear();
  42990. this.onAfterRenderObservable.clear();
  42991. this.onBeforeRenderObservable.clear();
  42992. };
  42993. return Layer;
  42994. }());
  42995. /***/ }),
  42996. /***/ "./Layers/layerSceneComponent.ts":
  42997. /*!***************************************!*\
  42998. !*** ./Layers/layerSceneComponent.ts ***!
  42999. \***************************************/
  43000. /*! exports provided: LayerSceneComponent */
  43001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43002. "use strict";
  43003. __webpack_require__.r(__webpack_exports__);
  43004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  43005. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43006. /**
  43007. * Defines the layer scene component responsible to manage any layers
  43008. * in a given scene.
  43009. */
  43010. var LayerSceneComponent = /** @class */ (function () {
  43011. /**
  43012. * Creates a new instance of the component for the given scene
  43013. * @param scene Defines the scene to register the component in
  43014. */
  43015. function LayerSceneComponent(scene) {
  43016. /**
  43017. * The component name helpfull to identify the component in the list of scene components.
  43018. */
  43019. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  43020. this.scene = scene;
  43021. this._engine = scene.getEngine();
  43022. scene.layers = new Array();
  43023. }
  43024. /**
  43025. * Registers the component in a given scene
  43026. */
  43027. LayerSceneComponent.prototype.register = function () {
  43028. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  43029. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  43030. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  43031. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  43032. };
  43033. /**
  43034. * Rebuilds the elements related to this component in case of
  43035. * context lost for instance.
  43036. */
  43037. LayerSceneComponent.prototype.rebuild = function () {
  43038. var layers = this.scene.layers;
  43039. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43040. var layer = layers_1[_i];
  43041. layer._rebuild();
  43042. }
  43043. };
  43044. /**
  43045. * Disposes the component and the associated ressources.
  43046. */
  43047. LayerSceneComponent.prototype.dispose = function () {
  43048. var layers = this.scene.layers;
  43049. while (layers.length) {
  43050. layers[0].dispose();
  43051. }
  43052. };
  43053. LayerSceneComponent.prototype._draw = function (predicate) {
  43054. var layers = this.scene.layers;
  43055. if (layers.length) {
  43056. this._engine.setDepthBuffer(false);
  43057. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43058. var layer = layers_2[_i];
  43059. if (predicate(layer)) {
  43060. layer.render();
  43061. }
  43062. }
  43063. this._engine.setDepthBuffer(true);
  43064. }
  43065. };
  43066. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  43067. return !layer.renderOnlyInRenderTargetTextures &&
  43068. layer.isBackground === isBackground &&
  43069. ((layer.layerMask & cameraLayerMask) !== 0);
  43070. };
  43071. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  43072. var _this = this;
  43073. this._draw(function (layer) {
  43074. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  43075. });
  43076. };
  43077. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  43078. var _this = this;
  43079. this._draw(function (layer) {
  43080. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  43081. });
  43082. };
  43083. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  43084. return (layer.renderTargetTextures.length > 0) &&
  43085. layer.isBackground === isBackground &&
  43086. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  43087. ((layer.layerMask & cameraLayerMask) !== 0);
  43088. };
  43089. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  43090. var _this = this;
  43091. this._draw(function (layer) {
  43092. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  43093. });
  43094. };
  43095. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  43096. var _this = this;
  43097. this._draw(function (layer) {
  43098. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  43099. });
  43100. };
  43101. return LayerSceneComponent;
  43102. }());
  43103. /***/ }),
  43104. /***/ "./Legacy/legacy.ts":
  43105. /*!**************************!*\
  43106. !*** ./Legacy/legacy.ts ***!
  43107. \**************************/
  43108. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, 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, 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, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, 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, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  43109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43110. "use strict";
  43111. __webpack_require__.r(__webpack_exports__);
  43112. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  43113. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  43114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  43115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  43116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  43117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  43118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  43119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  43184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  43185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  43186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  43187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  43188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  43189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  43190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  43191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  43192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  43193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  43194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  43195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  43196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  43197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  43198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  43199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  43200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  43201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  43202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  43203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  43204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  43205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  43206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  43207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  43208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  43209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  43210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  43211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  43212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  43213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  43214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  43215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  43216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  43217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  43218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  43219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  43220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  43221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  43222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  43223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  43224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  43225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  43226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  43227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  43228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  43229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  43230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  43231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  43232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  43233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  43234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  43235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  43236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  43237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  43238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  43239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  43240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  43241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  43242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  43243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  43244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  43245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  43246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  43247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  43248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  43249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  43251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  43252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  43253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  43254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  43255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  43256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  43258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  43259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  43260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  43261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  43262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  43264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  43265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  43266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  43267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  43268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  43269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  43270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  43271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  43272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  43273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  43274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  43275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  43276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  43277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  43278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  43279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  43280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  43281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  43282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  43283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  43284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  43285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  43286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  43287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  43288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  43289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  43290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  43291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  43293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  43295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  43297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  43325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  43326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  43327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  43328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  43329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  43330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  43331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  43332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  43333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  43334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  43335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  43336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  43337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  43338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  43339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  43340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  43341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  43342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  43343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  43344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  43345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  43346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  43347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  43348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  43349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  43350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  43351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  43352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  43353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  43354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  43355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  43356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  43357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  43358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  43359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  43360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  43361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  43362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  43363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  43364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  43365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  43366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  43367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  43368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  43369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  43370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  43371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  43372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  43373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  43374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  43375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  43376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  43377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  43378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  43379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  43380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  43381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  43382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  43383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  43384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  43385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  43386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  43387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  43388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  43389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  43390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  43391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  43392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  43393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  43394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  43395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  43396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  43397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  43398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  43399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  43400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  43401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  43402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  43403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  43404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  43405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  43406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  43407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  43408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  43409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  43410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  43411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  43412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  43413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  43414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  43415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  43416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  43417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  43418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  43419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  43420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  43421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  43422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  43423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  43424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  43425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  43426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  43427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  43428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  43429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  43430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  43431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  43432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  43433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  43434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  43435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  43436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  43437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  43438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  43439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  43440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  43441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  43442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  43443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  43444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  43445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  43446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  43447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  43448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  43449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  43450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  43451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  43452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  43453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  43454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  43455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  43456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  43457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  43458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  43459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  43460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  43461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  43462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  43463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  43464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  43465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  43466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  43467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  43468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  43469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  43470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  43471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  43472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  43473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  43474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  43475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  43476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  43477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  43478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  43479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  43480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  43481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  43482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  43483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  43484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  43485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  43486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  43487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  43488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  43489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  43490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  43491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  43492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  43493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  43494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  43495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  43496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  43497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  43498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  43499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  43500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  43501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  43502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  43503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  43504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  43505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  43506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  43507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  43508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  43509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  43510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  43511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  43512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  43513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  43514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  43515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  43516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  43517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  43518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  43519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  43520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  43521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  43522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  43523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  43524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  43525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  43526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  43527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  43528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  43529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  43530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  43531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  43532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  43533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  43534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  43535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  43536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  43537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  43538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  43539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  43540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  43541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  43542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  43543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  43544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  43545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  43546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  43547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  43548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  43549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  43550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  43551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  43552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  43553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  43554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  43555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  43556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  43557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  43558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  43559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  43560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  43561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  43562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  43563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  43564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  43565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  43566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  43567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  43568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  43569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  43571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  43572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  43573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  43574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  43575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  43576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  43577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  43578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  43579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  43580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  43581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  43582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  43583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  43584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  43585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  43586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  43587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  43588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  43589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  43590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  43591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  43592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  43593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  43594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  43595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  43596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  43597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  43598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  43599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  43600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  43601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  43602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  43603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  43604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  43605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  43606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  43607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  43608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  43609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  43610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  43611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  43612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  43613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  43614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  43615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  43616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  43617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  43618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  43619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  43620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  43621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  43622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  43623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  43624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  43625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  43626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  43627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  43628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  43629. /**
  43630. * Legacy support, defining window.BABYLON (global variable).
  43631. *
  43632. * This is the entry point for the UMD module.
  43633. * The entry point for a future ESM package should be index.ts
  43634. */
  43635. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  43636. if (typeof globalObject !== "undefined") {
  43637. globalObject.BABYLON = BABYLON;
  43638. globalObject.BABYLON = globalObject.BABYLON || {};
  43639. var BABYLON = globalObject.BABYLON;
  43640. BABYLON.Debug = BABYLON.Debug || {};
  43641. var keys = [];
  43642. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  43643. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  43644. keys.push(key);
  43645. }
  43646. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  43647. // Prevent Reassignment.
  43648. if (keys.indexOf(key) > -1) {
  43649. continue;
  43650. }
  43651. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  43652. }
  43653. }
  43654. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  43655. /***/ }),
  43656. /***/ "./LensFlares/index.ts":
  43657. /*!*****************************!*\
  43658. !*** ./LensFlares/index.ts ***!
  43659. \*****************************/
  43660. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  43661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43662. "use strict";
  43663. __webpack_require__.r(__webpack_exports__);
  43664. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43666. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  43668. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  43669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  43670. /***/ }),
  43671. /***/ "./LensFlares/lensFlare.ts":
  43672. /*!*********************************!*\
  43673. !*** ./LensFlares/lensFlare.ts ***!
  43674. \*********************************/
  43675. /*! exports provided: LensFlare */
  43676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43677. "use strict";
  43678. __webpack_require__.r(__webpack_exports__);
  43679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  43680. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43681. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43682. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43683. /**
  43684. * This represents one of the lens effect in a `lensFlareSystem`.
  43685. * It controls one of the indiviual texture used in the effect.
  43686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43687. */
  43688. var LensFlare = /** @class */ (function () {
  43689. /**
  43690. * Instantiates a new Lens Flare.
  43691. * This represents one of the lens effect in a `lensFlareSystem`.
  43692. * It controls one of the indiviual texture used in the effect.
  43693. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43694. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43695. * @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.
  43696. * @param color Define the lens color
  43697. * @param imgUrl Define the lens texture url
  43698. * @param system Define the `lensFlareSystem` this flare is part of
  43699. */
  43700. function LensFlare(
  43701. /**
  43702. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43703. */
  43704. size,
  43705. /**
  43706. * 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.
  43707. */
  43708. position, color, imgUrl, system) {
  43709. this.size = size;
  43710. this.position = position;
  43711. /**
  43712. * Define the alpha mode to render this particular lens.
  43713. */
  43714. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  43715. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  43716. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  43717. this._system = system;
  43718. system.lensFlares.push(this);
  43719. }
  43720. /**
  43721. * Creates a new Lens Flare.
  43722. * This represents one of the lens effect in a `lensFlareSystem`.
  43723. * It controls one of the indiviual texture used in the effect.
  43724. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43725. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  43726. * @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.
  43727. * @param color Define the lens color
  43728. * @param imgUrl Define the lens texture url
  43729. * @param system Define the `lensFlareSystem` this flare is part of
  43730. * @returns The newly created Lens Flare
  43731. */
  43732. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  43733. return new LensFlare(size, position, color, imgUrl, system);
  43734. };
  43735. /**
  43736. * Dispose and release the lens flare with its associated resources.
  43737. */
  43738. LensFlare.prototype.dispose = function () {
  43739. if (this.texture) {
  43740. this.texture.dispose();
  43741. }
  43742. // Remove from scene
  43743. var index = this._system.lensFlares.indexOf(this);
  43744. this._system.lensFlares.splice(index, 1);
  43745. };
  43746. return LensFlare;
  43747. }());
  43748. /***/ }),
  43749. /***/ "./LensFlares/lensFlareSystem.ts":
  43750. /*!***************************************!*\
  43751. !*** ./LensFlares/lensFlareSystem.ts ***!
  43752. \***************************************/
  43753. /*! exports provided: LensFlareSystem */
  43754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43755. "use strict";
  43756. __webpack_require__.r(__webpack_exports__);
  43757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  43758. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43759. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43760. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  43761. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43762. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43763. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  43764. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43765. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43766. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43767. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  43768. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  43769. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  43770. /**
  43771. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43772. * It is usually composed of several `lensFlare`.
  43773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43774. */
  43775. var LensFlareSystem = /** @class */ (function () {
  43776. /**
  43777. * Instantiates a lens flare system.
  43778. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43779. * It is usually composed of several `lensFlare`.
  43780. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43781. * @param name Define the name of the lens flare system in the scene
  43782. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43783. * @param scene Define the scene the lens flare system belongs to
  43784. */
  43785. function LensFlareSystem(
  43786. /**
  43787. * Define the name of the lens flare system
  43788. */
  43789. name, emitter, scene) {
  43790. this.name = name;
  43791. /**
  43792. * List of lens flares used in this system.
  43793. */
  43794. this.lensFlares = new Array();
  43795. /**
  43796. * Define a limit from the border the lens flare can be visible.
  43797. */
  43798. this.borderLimit = 300;
  43799. /**
  43800. * Define a viewport border we do not want to see the lens flare in.
  43801. */
  43802. this.viewportBorder = 0;
  43803. /**
  43804. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43805. */
  43806. this.layerMask = 0x0FFFFFFF;
  43807. this._vertexBuffers = {};
  43808. this._isEnabled = true;
  43809. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  43810. LensFlareSystem._SceneComponentInitialization(this._scene);
  43811. this._emitter = emitter;
  43812. this.id = name;
  43813. scene.lensFlareSystems.push(this);
  43814. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  43815. var engine = scene.getEngine();
  43816. // VBO
  43817. var vertices = [];
  43818. vertices.push(1, 1);
  43819. vertices.push(-1, 1);
  43820. vertices.push(-1, -1);
  43821. vertices.push(1, -1);
  43822. 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);
  43823. // Indices
  43824. var indices = [];
  43825. indices.push(0);
  43826. indices.push(1);
  43827. indices.push(2);
  43828. indices.push(0);
  43829. indices.push(2);
  43830. indices.push(3);
  43831. this._indexBuffer = engine.createIndexBuffer(indices);
  43832. // Effects
  43833. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  43834. }
  43835. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  43836. /**
  43837. * Define if the lens flare system is enabled.
  43838. */
  43839. get: function () {
  43840. return this._isEnabled;
  43841. },
  43842. set: function (value) {
  43843. this._isEnabled = value;
  43844. },
  43845. enumerable: true,
  43846. configurable: true
  43847. });
  43848. /**
  43849. * Get the scene the effects belongs to.
  43850. * @returns the scene holding the lens flare system
  43851. */
  43852. LensFlareSystem.prototype.getScene = function () {
  43853. return this._scene;
  43854. };
  43855. /**
  43856. * Get the emitter of the lens flare system.
  43857. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43858. * @returns the emitter of the lens flare system
  43859. */
  43860. LensFlareSystem.prototype.getEmitter = function () {
  43861. return this._emitter;
  43862. };
  43863. /**
  43864. * Set the emitter of the lens flare system.
  43865. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43866. * @param newEmitter Define the new emitter of the system
  43867. */
  43868. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  43869. this._emitter = newEmitter;
  43870. };
  43871. /**
  43872. * Get the lens flare system emitter position.
  43873. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43874. * @returns the position
  43875. */
  43876. LensFlareSystem.prototype.getEmitterPosition = function () {
  43877. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  43878. };
  43879. /**
  43880. * @hidden
  43881. */
  43882. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  43883. var position = this.getEmitterPosition();
  43884. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  43885. this._positionX = position.x;
  43886. this._positionY = position.y;
  43887. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  43888. if (this.viewportBorder > 0) {
  43889. globalViewport.x -= this.viewportBorder;
  43890. globalViewport.y -= this.viewportBorder;
  43891. globalViewport.width += this.viewportBorder * 2;
  43892. globalViewport.height += this.viewportBorder * 2;
  43893. position.x += this.viewportBorder;
  43894. position.y += this.viewportBorder;
  43895. this._positionX += this.viewportBorder;
  43896. this._positionY += this.viewportBorder;
  43897. }
  43898. if (position.z > 0) {
  43899. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  43900. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  43901. return true;
  43902. }
  43903. }
  43904. return true;
  43905. }
  43906. return false;
  43907. };
  43908. /** @hidden */
  43909. LensFlareSystem.prototype._isVisible = function () {
  43910. if (!this._isEnabled || !this._scene.activeCamera) {
  43911. return false;
  43912. }
  43913. var emitterPosition = this.getEmitterPosition();
  43914. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  43915. var distance = direction.length();
  43916. direction.normalize();
  43917. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  43918. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  43919. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  43920. };
  43921. /**
  43922. * @hidden
  43923. */
  43924. LensFlareSystem.prototype.render = function () {
  43925. if (!this._effect.isReady() || !this._scene.activeCamera) {
  43926. return false;
  43927. }
  43928. var engine = this._scene.getEngine();
  43929. var viewport = this._scene.activeCamera.viewport;
  43930. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  43931. // Position
  43932. if (!this.computeEffectivePosition(globalViewport)) {
  43933. return false;
  43934. }
  43935. // Visibility
  43936. if (!this._isVisible()) {
  43937. return false;
  43938. }
  43939. // Intensity
  43940. var awayX;
  43941. var awayY;
  43942. if (this._positionX < this.borderLimit + globalViewport.x) {
  43943. awayX = this.borderLimit + globalViewport.x - this._positionX;
  43944. }
  43945. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  43946. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  43947. }
  43948. else {
  43949. awayX = 0;
  43950. }
  43951. if (this._positionY < this.borderLimit + globalViewport.y) {
  43952. awayY = this.borderLimit + globalViewport.y - this._positionY;
  43953. }
  43954. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  43955. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  43956. }
  43957. else {
  43958. awayY = 0;
  43959. }
  43960. var away = (awayX > awayY) ? awayX : awayY;
  43961. away -= this.viewportBorder;
  43962. if (away > this.borderLimit) {
  43963. away = this.borderLimit;
  43964. }
  43965. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  43966. if (intensity < 0) {
  43967. return false;
  43968. }
  43969. if (intensity > 1.0) {
  43970. intensity = 1.0;
  43971. }
  43972. if (this.viewportBorder > 0) {
  43973. globalViewport.x += this.viewportBorder;
  43974. globalViewport.y += this.viewportBorder;
  43975. globalViewport.width -= this.viewportBorder * 2;
  43976. globalViewport.height -= this.viewportBorder * 2;
  43977. this._positionX -= this.viewportBorder;
  43978. this._positionY -= this.viewportBorder;
  43979. }
  43980. // Position
  43981. var centerX = globalViewport.x + globalViewport.width / 2;
  43982. var centerY = globalViewport.y + globalViewport.height / 2;
  43983. var distX = centerX - this._positionX;
  43984. var distY = centerY - this._positionY;
  43985. // Effects
  43986. engine.enableEffect(this._effect);
  43987. engine.setState(false);
  43988. engine.setDepthBuffer(false);
  43989. // VBOs
  43990. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  43991. // Flares
  43992. for (var index = 0; index < this.lensFlares.length; index++) {
  43993. var flare = this.lensFlares[index];
  43994. engine.setAlphaMode(flare.alphaMode);
  43995. var x = centerX - (distX * flare.position);
  43996. var y = centerY - (distY * flare.position);
  43997. var cw = flare.size;
  43998. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  43999. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  44000. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  44001. 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);
  44002. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  44003. // Texture
  44004. this._effect.setTexture("textureSampler", flare.texture);
  44005. // Color
  44006. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  44007. // Draw order
  44008. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44009. }
  44010. engine.setDepthBuffer(true);
  44011. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44012. return true;
  44013. };
  44014. /**
  44015. * Dispose and release the lens flare with its associated resources.
  44016. */
  44017. LensFlareSystem.prototype.dispose = function () {
  44018. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  44019. if (vertexBuffer) {
  44020. vertexBuffer.dispose();
  44021. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  44022. }
  44023. if (this._indexBuffer) {
  44024. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44025. this._indexBuffer = null;
  44026. }
  44027. while (this.lensFlares.length) {
  44028. this.lensFlares[0].dispose();
  44029. }
  44030. // Remove from scene
  44031. var index = this._scene.lensFlareSystems.indexOf(this);
  44032. this._scene.lensFlareSystems.splice(index, 1);
  44033. };
  44034. /**
  44035. * Parse a lens flare system from a JSON repressentation
  44036. * @param parsedLensFlareSystem Define the JSON to parse
  44037. * @param scene Define the scene the parsed system should be instantiated in
  44038. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44039. * @returns the parsed system
  44040. */
  44041. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  44042. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  44043. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  44044. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  44045. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  44046. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  44047. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  44048. var parsedFlare = parsedLensFlareSystem.flares[index];
  44049. _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);
  44050. }
  44051. return lensFlareSystem;
  44052. };
  44053. /**
  44054. * Serialize the current Lens Flare System into a JSON representation.
  44055. * @returns the serialized JSON
  44056. */
  44057. LensFlareSystem.prototype.serialize = function () {
  44058. var serializationObject = {};
  44059. serializationObject.id = this.id;
  44060. serializationObject.name = this.name;
  44061. serializationObject.emitterId = this.getEmitter().id;
  44062. serializationObject.borderLimit = this.borderLimit;
  44063. serializationObject.flares = [];
  44064. for (var index = 0; index < this.lensFlares.length; index++) {
  44065. var flare = this.lensFlares[index];
  44066. serializationObject.flares.push({
  44067. size: flare.size,
  44068. position: flare.position,
  44069. color: flare.color.asArray(),
  44070. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  44071. });
  44072. }
  44073. return serializationObject;
  44074. };
  44075. /** @hidden */
  44076. LensFlareSystem._SceneComponentInitialization = function (_) {
  44077. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  44078. };
  44079. return LensFlareSystem;
  44080. }());
  44081. /***/ }),
  44082. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  44083. /*!*****************************************************!*\
  44084. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  44085. \*****************************************************/
  44086. /*! exports provided: LensFlareSystemSceneComponent */
  44087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44088. "use strict";
  44089. __webpack_require__.r(__webpack_exports__);
  44090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  44091. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44092. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44093. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44094. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44095. // Adds the parser to the scene parsers.
  44096. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  44097. // Lens flares
  44098. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  44099. if (!container.lensFlareSystems) {
  44100. container.lensFlareSystems = new Array();
  44101. }
  44102. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  44103. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  44104. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  44105. container.lensFlareSystems.push(lf);
  44106. }
  44107. }
  44108. });
  44109. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  44110. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44111. if (this.lensFlareSystems[index].name === name) {
  44112. return this.lensFlareSystems[index];
  44113. }
  44114. }
  44115. return null;
  44116. };
  44117. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  44118. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44119. if (this.lensFlareSystems[index].id === id) {
  44120. return this.lensFlareSystems[index];
  44121. }
  44122. }
  44123. return null;
  44124. };
  44125. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44126. var index = this.lensFlareSystems.indexOf(toRemove);
  44127. if (index !== -1) {
  44128. this.lensFlareSystems.splice(index, 1);
  44129. }
  44130. return index;
  44131. };
  44132. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44133. this.lensFlareSystems.push(newLensFlareSystem);
  44134. };
  44135. /**
  44136. * Defines the lens flare scene component responsible to manage any lens flares
  44137. * in a given scene.
  44138. */
  44139. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44140. /**
  44141. * Creates a new instance of the component for the given scene
  44142. * @param scene Defines the scene to register the component in
  44143. */
  44144. function LensFlareSystemSceneComponent(scene) {
  44145. /**
  44146. * The component name helpfull to identify the component in the list of scene components.
  44147. */
  44148. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44149. this.scene = scene;
  44150. scene.lensFlareSystems = new Array();
  44151. }
  44152. /**
  44153. * Registers the component in a given scene
  44154. */
  44155. LensFlareSystemSceneComponent.prototype.register = function () {
  44156. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44157. };
  44158. /**
  44159. * Rebuilds the elements related to this component in case of
  44160. * context lost for instance.
  44161. */
  44162. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44163. // Nothing to do for lens flare
  44164. };
  44165. /**
  44166. * Adds all the element from the container to the scene
  44167. * @param container the container holding the elements
  44168. */
  44169. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44170. var _this = this;
  44171. if (!container.lensFlareSystems) {
  44172. return;
  44173. }
  44174. container.lensFlareSystems.forEach(function (o) {
  44175. _this.scene.addLensFlareSystem(o);
  44176. });
  44177. };
  44178. /**
  44179. * Removes all the elements in the container from the scene
  44180. * @param container contains the elements to remove
  44181. */
  44182. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  44183. var _this = this;
  44184. if (!container.lensFlareSystems) {
  44185. return;
  44186. }
  44187. container.lensFlareSystems.forEach(function (o) {
  44188. _this.scene.removeLensFlareSystem(o);
  44189. });
  44190. };
  44191. /**
  44192. * Serializes the component data to the specified json object
  44193. * @param serializationObject The object to serialize to
  44194. */
  44195. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  44196. // Lens flares
  44197. serializationObject.lensFlareSystems = [];
  44198. var lensFlareSystems = this.scene.lensFlareSystems;
  44199. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  44200. var lensFlareSystem = lensFlareSystems_1[_i];
  44201. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  44202. }
  44203. };
  44204. /**
  44205. * Disposes the component and the associated ressources.
  44206. */
  44207. LensFlareSystemSceneComponent.prototype.dispose = function () {
  44208. var lensFlareSystems = this.scene.lensFlareSystems;
  44209. while (lensFlareSystems.length) {
  44210. lensFlareSystems[0].dispose();
  44211. }
  44212. };
  44213. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  44214. // Lens flares
  44215. if (this.scene.lensFlaresEnabled) {
  44216. var lensFlareSystems = this.scene.lensFlareSystems;
  44217. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44218. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  44219. var lensFlareSystem = lensFlareSystems_2[_i];
  44220. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  44221. lensFlareSystem.render();
  44222. }
  44223. }
  44224. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44225. }
  44226. };
  44227. return LensFlareSystemSceneComponent;
  44228. }());
  44229. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  44230. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  44231. if (!component) {
  44232. component = new LensFlareSystemSceneComponent(scene);
  44233. scene._addComponent(component);
  44234. }
  44235. };
  44236. /***/ }),
  44237. /***/ "./Lights/Shadows/index.ts":
  44238. /*!*********************************!*\
  44239. !*** ./Lights/Shadows/index.ts ***!
  44240. \*********************************/
  44241. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  44242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44243. "use strict";
  44244. __webpack_require__.r(__webpack_exports__);
  44245. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44247. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  44248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  44249. /***/ }),
  44250. /***/ "./Lights/Shadows/shadowGenerator.ts":
  44251. /*!*******************************************!*\
  44252. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  44253. \*******************************************/
  44254. /*! exports provided: ShadowGenerator */
  44255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44256. "use strict";
  44257. __webpack_require__.r(__webpack_exports__);
  44258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  44259. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44260. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  44261. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  44262. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  44263. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  44264. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  44265. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44266. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44267. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44268. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44269. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  44270. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  44271. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  44272. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  44273. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  44274. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  44275. /**
  44276. * Default implementation IShadowGenerator.
  44277. * This is the main object responsible of generating shadows in the framework.
  44278. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44279. */
  44280. var ShadowGenerator = /** @class */ (function () {
  44281. /**
  44282. * Creates a ShadowGenerator object.
  44283. * A ShadowGenerator is the required tool to use the shadows.
  44284. * Each light casting shadows needs to use its own ShadowGenerator.
  44285. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44286. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44287. * @param light The light object generating the shadows.
  44288. * @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.
  44289. */
  44290. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  44291. /**
  44292. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  44293. */
  44294. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44295. this._bias = 0.00005;
  44296. this._normalBias = 0;
  44297. this._blurBoxOffset = 1;
  44298. this._blurScale = 2;
  44299. this._blurKernel = 1;
  44300. this._useKernelBlur = false;
  44301. this._filter = ShadowGenerator.FILTER_NONE;
  44302. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  44303. this._contactHardeningLightSizeUVRatio = 0.1;
  44304. this._darkness = 0;
  44305. this._transparencyShadow = false;
  44306. /**
  44307. * Controls the extent to which the shadows fade out at the edge of the frustum
  44308. * Used only by directionals and spots
  44309. */
  44310. this.frustumEdgeFalloff = 0;
  44311. /**
  44312. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44313. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44314. * It might on the other hand introduce peter panning.
  44315. */
  44316. this.forceBackFacesOnly = false;
  44317. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  44318. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44319. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44320. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44321. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44322. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44323. this._currentFaceIndex = 0;
  44324. this._currentFaceIndexCache = 0;
  44325. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  44326. this._mapSize = mapSize;
  44327. this._light = light;
  44328. this._scene = light.getScene();
  44329. light._shadowGenerator = this;
  44330. ShadowGenerator._SceneComponentInitialization(this._scene);
  44331. // Texture type fallback from float to int if not supported.
  44332. var caps = this._scene.getEngine().getCaps();
  44333. if (!usefulFloatFirst) {
  44334. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44335. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44336. }
  44337. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44338. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44339. }
  44340. else {
  44341. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44342. }
  44343. }
  44344. else {
  44345. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44346. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44347. }
  44348. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44349. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44350. }
  44351. else {
  44352. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44353. }
  44354. }
  44355. this._initializeGenerator();
  44356. this._applyFilterValues();
  44357. }
  44358. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  44359. /**
  44360. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44361. */
  44362. get: function () {
  44363. return this._bias;
  44364. },
  44365. /**
  44366. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44367. */
  44368. set: function (bias) {
  44369. this._bias = bias;
  44370. },
  44371. enumerable: true,
  44372. configurable: true
  44373. });
  44374. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  44375. /**
  44376. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44377. */
  44378. get: function () {
  44379. return this._normalBias;
  44380. },
  44381. /**
  44382. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44383. */
  44384. set: function (normalBias) {
  44385. this._normalBias = normalBias;
  44386. },
  44387. enumerable: true,
  44388. configurable: true
  44389. });
  44390. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  44391. /**
  44392. * Gets the blur box offset: offset applied during the blur pass.
  44393. * Only useful if useKernelBlur = false
  44394. */
  44395. get: function () {
  44396. return this._blurBoxOffset;
  44397. },
  44398. /**
  44399. * Sets the blur box offset: offset applied during the blur pass.
  44400. * Only useful if useKernelBlur = false
  44401. */
  44402. set: function (value) {
  44403. if (this._blurBoxOffset === value) {
  44404. return;
  44405. }
  44406. this._blurBoxOffset = value;
  44407. this._disposeBlurPostProcesses();
  44408. },
  44409. enumerable: true,
  44410. configurable: true
  44411. });
  44412. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  44413. /**
  44414. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44415. * 2 means half of the size.
  44416. */
  44417. get: function () {
  44418. return this._blurScale;
  44419. },
  44420. /**
  44421. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44422. * 2 means half of the size.
  44423. */
  44424. set: function (value) {
  44425. if (this._blurScale === value) {
  44426. return;
  44427. }
  44428. this._blurScale = value;
  44429. this._disposeBlurPostProcesses();
  44430. },
  44431. enumerable: true,
  44432. configurable: true
  44433. });
  44434. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  44435. /**
  44436. * Gets the blur kernel: kernel size of the blur pass.
  44437. * Only useful if useKernelBlur = true
  44438. */
  44439. get: function () {
  44440. return this._blurKernel;
  44441. },
  44442. /**
  44443. * Sets the blur kernel: kernel size of the blur pass.
  44444. * Only useful if useKernelBlur = true
  44445. */
  44446. set: function (value) {
  44447. if (this._blurKernel === value) {
  44448. return;
  44449. }
  44450. this._blurKernel = value;
  44451. this._disposeBlurPostProcesses();
  44452. },
  44453. enumerable: true,
  44454. configurable: true
  44455. });
  44456. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  44457. /**
  44458. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44459. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44460. */
  44461. get: function () {
  44462. return this._useKernelBlur;
  44463. },
  44464. /**
  44465. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44466. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44467. */
  44468. set: function (value) {
  44469. if (this._useKernelBlur === value) {
  44470. return;
  44471. }
  44472. this._useKernelBlur = value;
  44473. this._disposeBlurPostProcesses();
  44474. },
  44475. enumerable: true,
  44476. configurable: true
  44477. });
  44478. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  44479. /**
  44480. * Gets the depth scale used in ESM mode.
  44481. */
  44482. get: function () {
  44483. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  44484. },
  44485. /**
  44486. * Sets the depth scale used in ESM mode.
  44487. * This can override the scale stored on the light.
  44488. */
  44489. set: function (value) {
  44490. this._depthScale = value;
  44491. },
  44492. enumerable: true,
  44493. configurable: true
  44494. });
  44495. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  44496. /**
  44497. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44498. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44499. */
  44500. get: function () {
  44501. return this._filter;
  44502. },
  44503. /**
  44504. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44505. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44506. */
  44507. set: function (value) {
  44508. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  44509. if (this._light.needCube()) {
  44510. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44511. this.useExponentialShadowMap = true;
  44512. return;
  44513. }
  44514. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44515. this.useCloseExponentialShadowMap = true;
  44516. return;
  44517. }
  44518. // PCF on cubemap would also be expensive
  44519. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44520. this.usePoissonSampling = true;
  44521. return;
  44522. }
  44523. }
  44524. // Weblg1 fallback for PCF.
  44525. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44526. if (this._scene.getEngine().webGLVersion === 1) {
  44527. this.usePoissonSampling = true;
  44528. return;
  44529. }
  44530. }
  44531. if (this._filter === value) {
  44532. return;
  44533. }
  44534. this._filter = value;
  44535. this._disposeBlurPostProcesses();
  44536. this._applyFilterValues();
  44537. this._light._markMeshesAsLightDirty();
  44538. },
  44539. enumerable: true,
  44540. configurable: true
  44541. });
  44542. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  44543. /**
  44544. * Gets if the current filter is set to Poisson Sampling.
  44545. */
  44546. get: function () {
  44547. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  44548. },
  44549. /**
  44550. * Sets the current filter to Poisson Sampling.
  44551. */
  44552. set: function (value) {
  44553. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  44554. return;
  44555. }
  44556. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  44557. },
  44558. enumerable: true,
  44559. configurable: true
  44560. });
  44561. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  44562. /**
  44563. * Gets if the current filter is set to ESM.
  44564. */
  44565. get: function () {
  44566. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  44567. },
  44568. /**
  44569. * Sets the current filter is to ESM.
  44570. */
  44571. set: function (value) {
  44572. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  44573. return;
  44574. }
  44575. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44576. },
  44577. enumerable: true,
  44578. configurable: true
  44579. });
  44580. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  44581. /**
  44582. * Gets if the current filter is set to filtered ESM.
  44583. */
  44584. get: function () {
  44585. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  44586. },
  44587. /**
  44588. * Gets if the current filter is set to filtered ESM.
  44589. */
  44590. set: function (value) {
  44591. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44592. return;
  44593. }
  44594. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44595. },
  44596. enumerable: true,
  44597. configurable: true
  44598. });
  44599. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  44600. /**
  44601. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44602. * exponential to prevent steep falloff artifacts).
  44603. */
  44604. get: function () {
  44605. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  44606. },
  44607. /**
  44608. * Sets the current filter to "close ESM" (using the inverse of the
  44609. * exponential to prevent steep falloff artifacts).
  44610. */
  44611. set: function (value) {
  44612. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  44613. return;
  44614. }
  44615. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44616. },
  44617. enumerable: true,
  44618. configurable: true
  44619. });
  44620. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  44621. /**
  44622. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44623. * exponential to prevent steep falloff artifacts).
  44624. */
  44625. get: function () {
  44626. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  44627. },
  44628. /**
  44629. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44630. * exponential to prevent steep falloff artifacts).
  44631. */
  44632. set: function (value) {
  44633. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44634. return;
  44635. }
  44636. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44637. },
  44638. enumerable: true,
  44639. configurable: true
  44640. });
  44641. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  44642. /**
  44643. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44644. */
  44645. get: function () {
  44646. return this.filter === ShadowGenerator.FILTER_PCF;
  44647. },
  44648. /**
  44649. * Sets the current filter to "PCF" (percentage closer filtering).
  44650. */
  44651. set: function (value) {
  44652. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  44653. return;
  44654. }
  44655. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  44656. },
  44657. enumerable: true,
  44658. configurable: true
  44659. });
  44660. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  44661. /**
  44662. * Gets the PCF or PCSS Quality.
  44663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44664. */
  44665. get: function () {
  44666. return this._filteringQuality;
  44667. },
  44668. /**
  44669. * Sets the PCF or PCSS Quality.
  44670. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44671. */
  44672. set: function (filteringQuality) {
  44673. this._filteringQuality = filteringQuality;
  44674. },
  44675. enumerable: true,
  44676. configurable: true
  44677. });
  44678. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  44679. /**
  44680. * Gets if the current filter is set to "PCSS" (contact hardening).
  44681. */
  44682. get: function () {
  44683. return this.filter === ShadowGenerator.FILTER_PCSS;
  44684. },
  44685. /**
  44686. * Sets the current filter to "PCSS" (contact hardening).
  44687. */
  44688. set: function (value) {
  44689. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  44690. return;
  44691. }
  44692. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  44693. },
  44694. enumerable: true,
  44695. configurable: true
  44696. });
  44697. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  44698. /**
  44699. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44700. * Using a ratio helps keeping shape stability independently of the map size.
  44701. *
  44702. * It does not account for the light projection as it was having too much
  44703. * instability during the light setup or during light position changes.
  44704. *
  44705. * Only valid if useContactHardeningShadow is true.
  44706. */
  44707. get: function () {
  44708. return this._contactHardeningLightSizeUVRatio;
  44709. },
  44710. /**
  44711. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44712. * Using a ratio helps keeping shape stability independently of the map size.
  44713. *
  44714. * It does not account for the light projection as it was having too much
  44715. * instability during the light setup or during light position changes.
  44716. *
  44717. * Only valid if useContactHardeningShadow is true.
  44718. */
  44719. set: function (contactHardeningLightSizeUVRatio) {
  44720. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  44721. },
  44722. enumerable: true,
  44723. configurable: true
  44724. });
  44725. /**
  44726. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44727. * 0 means strongest and 1 would means no shadow.
  44728. * @returns the darkness.
  44729. */
  44730. ShadowGenerator.prototype.getDarkness = function () {
  44731. return this._darkness;
  44732. };
  44733. /**
  44734. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44735. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44736. * @returns the shadow generator allowing fluent coding.
  44737. */
  44738. ShadowGenerator.prototype.setDarkness = function (darkness) {
  44739. if (darkness >= 1.0) {
  44740. this._darkness = 1.0;
  44741. }
  44742. else if (darkness <= 0.0) {
  44743. this._darkness = 0.0;
  44744. }
  44745. else {
  44746. this._darkness = darkness;
  44747. }
  44748. return this;
  44749. };
  44750. /**
  44751. * Sets the ability to have transparent shadow (boolean).
  44752. * @param transparent True if transparent else False
  44753. * @returns the shadow generator allowing fluent coding
  44754. */
  44755. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  44756. this._transparencyShadow = transparent;
  44757. return this;
  44758. };
  44759. /**
  44760. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44761. * @returns The render target texture if present otherwise, null
  44762. */
  44763. ShadowGenerator.prototype.getShadowMap = function () {
  44764. return this._shadowMap;
  44765. };
  44766. /**
  44767. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44768. * @returns The render target texture if the shadow map is present otherwise, null
  44769. */
  44770. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  44771. if (this._shadowMap2) {
  44772. return this._shadowMap2;
  44773. }
  44774. return this._shadowMap;
  44775. };
  44776. /**
  44777. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44778. * @param mesh Mesh to add
  44779. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44780. * @returns the Shadow Generator itself
  44781. */
  44782. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  44783. if (includeDescendants === void 0) { includeDescendants = true; }
  44784. var _a;
  44785. if (!this._shadowMap) {
  44786. return this;
  44787. }
  44788. if (!this._shadowMap.renderList) {
  44789. this._shadowMap.renderList = [];
  44790. }
  44791. this._shadowMap.renderList.push(mesh);
  44792. if (includeDescendants) {
  44793. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  44794. }
  44795. return this;
  44796. };
  44797. /**
  44798. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44799. * @param mesh Mesh to remove
  44800. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44801. * @returns the Shadow Generator itself
  44802. */
  44803. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  44804. if (includeDescendants === void 0) { includeDescendants = true; }
  44805. if (!this._shadowMap || !this._shadowMap.renderList) {
  44806. return this;
  44807. }
  44808. var index = this._shadowMap.renderList.indexOf(mesh);
  44809. if (index !== -1) {
  44810. this._shadowMap.renderList.splice(index, 1);
  44811. }
  44812. if (includeDescendants) {
  44813. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  44814. var child = _a[_i];
  44815. this.removeShadowCaster(child);
  44816. }
  44817. }
  44818. return this;
  44819. };
  44820. /**
  44821. * Returns the associated light object.
  44822. * @returns the light generating the shadow
  44823. */
  44824. ShadowGenerator.prototype.getLight = function () {
  44825. return this._light;
  44826. };
  44827. ShadowGenerator.prototype._initializeGenerator = function () {
  44828. this._light._markMeshesAsLightDirty();
  44829. this._initializeShadowMap();
  44830. };
  44831. ShadowGenerator.prototype._initializeShadowMap = function () {
  44832. var _this = this;
  44833. // Render target
  44834. var engine = this._scene.getEngine();
  44835. if (engine.webGLVersion > 1) {
  44836. 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);
  44837. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  44838. }
  44839. else {
  44840. 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());
  44841. }
  44842. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44843. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44844. this._shadowMap.anisotropicFilteringLevel = 1;
  44845. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44846. this._shadowMap.renderParticles = false;
  44847. this._shadowMap.ignoreCameraViewport = true;
  44848. // Record Face Index before render.
  44849. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  44850. _this._currentFaceIndex = faceIndex;
  44851. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44852. engine.setColorWrite(false);
  44853. }
  44854. });
  44855. // Custom render function.
  44856. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  44857. // Blur if required afer render.
  44858. this._shadowMap.onAfterUnbindObservable.add(function () {
  44859. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44860. engine.setColorWrite(true);
  44861. }
  44862. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  44863. return;
  44864. }
  44865. var shadowMap = _this.getShadowMapForRendering();
  44866. if (shadowMap) {
  44867. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  44868. }
  44869. });
  44870. // Clear according to the chosen filter.
  44871. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  44872. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  44873. this._shadowMap.onClearObservable.add(function (engine) {
  44874. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44875. engine.clear(clearOne, false, true, false);
  44876. }
  44877. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  44878. engine.clear(clearZero, true, true, false);
  44879. }
  44880. else {
  44881. engine.clear(clearOne, true, true, false);
  44882. }
  44883. });
  44884. };
  44885. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  44886. var _this = this;
  44887. var engine = this._scene.getEngine();
  44888. var targetSize = this._mapSize / this.blurScale;
  44889. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  44890. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  44891. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44892. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44893. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44894. }
  44895. if (this.useKernelBlur) {
  44896. 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);
  44897. this._kernelBlurXPostprocess.width = targetSize;
  44898. this._kernelBlurXPostprocess.height = targetSize;
  44899. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  44900. effect.setTexture("textureSampler", _this._shadowMap);
  44901. });
  44902. 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);
  44903. this._kernelBlurXPostprocess.autoClear = false;
  44904. this._kernelBlurYPostprocess.autoClear = false;
  44905. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44906. this._kernelBlurXPostprocess.packedFloat = true;
  44907. this._kernelBlurYPostprocess.packedFloat = true;
  44908. }
  44909. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  44910. }
  44911. else {
  44912. 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);
  44913. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  44914. effect.setFloat2("screenSize", targetSize, targetSize);
  44915. effect.setTexture("textureSampler", _this._shadowMap);
  44916. });
  44917. this._boxBlurPostprocess.autoClear = false;
  44918. this._blurPostProcesses = [this._boxBlurPostprocess];
  44919. }
  44920. };
  44921. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  44922. var index;
  44923. var engine = this._scene.getEngine();
  44924. if (depthOnlySubMeshes.length) {
  44925. engine.setColorWrite(false);
  44926. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  44927. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  44928. }
  44929. engine.setColorWrite(true);
  44930. }
  44931. for (index = 0; index < opaqueSubMeshes.length; index++) {
  44932. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  44933. }
  44934. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  44935. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  44936. }
  44937. if (this._transparencyShadow) {
  44938. for (index = 0; index < transparentSubMeshes.length; index++) {
  44939. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  44940. }
  44941. }
  44942. };
  44943. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  44944. var _this = this;
  44945. var mesh = subMesh.getRenderingMesh();
  44946. var scene = this._scene;
  44947. var engine = scene.getEngine();
  44948. var material = subMesh.getMaterial();
  44949. if (!material || subMesh.verticesCount === 0) {
  44950. return;
  44951. }
  44952. // Culling
  44953. engine.setState(material.backFaceCulling);
  44954. // Managing instances
  44955. var batch = mesh._getInstancesRenderList(subMesh._id);
  44956. if (batch.mustReturn) {
  44957. return;
  44958. }
  44959. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  44960. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  44961. engine.enableEffect(this._effect);
  44962. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  44963. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  44964. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  44965. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44966. this._effect.setVector3("lightData", this._cachedDirection);
  44967. }
  44968. else {
  44969. this._effect.setVector3("lightData", this._cachedPosition);
  44970. }
  44971. if (scene.activeCamera) {
  44972. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  44973. }
  44974. // Alpha test
  44975. if (material && material.needAlphaTesting()) {
  44976. var alphaTexture = material.getAlphaTestTexture();
  44977. if (alphaTexture) {
  44978. this._effect.setTexture("diffuseSampler", alphaTexture);
  44979. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  44980. }
  44981. }
  44982. // Bones
  44983. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44984. var skeleton = mesh.skeleton;
  44985. if (skeleton.isUsingTextureForMatrices) {
  44986. var boneTexture = skeleton.getTransformMatrixTexture();
  44987. if (!boneTexture) {
  44988. return;
  44989. }
  44990. this._effect.setTexture("boneSampler", boneTexture);
  44991. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  44992. }
  44993. else {
  44994. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  44995. }
  44996. }
  44997. // Morph targets
  44998. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  44999. if (this.forceBackFacesOnly) {
  45000. engine.setState(true, 0, false, true);
  45001. }
  45002. // Observable
  45003. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  45004. // Draw
  45005. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  45006. if (this.forceBackFacesOnly) {
  45007. engine.setState(true, 0, false, false);
  45008. }
  45009. }
  45010. else {
  45011. // Need to reset refresh rate of the shadowMap
  45012. if (this._shadowMap) {
  45013. this._shadowMap.resetRefreshCounter();
  45014. }
  45015. }
  45016. };
  45017. ShadowGenerator.prototype._applyFilterValues = function () {
  45018. if (!this._shadowMap) {
  45019. return;
  45020. }
  45021. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  45022. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  45023. }
  45024. else {
  45025. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45026. }
  45027. };
  45028. /**
  45029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45030. * @param onCompiled Callback triggered at the and of the effects compilation
  45031. * @param options Sets of optional options forcing the compilation with different modes
  45032. */
  45033. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  45034. var _this = this;
  45035. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  45036. var shadowMap = this.getShadowMap();
  45037. if (!shadowMap) {
  45038. if (onCompiled) {
  45039. onCompiled(this);
  45040. }
  45041. return;
  45042. }
  45043. var renderList = shadowMap.renderList;
  45044. if (!renderList) {
  45045. if (onCompiled) {
  45046. onCompiled(this);
  45047. }
  45048. return;
  45049. }
  45050. var subMeshes = new Array();
  45051. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  45052. var mesh = renderList_1[_i];
  45053. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  45054. }
  45055. if (subMeshes.length === 0) {
  45056. if (onCompiled) {
  45057. onCompiled(this);
  45058. }
  45059. return;
  45060. }
  45061. var currentIndex = 0;
  45062. var checkReady = function () {
  45063. if (!_this._scene || !_this._scene.getEngine()) {
  45064. return;
  45065. }
  45066. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  45067. currentIndex++;
  45068. if (currentIndex >= subMeshes.length) {
  45069. if (onCompiled) {
  45070. onCompiled(_this);
  45071. }
  45072. return;
  45073. }
  45074. }
  45075. setTimeout(checkReady, 16);
  45076. };
  45077. checkReady();
  45078. };
  45079. /**
  45080. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45081. * @param options Sets of optional options forcing the compilation with different modes
  45082. * @returns A promise that resolves when the compilation completes
  45083. */
  45084. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  45085. var _this = this;
  45086. return new Promise(function (resolve) {
  45087. _this.forceCompilation(function () {
  45088. resolve();
  45089. }, options);
  45090. });
  45091. };
  45092. /**
  45093. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  45094. * @param subMesh The submesh we want to render in the shadow map
  45095. * @param useInstances Defines wether will draw in the map using instances
  45096. * @returns true if ready otherwise, false
  45097. */
  45098. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  45099. var defines = [];
  45100. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45101. defines.push("#define FLOAT");
  45102. }
  45103. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45104. defines.push("#define ESM");
  45105. }
  45106. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  45107. defines.push("#define DEPTHTEXTURE");
  45108. }
  45109. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  45110. var mesh = subMesh.getMesh();
  45111. var material = subMesh.getMaterial();
  45112. // Normal bias.
  45113. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  45114. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  45115. defines.push("#define NORMAL");
  45116. if (mesh.nonUniformScaling) {
  45117. defines.push("#define NONUNIFORMSCALING");
  45118. }
  45119. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45120. defines.push("#define DIRECTIONINLIGHTDATA");
  45121. }
  45122. }
  45123. // Alpha test
  45124. if (material && material.needAlphaTesting()) {
  45125. var alphaTexture = material.getAlphaTestTexture();
  45126. if (alphaTexture) {
  45127. defines.push("#define ALPHATEST");
  45128. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45129. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45130. defines.push("#define UV1");
  45131. }
  45132. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45133. if (alphaTexture.coordinatesIndex === 1) {
  45134. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45135. defines.push("#define UV2");
  45136. }
  45137. }
  45138. }
  45139. }
  45140. // Bones
  45141. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45142. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45143. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45144. if (mesh.numBoneInfluencers > 4) {
  45145. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45146. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45147. }
  45148. var skeleton = mesh.skeleton;
  45149. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45150. if (skeleton.isUsingTextureForMatrices) {
  45151. defines.push("#define BONETEXTURE");
  45152. }
  45153. else {
  45154. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45155. }
  45156. }
  45157. else {
  45158. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45159. }
  45160. // Morph targets
  45161. var manager = mesh.morphTargetManager;
  45162. var morphInfluencers = 0;
  45163. if (manager) {
  45164. if (manager.numInfluencers > 0) {
  45165. defines.push("#define MORPHTARGETS");
  45166. morphInfluencers = manager.numInfluencers;
  45167. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45168. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  45169. }
  45170. }
  45171. // Instances
  45172. if (useInstances) {
  45173. defines.push("#define INSTANCES");
  45174. attribs.push("world0");
  45175. attribs.push("world1");
  45176. attribs.push("world2");
  45177. attribs.push("world3");
  45178. }
  45179. if (this.customShaderOptions) {
  45180. if (this.customShaderOptions.defines) {
  45181. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  45182. var define = _a[_i];
  45183. if (defines.indexOf(define) === -1) {
  45184. defines.push(define);
  45185. }
  45186. }
  45187. }
  45188. }
  45189. // Get correct effect
  45190. var join = defines.join("\n");
  45191. if (this._cachedDefines !== join) {
  45192. this._cachedDefines = join;
  45193. var shaderName = "shadowMap";
  45194. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  45195. var samplers = ["diffuseSampler", "boneSampler"];
  45196. // Custom shader?
  45197. if (this.customShaderOptions) {
  45198. shaderName = this.customShaderOptions.shaderName;
  45199. if (this.customShaderOptions.attributes) {
  45200. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  45201. var attrib = _c[_b];
  45202. if (attribs.indexOf(attrib) === -1) {
  45203. attribs.push(attrib);
  45204. }
  45205. }
  45206. }
  45207. if (this.customShaderOptions.uniforms) {
  45208. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  45209. var uniform = _e[_d];
  45210. if (uniforms.indexOf(uniform) === -1) {
  45211. uniforms.push(uniform);
  45212. }
  45213. }
  45214. }
  45215. if (this.customShaderOptions.samplers) {
  45216. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  45217. var sampler = _g[_f];
  45218. if (samplers.indexOf(sampler) === -1) {
  45219. samplers.push(sampler);
  45220. }
  45221. }
  45222. }
  45223. }
  45224. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45225. }
  45226. if (!this._effect.isReady()) {
  45227. return false;
  45228. }
  45229. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45230. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  45231. this._initializeBlurRTTAndPostProcesses();
  45232. }
  45233. }
  45234. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  45235. return false;
  45236. }
  45237. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  45238. return false;
  45239. }
  45240. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  45241. return false;
  45242. }
  45243. return true;
  45244. };
  45245. /**
  45246. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  45247. * @param defines Defines of the material we want to update
  45248. * @param lightIndex Index of the light in the enabled light list of the material
  45249. */
  45250. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  45251. var scene = this._scene;
  45252. var light = this._light;
  45253. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45254. return;
  45255. }
  45256. defines["SHADOW" + lightIndex] = true;
  45257. if (this.useContactHardeningShadow) {
  45258. defines["SHADOWPCSS" + lightIndex] = true;
  45259. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45260. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45261. }
  45262. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45263. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45264. }
  45265. // else default to high.
  45266. }
  45267. if (this.usePercentageCloserFiltering) {
  45268. defines["SHADOWPCF" + lightIndex] = true;
  45269. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45270. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45271. }
  45272. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45273. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45274. }
  45275. // else default to high.
  45276. }
  45277. else if (this.usePoissonSampling) {
  45278. defines["SHADOWPOISSON" + lightIndex] = true;
  45279. }
  45280. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45281. defines["SHADOWESM" + lightIndex] = true;
  45282. }
  45283. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45284. defines["SHADOWCLOSEESM" + lightIndex] = true;
  45285. }
  45286. if (light.needCube()) {
  45287. defines["SHADOWCUBE" + lightIndex] = true;
  45288. }
  45289. };
  45290. /**
  45291. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  45292. * defined in the generator but impacting the effect).
  45293. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45294. * @param effect The effect we are binfing the information for
  45295. */
  45296. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45297. var light = this._light;
  45298. var scene = this._scene;
  45299. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45300. return;
  45301. }
  45302. var camera = scene.activeCamera;
  45303. if (!camera) {
  45304. return;
  45305. }
  45306. var shadowMap = this.getShadowMap();
  45307. if (!shadowMap) {
  45308. return;
  45309. }
  45310. if (!light.needCube()) {
  45311. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  45312. }
  45313. // Only PCF uses depth stencil texture.
  45314. if (this._filter === ShadowGenerator.FILTER_PCF) {
  45315. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45316. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45317. }
  45318. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  45319. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45320. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  45321. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45322. }
  45323. else {
  45324. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45325. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  45326. }
  45327. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  45328. };
  45329. /**
  45330. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  45331. * (eq to shadow prjection matrix * light transform matrix)
  45332. * @returns The transform matrix used to create the shadow map
  45333. */
  45334. ShadowGenerator.prototype.getTransformMatrix = function () {
  45335. var scene = this._scene;
  45336. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  45337. return this._transformMatrix;
  45338. }
  45339. this._currentRenderID = scene.getRenderId();
  45340. this._currentFaceIndexCache = this._currentFaceIndex;
  45341. var lightPosition = this._light.position;
  45342. if (this._light.computeTransformedInformation()) {
  45343. lightPosition = this._light.transformedPosition;
  45344. }
  45345. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  45346. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  45347. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  45348. }
  45349. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  45350. this._cachedPosition.copyFrom(lightPosition);
  45351. this._cachedDirection.copyFrom(this._lightDirection);
  45352. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  45353. var shadowMap = this.getShadowMap();
  45354. if (shadowMap) {
  45355. var renderList = shadowMap.renderList;
  45356. if (renderList) {
  45357. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  45358. }
  45359. }
  45360. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  45361. }
  45362. return this._transformMatrix;
  45363. };
  45364. /**
  45365. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  45366. * Cube and 2D textures for instance.
  45367. */
  45368. ShadowGenerator.prototype.recreateShadowMap = function () {
  45369. var shadowMap = this._shadowMap;
  45370. if (!shadowMap) {
  45371. return;
  45372. }
  45373. // Track render list.
  45374. var renderList = shadowMap.renderList;
  45375. // Clean up existing data.
  45376. this._disposeRTTandPostProcesses();
  45377. // Reinitializes.
  45378. this._initializeGenerator();
  45379. // Reaffect the filter to ensure a correct fallback if necessary.
  45380. this.filter = this.filter;
  45381. // Reaffect the filter.
  45382. this._applyFilterValues();
  45383. // Reaffect Render List.
  45384. this._shadowMap.renderList = renderList;
  45385. };
  45386. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  45387. if (this._shadowMap2) {
  45388. this._shadowMap2.dispose();
  45389. this._shadowMap2 = null;
  45390. }
  45391. if (this._boxBlurPostprocess) {
  45392. this._boxBlurPostprocess.dispose();
  45393. this._boxBlurPostprocess = null;
  45394. }
  45395. if (this._kernelBlurXPostprocess) {
  45396. this._kernelBlurXPostprocess.dispose();
  45397. this._kernelBlurXPostprocess = null;
  45398. }
  45399. if (this._kernelBlurYPostprocess) {
  45400. this._kernelBlurYPostprocess.dispose();
  45401. this._kernelBlurYPostprocess = null;
  45402. }
  45403. this._blurPostProcesses = [];
  45404. };
  45405. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  45406. if (this._shadowMap) {
  45407. this._shadowMap.dispose();
  45408. this._shadowMap = null;
  45409. }
  45410. this._disposeBlurPostProcesses();
  45411. };
  45412. /**
  45413. * Disposes the ShadowGenerator.
  45414. * Returns nothing.
  45415. */
  45416. ShadowGenerator.prototype.dispose = function () {
  45417. this._disposeRTTandPostProcesses();
  45418. if (this._light) {
  45419. this._light._shadowGenerator = null;
  45420. this._light._markMeshesAsLightDirty();
  45421. }
  45422. };
  45423. /**
  45424. * Serializes the shadow generator setup to a json object.
  45425. * @returns The serialized JSON object
  45426. */
  45427. ShadowGenerator.prototype.serialize = function () {
  45428. var serializationObject = {};
  45429. var shadowMap = this.getShadowMap();
  45430. if (!shadowMap) {
  45431. return serializationObject;
  45432. }
  45433. serializationObject.lightId = this._light.id;
  45434. serializationObject.mapSize = shadowMap.getRenderSize();
  45435. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  45436. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  45437. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45438. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45439. serializationObject.usePoissonSampling = this.usePoissonSampling;
  45440. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  45441. serializationObject.depthScale = this.depthScale;
  45442. serializationObject.darkness = this.getDarkness();
  45443. serializationObject.blurBoxOffset = this.blurBoxOffset;
  45444. serializationObject.blurKernel = this.blurKernel;
  45445. serializationObject.blurScale = this.blurScale;
  45446. serializationObject.useKernelBlur = this.useKernelBlur;
  45447. serializationObject.transparencyShadow = this._transparencyShadow;
  45448. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  45449. serializationObject.bias = this.bias;
  45450. serializationObject.normalBias = this.normalBias;
  45451. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  45452. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  45453. serializationObject.filteringQuality = this.filteringQuality;
  45454. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  45455. serializationObject.renderList = [];
  45456. if (shadowMap.renderList) {
  45457. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  45458. var mesh = shadowMap.renderList[meshIndex];
  45459. serializationObject.renderList.push(mesh.id);
  45460. }
  45461. }
  45462. return serializationObject;
  45463. };
  45464. /**
  45465. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  45466. * @param parsedShadowGenerator The JSON object to parse
  45467. * @param scene The scene to create the shadow map for
  45468. * @returns The parsed shadow generator
  45469. */
  45470. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  45471. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  45472. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  45473. var shadowMap = shadowGenerator.getShadowMap();
  45474. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  45475. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  45476. meshes.forEach(function (mesh) {
  45477. if (!shadowMap) {
  45478. return;
  45479. }
  45480. if (!shadowMap.renderList) {
  45481. shadowMap.renderList = [];
  45482. }
  45483. shadowMap.renderList.push(mesh);
  45484. });
  45485. }
  45486. if (parsedShadowGenerator.usePoissonSampling) {
  45487. shadowGenerator.usePoissonSampling = true;
  45488. }
  45489. else if (parsedShadowGenerator.useExponentialShadowMap) {
  45490. shadowGenerator.useExponentialShadowMap = true;
  45491. }
  45492. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  45493. shadowGenerator.useBlurExponentialShadowMap = true;
  45494. }
  45495. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  45496. shadowGenerator.useCloseExponentialShadowMap = true;
  45497. }
  45498. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  45499. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  45500. }
  45501. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  45502. shadowGenerator.usePercentageCloserFiltering = true;
  45503. }
  45504. else if (parsedShadowGenerator.useContactHardeningShadow) {
  45505. shadowGenerator.useContactHardeningShadow = true;
  45506. }
  45507. if (parsedShadowGenerator.filteringQuality) {
  45508. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  45509. }
  45510. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  45511. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  45512. }
  45513. // Backward compat
  45514. else if (parsedShadowGenerator.useVarianceShadowMap) {
  45515. shadowGenerator.useExponentialShadowMap = true;
  45516. }
  45517. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  45518. shadowGenerator.useBlurExponentialShadowMap = true;
  45519. }
  45520. if (parsedShadowGenerator.depthScale) {
  45521. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  45522. }
  45523. if (parsedShadowGenerator.blurScale) {
  45524. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  45525. }
  45526. if (parsedShadowGenerator.blurBoxOffset) {
  45527. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  45528. }
  45529. if (parsedShadowGenerator.useKernelBlur) {
  45530. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  45531. }
  45532. if (parsedShadowGenerator.blurKernel) {
  45533. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  45534. }
  45535. if (parsedShadowGenerator.bias !== undefined) {
  45536. shadowGenerator.bias = parsedShadowGenerator.bias;
  45537. }
  45538. if (parsedShadowGenerator.normalBias !== undefined) {
  45539. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  45540. }
  45541. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  45542. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  45543. }
  45544. if (parsedShadowGenerator.darkness) {
  45545. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  45546. }
  45547. if (parsedShadowGenerator.transparencyShadow) {
  45548. shadowGenerator.setTransparencyShadow(true);
  45549. }
  45550. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  45551. return shadowGenerator;
  45552. };
  45553. /**
  45554. * Shadow generator mode None: no filtering applied.
  45555. */
  45556. ShadowGenerator.FILTER_NONE = 0;
  45557. /**
  45558. * Shadow generator mode ESM: Exponential Shadow Mapping.
  45559. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45560. */
  45561. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  45562. /**
  45563. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  45564. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  45565. */
  45566. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  45567. /**
  45568. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  45569. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45570. */
  45571. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  45572. /**
  45573. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  45574. * edge artifacts on steep falloff.
  45575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45576. */
  45577. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  45578. /**
  45579. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  45580. * edge artifacts on steep falloff.
  45581. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45582. */
  45583. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  45584. /**
  45585. * Shadow generator mode PCF: Percentage Closer Filtering
  45586. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45587. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  45588. */
  45589. ShadowGenerator.FILTER_PCF = 6;
  45590. /**
  45591. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  45592. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45593. * Contact Hardening
  45594. */
  45595. ShadowGenerator.FILTER_PCSS = 7;
  45596. /**
  45597. * Reserved for PCF and PCSS
  45598. * Highest Quality.
  45599. *
  45600. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  45601. *
  45602. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  45603. */
  45604. ShadowGenerator.QUALITY_HIGH = 0;
  45605. /**
  45606. * Reserved for PCF and PCSS
  45607. * Good tradeoff for quality/perf cross devices
  45608. *
  45609. * Execute PCF on a 3*3 kernel.
  45610. *
  45611. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  45612. */
  45613. ShadowGenerator.QUALITY_MEDIUM = 1;
  45614. /**
  45615. * Reserved for PCF and PCSS
  45616. * The lowest quality but the fastest.
  45617. *
  45618. * Execute PCF on a 1*1 kernel.
  45619. *
  45620. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  45621. */
  45622. ShadowGenerator.QUALITY_LOW = 2;
  45623. /** @hidden */
  45624. ShadowGenerator._SceneComponentInitialization = function (_) {
  45625. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  45626. };
  45627. return ShadowGenerator;
  45628. }());
  45629. /***/ }),
  45630. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  45631. /*!*********************************************************!*\
  45632. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  45633. \*********************************************************/
  45634. /*! exports provided: ShadowGeneratorSceneComponent */
  45635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45636. "use strict";
  45637. __webpack_require__.r(__webpack_exports__);
  45638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  45639. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45640. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  45641. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  45642. // Adds the parser to the scene parsers.
  45643. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  45644. // Shadows
  45645. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  45646. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  45647. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  45648. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  45649. // SG would be available on their associated lights
  45650. }
  45651. }
  45652. });
  45653. /**
  45654. * Defines the shadow generator component responsible to manage any shadow generators
  45655. * in a given scene.
  45656. */
  45657. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  45658. /**
  45659. * Creates a new instance of the component for the given scene
  45660. * @param scene Defines the scene to register the component in
  45661. */
  45662. function ShadowGeneratorSceneComponent(scene) {
  45663. /**
  45664. * The component name helpfull to identify the component in the list of scene components.
  45665. */
  45666. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  45667. this.scene = scene;
  45668. }
  45669. /**
  45670. * Registers the component in a given scene
  45671. */
  45672. ShadowGeneratorSceneComponent.prototype.register = function () {
  45673. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  45674. };
  45675. /**
  45676. * Rebuilds the elements related to this component in case of
  45677. * context lost for instance.
  45678. */
  45679. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  45680. // Nothing To Do Here.
  45681. };
  45682. /**
  45683. * Serializes the component data to the specified json object
  45684. * @param serializationObject The object to serialize to
  45685. */
  45686. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  45687. // Shadows
  45688. serializationObject.shadowGenerators = [];
  45689. var lights = this.scene.lights;
  45690. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  45691. var light = lights_1[_i];
  45692. var shadowGenerator = light.getShadowGenerator();
  45693. if (shadowGenerator) {
  45694. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  45695. }
  45696. }
  45697. };
  45698. /**
  45699. * Adds all the element from the container to the scene
  45700. * @param container the container holding the elements
  45701. */
  45702. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  45703. // Nothing To Do Here. (directly attached to a light)
  45704. };
  45705. /**
  45706. * Removes all the elements in the container from the scene
  45707. * @param container contains the elements to remove
  45708. */
  45709. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  45710. // Nothing To Do Here. (directly attached to a light)
  45711. };
  45712. /**
  45713. * Rebuilds the elements related to this component in case of
  45714. * context lost for instance.
  45715. */
  45716. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  45717. // Nothing To Do Here.
  45718. };
  45719. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  45720. // Shadows
  45721. var scene = this.scene;
  45722. if (this.scene.shadowsEnabled) {
  45723. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  45724. var light = scene.lights[lightIndex];
  45725. var shadowGenerator = light.getShadowGenerator();
  45726. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  45727. var shadowMap = (shadowGenerator.getShadowMap());
  45728. if (scene.textures.indexOf(shadowMap) !== -1) {
  45729. renderTargets.push(shadowMap);
  45730. }
  45731. }
  45732. }
  45733. }
  45734. };
  45735. return ShadowGeneratorSceneComponent;
  45736. }());
  45737. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  45738. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  45739. if (!component) {
  45740. component = new ShadowGeneratorSceneComponent(scene);
  45741. scene._addComponent(component);
  45742. }
  45743. };
  45744. /***/ }),
  45745. /***/ "./Lights/directionalLight.ts":
  45746. /*!************************************!*\
  45747. !*** ./Lights/directionalLight.ts ***!
  45748. \************************************/
  45749. /*! exports provided: DirectionalLight */
  45750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45751. "use strict";
  45752. __webpack_require__.r(__webpack_exports__);
  45753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  45754. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45755. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45756. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45757. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45758. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45759. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45760. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  45761. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45762. });
  45763. /**
  45764. * A directional light is defined by a direction (what a surprise!).
  45765. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45766. * 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.
  45767. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45768. */
  45769. var DirectionalLight = /** @class */ (function (_super) {
  45770. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  45771. /**
  45772. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45773. * The directional light is emitted from everywhere in the given direction.
  45774. * It can cast shadows.
  45775. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45776. * @param name The friendly name of the light
  45777. * @param direction The direction of the light
  45778. * @param scene The scene the light belongs to
  45779. */
  45780. function DirectionalLight(name, direction, scene) {
  45781. var _this = _super.call(this, name, scene) || this;
  45782. _this._shadowFrustumSize = 0;
  45783. _this._shadowOrthoScale = 0.1;
  45784. /**
  45785. * Automatically compute the projection matrix to best fit (including all the casters)
  45786. * on each frame.
  45787. */
  45788. _this.autoUpdateExtends = true;
  45789. // Cache
  45790. _this._orthoLeft = Number.MAX_VALUE;
  45791. _this._orthoRight = Number.MIN_VALUE;
  45792. _this._orthoTop = Number.MIN_VALUE;
  45793. _this._orthoBottom = Number.MAX_VALUE;
  45794. _this.position = direction.scale(-1.0);
  45795. _this.direction = direction;
  45796. return _this;
  45797. }
  45798. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  45799. /**
  45800. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45801. */
  45802. get: function () {
  45803. return this._shadowFrustumSize;
  45804. },
  45805. /**
  45806. * Specifies a fix frustum size for the shadow generation.
  45807. */
  45808. set: function (value) {
  45809. this._shadowFrustumSize = value;
  45810. this.forceProjectionMatrixCompute();
  45811. },
  45812. enumerable: true,
  45813. configurable: true
  45814. });
  45815. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  45816. /**
  45817. * Gets the shadow projection scale against the optimal computed one.
  45818. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45819. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45820. */
  45821. get: function () {
  45822. return this._shadowOrthoScale;
  45823. },
  45824. /**
  45825. * Sets the shadow projection scale against the optimal computed one.
  45826. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45827. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45828. */
  45829. set: function (value) {
  45830. this._shadowOrthoScale = value;
  45831. this.forceProjectionMatrixCompute();
  45832. },
  45833. enumerable: true,
  45834. configurable: true
  45835. });
  45836. /**
  45837. * Returns the string "DirectionalLight".
  45838. * @return The class name
  45839. */
  45840. DirectionalLight.prototype.getClassName = function () {
  45841. return "DirectionalLight";
  45842. };
  45843. /**
  45844. * Returns the integer 1.
  45845. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45846. */
  45847. DirectionalLight.prototype.getTypeID = function () {
  45848. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  45849. };
  45850. /**
  45851. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45852. * Returns the DirectionalLight Shadow projection matrix.
  45853. */
  45854. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45855. if (this.shadowFrustumSize > 0) {
  45856. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  45857. }
  45858. else {
  45859. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  45860. }
  45861. };
  45862. /**
  45863. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45864. * Returns the DirectionalLight Shadow projection matrix.
  45865. */
  45866. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  45867. var activeCamera = this.getScene().activeCamera;
  45868. if (!activeCamera) {
  45869. return;
  45870. }
  45871. _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);
  45872. };
  45873. /**
  45874. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45875. * Returns the DirectionalLight Shadow projection matrix.
  45876. */
  45877. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45878. var activeCamera = this.getScene().activeCamera;
  45879. if (!activeCamera) {
  45880. return;
  45881. }
  45882. // Check extends
  45883. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  45884. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45885. this._orthoLeft = Number.MAX_VALUE;
  45886. this._orthoRight = Number.MIN_VALUE;
  45887. this._orthoTop = Number.MIN_VALUE;
  45888. this._orthoBottom = Number.MAX_VALUE;
  45889. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  45890. var mesh = renderList[meshIndex];
  45891. if (!mesh) {
  45892. continue;
  45893. }
  45894. var boundingInfo = mesh.getBoundingInfo();
  45895. var boundingBox = boundingInfo.boundingBox;
  45896. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  45897. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  45898. if (tempVector3.x < this._orthoLeft) {
  45899. this._orthoLeft = tempVector3.x;
  45900. }
  45901. if (tempVector3.y < this._orthoBottom) {
  45902. this._orthoBottom = tempVector3.y;
  45903. }
  45904. if (tempVector3.x > this._orthoRight) {
  45905. this._orthoRight = tempVector3.x;
  45906. }
  45907. if (tempVector3.y > this._orthoTop) {
  45908. this._orthoTop = tempVector3.y;
  45909. }
  45910. }
  45911. }
  45912. }
  45913. var xOffset = this._orthoRight - this._orthoLeft;
  45914. var yOffset = this._orthoTop - this._orthoBottom;
  45915. _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);
  45916. };
  45917. DirectionalLight.prototype._buildUniformLayout = function () {
  45918. this._uniformBuffer.addUniform("vLightData", 4);
  45919. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45920. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45921. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45922. this._uniformBuffer.addUniform("depthValues", 2);
  45923. this._uniformBuffer.create();
  45924. };
  45925. /**
  45926. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45927. * @param effect The effect to update
  45928. * @param lightIndex The index of the light in the effect to update
  45929. * @returns The directional light
  45930. */
  45931. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  45932. if (this.computeTransformedInformation()) {
  45933. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  45934. return this;
  45935. }
  45936. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  45937. return this;
  45938. };
  45939. /**
  45940. * Gets the minZ used for shadow according to both the scene and the light.
  45941. *
  45942. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45943. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45944. * @param activeCamera The camera we are returning the min for
  45945. * @returns the depth min z
  45946. */
  45947. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  45948. return 1;
  45949. };
  45950. /**
  45951. * Gets the maxZ used for shadow according to both the scene and the light.
  45952. *
  45953. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45954. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45955. * @param activeCamera The camera we are returning the max for
  45956. * @returns the depth max z
  45957. */
  45958. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  45959. return 1;
  45960. };
  45961. /**
  45962. * Prepares the list of defines specific to the light type.
  45963. * @param defines the list of defines
  45964. * @param lightIndex defines the index of the light for the effect
  45965. */
  45966. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45967. defines["DIRLIGHT" + lightIndex] = true;
  45968. };
  45969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45971. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  45972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45974. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  45975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45977. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  45978. return DirectionalLight;
  45979. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  45980. /***/ }),
  45981. /***/ "./Lights/hemisphericLight.ts":
  45982. /*!************************************!*\
  45983. !*** ./Lights/hemisphericLight.ts ***!
  45984. \************************************/
  45985. /*! exports provided: HemisphericLight */
  45986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45987. "use strict";
  45988. __webpack_require__.r(__webpack_exports__);
  45989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  45990. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45991. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45992. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45993. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45994. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45995. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  45996. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45997. });
  45998. /**
  45999. * The HemisphericLight simulates the ambient environment light,
  46000. * so the passed direction is the light reflection direction, not the incoming direction.
  46001. */
  46002. var HemisphericLight = /** @class */ (function (_super) {
  46003. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  46004. /**
  46005. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  46006. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  46007. * The HemisphericLight can't cast shadows.
  46008. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46009. * @param name The friendly name of the light
  46010. * @param direction The direction of the light reflection
  46011. * @param scene The scene the light belongs to
  46012. */
  46013. function HemisphericLight(name, direction, scene) {
  46014. var _this = _super.call(this, name, scene) || this;
  46015. /**
  46016. * The groundColor is the light in the opposite direction to the one specified during creation.
  46017. * 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.
  46018. */
  46019. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  46020. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46021. return _this;
  46022. }
  46023. HemisphericLight.prototype._buildUniformLayout = function () {
  46024. this._uniformBuffer.addUniform("vLightData", 4);
  46025. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46026. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46027. this._uniformBuffer.addUniform("vLightGround", 3);
  46028. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46029. this._uniformBuffer.addUniform("depthValues", 2);
  46030. this._uniformBuffer.create();
  46031. };
  46032. /**
  46033. * Returns the string "HemisphericLight".
  46034. * @return The class name
  46035. */
  46036. HemisphericLight.prototype.getClassName = function () {
  46037. return "HemisphericLight";
  46038. };
  46039. /**
  46040. * Sets the HemisphericLight direction towards the passed target (Vector3).
  46041. * Returns the updated direction.
  46042. * @param target The target the direction should point to
  46043. * @return The computed direction
  46044. */
  46045. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  46046. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  46047. return this.direction;
  46048. };
  46049. /**
  46050. * Returns the shadow generator associated to the light.
  46051. * @returns Always null for hemispheric lights because it does not support shadows.
  46052. */
  46053. HemisphericLight.prototype.getShadowGenerator = function () {
  46054. return null;
  46055. };
  46056. /**
  46057. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  46058. * @param effect The effect to update
  46059. * @param lightIndex The index of the light in the effect to update
  46060. * @returns The hemispheric light
  46061. */
  46062. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  46063. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46064. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  46065. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  46066. return this;
  46067. };
  46068. /**
  46069. * Computes the world matrix of the node
  46070. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46071. * @param useWasUpdatedFlag defines a reserved property
  46072. * @returns the world matrix
  46073. */
  46074. HemisphericLight.prototype.computeWorldMatrix = function () {
  46075. if (!this._worldMatrix) {
  46076. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46077. }
  46078. return this._worldMatrix;
  46079. };
  46080. /**
  46081. * Returns the integer 3.
  46082. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46083. */
  46084. HemisphericLight.prototype.getTypeID = function () {
  46085. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  46086. };
  46087. /**
  46088. * Prepares the list of defines specific to the light type.
  46089. * @param defines the list of defines
  46090. * @param lightIndex defines the index of the light for the effect
  46091. */
  46092. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46093. defines["HEMILIGHT" + lightIndex] = true;
  46094. };
  46095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46097. ], HemisphericLight.prototype, "groundColor", void 0);
  46098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46100. ], HemisphericLight.prototype, "direction", void 0);
  46101. return HemisphericLight;
  46102. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  46103. /***/ }),
  46104. /***/ "./Lights/index.ts":
  46105. /*!*************************!*\
  46106. !*** ./Lights/index.ts ***!
  46107. \*************************/
  46108. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  46109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46110. "use strict";
  46111. __webpack_require__.r(__webpack_exports__);
  46112. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  46114. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  46116. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  46117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  46118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  46119. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  46120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46121. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46123. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46125. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46127. /***/ }),
  46128. /***/ "./Lights/light.ts":
  46129. /*!*************************!*\
  46130. !*** ./Lights/light.ts ***!
  46131. \*************************/
  46132. /*! exports provided: Light */
  46133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46134. "use strict";
  46135. __webpack_require__.r(__webpack_exports__);
  46136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46138. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46139. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46140. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46141. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46142. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46143. /**
  46144. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46145. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46146. * 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.
  46147. */
  46148. var Light = /** @class */ (function (_super) {
  46149. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46150. /**
  46151. * Creates a Light object in the scene.
  46152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46153. * @param name The firendly name of the light
  46154. * @param scene The scene the light belongs too
  46155. */
  46156. function Light(name, scene) {
  46157. var _this = _super.call(this, name, scene) || this;
  46158. /**
  46159. * Diffuse gives the basic color to an object.
  46160. */
  46161. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46162. /**
  46163. * Specular produces a highlight color on an object.
  46164. * Note: This is note affecting PBR materials.
  46165. */
  46166. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46167. /**
  46168. * Defines the falloff type for this light. This lets overrriding how punctual light are
  46169. * falling off base on range or angle.
  46170. * This can be set to any values in Light.FALLOFF_x.
  46171. *
  46172. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  46173. * other types of materials.
  46174. */
  46175. _this.falloffType = Light.FALLOFF_DEFAULT;
  46176. /**
  46177. * Strength of the light.
  46178. * Note: By default it is define in the framework own unit.
  46179. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  46180. */
  46181. _this.intensity = 1.0;
  46182. _this._range = Number.MAX_VALUE;
  46183. _this._inverseSquaredRange = 0;
  46184. /**
  46185. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  46186. * of light.
  46187. */
  46188. _this._photometricScale = 1.0;
  46189. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  46190. _this._radius = 0.00001;
  46191. /**
  46192. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  46193. * exceeding the number allowed of the materials.
  46194. */
  46195. _this.renderPriority = 0;
  46196. _this._shadowEnabled = true;
  46197. _this._excludeWithLayerMask = 0;
  46198. _this._includeOnlyWithLayerMask = 0;
  46199. _this._lightmapMode = 0;
  46200. /**
  46201. * @hidden Internal use only.
  46202. */
  46203. _this._excludedMeshesIds = new Array();
  46204. /**
  46205. * @hidden Internal use only.
  46206. */
  46207. _this._includedOnlyMeshesIds = new Array();
  46208. /** @hidden */
  46209. _this._isLight = true;
  46210. _this.getScene().addLight(_this);
  46211. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  46212. _this._buildUniformLayout();
  46213. _this.includedOnlyMeshes = new Array();
  46214. _this.excludedMeshes = new Array();
  46215. _this._resyncMeshes();
  46216. return _this;
  46217. }
  46218. Object.defineProperty(Light.prototype, "range", {
  46219. /**
  46220. * Defines how far from the source the light is impacting in scene units.
  46221. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46222. */
  46223. get: function () {
  46224. return this._range;
  46225. },
  46226. /**
  46227. * Defines how far from the source the light is impacting in scene units.
  46228. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46229. */
  46230. set: function (value) {
  46231. this._range = value;
  46232. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  46233. },
  46234. enumerable: true,
  46235. configurable: true
  46236. });
  46237. Object.defineProperty(Light.prototype, "intensityMode", {
  46238. /**
  46239. * Gets the photometric scale used to interpret the intensity.
  46240. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46241. */
  46242. get: function () {
  46243. return this._intensityMode;
  46244. },
  46245. /**
  46246. * Sets the photometric scale used to interpret the intensity.
  46247. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46248. */
  46249. set: function (value) {
  46250. this._intensityMode = value;
  46251. this._computePhotometricScale();
  46252. },
  46253. enumerable: true,
  46254. configurable: true
  46255. });
  46256. Object.defineProperty(Light.prototype, "radius", {
  46257. /**
  46258. * Gets the light radius used by PBR Materials to simulate soft area lights.
  46259. */
  46260. get: function () {
  46261. return this._radius;
  46262. },
  46263. /**
  46264. * sets the light radius used by PBR Materials to simulate soft area lights.
  46265. */
  46266. set: function (value) {
  46267. this._radius = value;
  46268. this._computePhotometricScale();
  46269. },
  46270. enumerable: true,
  46271. configurable: true
  46272. });
  46273. Object.defineProperty(Light.prototype, "shadowEnabled", {
  46274. /**
  46275. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46276. * the current shadow generator.
  46277. */
  46278. get: function () {
  46279. return this._shadowEnabled;
  46280. },
  46281. /**
  46282. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46283. * the current shadow generator.
  46284. */
  46285. set: function (value) {
  46286. if (this._shadowEnabled === value) {
  46287. return;
  46288. }
  46289. this._shadowEnabled = value;
  46290. this._markMeshesAsLightDirty();
  46291. },
  46292. enumerable: true,
  46293. configurable: true
  46294. });
  46295. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46296. /**
  46297. * Gets the only meshes impacted by this light.
  46298. */
  46299. get: function () {
  46300. return this._includedOnlyMeshes;
  46301. },
  46302. /**
  46303. * Sets the only meshes impacted by this light.
  46304. */
  46305. set: function (value) {
  46306. this._includedOnlyMeshes = value;
  46307. this._hookArrayForIncludedOnly(value);
  46308. },
  46309. enumerable: true,
  46310. configurable: true
  46311. });
  46312. Object.defineProperty(Light.prototype, "excludedMeshes", {
  46313. /**
  46314. * Gets the meshes not impacted by this light.
  46315. */
  46316. get: function () {
  46317. return this._excludedMeshes;
  46318. },
  46319. /**
  46320. * Sets the meshes not impacted by this light.
  46321. */
  46322. set: function (value) {
  46323. this._excludedMeshes = value;
  46324. this._hookArrayForExcluded(value);
  46325. },
  46326. enumerable: true,
  46327. configurable: true
  46328. });
  46329. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  46330. /**
  46331. * Gets the layer id use to find what meshes are not impacted by the light.
  46332. * Inactive if 0
  46333. */
  46334. get: function () {
  46335. return this._excludeWithLayerMask;
  46336. },
  46337. /**
  46338. * Sets the layer id use to find what meshes are not impacted by the light.
  46339. * Inactive if 0
  46340. */
  46341. set: function (value) {
  46342. this._excludeWithLayerMask = value;
  46343. this._resyncMeshes();
  46344. },
  46345. enumerable: true,
  46346. configurable: true
  46347. });
  46348. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  46349. /**
  46350. * Gets the layer id use to find what meshes are impacted by the light.
  46351. * Inactive if 0
  46352. */
  46353. get: function () {
  46354. return this._includeOnlyWithLayerMask;
  46355. },
  46356. /**
  46357. * Sets the layer id use to find what meshes are impacted by the light.
  46358. * Inactive if 0
  46359. */
  46360. set: function (value) {
  46361. this._includeOnlyWithLayerMask = value;
  46362. this._resyncMeshes();
  46363. },
  46364. enumerable: true,
  46365. configurable: true
  46366. });
  46367. Object.defineProperty(Light.prototype, "lightmapMode", {
  46368. /**
  46369. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46370. */
  46371. get: function () {
  46372. return this._lightmapMode;
  46373. },
  46374. /**
  46375. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46376. */
  46377. set: function (value) {
  46378. if (this._lightmapMode === value) {
  46379. return;
  46380. }
  46381. this._lightmapMode = value;
  46382. this._markMeshesAsLightDirty();
  46383. },
  46384. enumerable: true,
  46385. configurable: true
  46386. });
  46387. /**
  46388. * Returns the string "Light".
  46389. * @returns the class name
  46390. */
  46391. Light.prototype.getClassName = function () {
  46392. return "Light";
  46393. };
  46394. /**
  46395. * Converts the light information to a readable string for debug purpose.
  46396. * @param fullDetails Supports for multiple levels of logging within scene loading
  46397. * @returns the human readable light info
  46398. */
  46399. Light.prototype.toString = function (fullDetails) {
  46400. var ret = "Name: " + this.name;
  46401. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  46402. if (this.animations) {
  46403. for (var i = 0; i < this.animations.length; i++) {
  46404. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  46405. }
  46406. }
  46407. if (fullDetails) {
  46408. }
  46409. return ret;
  46410. };
  46411. /** @hidden */
  46412. Light.prototype._syncParentEnabledState = function () {
  46413. _super.prototype._syncParentEnabledState.call(this);
  46414. this._resyncMeshes();
  46415. };
  46416. /**
  46417. * Set the enabled state of this node.
  46418. * @param value - the new enabled state
  46419. */
  46420. Light.prototype.setEnabled = function (value) {
  46421. _super.prototype.setEnabled.call(this, value);
  46422. this._resyncMeshes();
  46423. };
  46424. /**
  46425. * Returns the Light associated shadow generator if any.
  46426. * @return the associated shadow generator.
  46427. */
  46428. Light.prototype.getShadowGenerator = function () {
  46429. return this._shadowGenerator;
  46430. };
  46431. /**
  46432. * Returns a Vector3, the absolute light position in the World.
  46433. * @returns the world space position of the light
  46434. */
  46435. Light.prototype.getAbsolutePosition = function () {
  46436. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46437. };
  46438. /**
  46439. * Specifies if the light will affect the passed mesh.
  46440. * @param mesh The mesh to test against the light
  46441. * @return true the mesh is affected otherwise, false.
  46442. */
  46443. Light.prototype.canAffectMesh = function (mesh) {
  46444. if (!mesh) {
  46445. return true;
  46446. }
  46447. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  46448. return false;
  46449. }
  46450. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  46451. return false;
  46452. }
  46453. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  46454. return false;
  46455. }
  46456. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  46457. return false;
  46458. }
  46459. return true;
  46460. };
  46461. /**
  46462. * Sort function to order lights for rendering.
  46463. * @param a First Light object to compare to second.
  46464. * @param b Second Light object to compare first.
  46465. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  46466. */
  46467. Light.CompareLightsPriority = function (a, b) {
  46468. //shadow-casting lights have priority over non-shadow-casting lights
  46469. //the renderPrioirty is a secondary sort criterion
  46470. if (a.shadowEnabled !== b.shadowEnabled) {
  46471. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  46472. }
  46473. return b.renderPriority - a.renderPriority;
  46474. };
  46475. /**
  46476. * Releases resources associated with this node.
  46477. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46478. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46479. */
  46480. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  46481. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  46482. if (this._shadowGenerator) {
  46483. this._shadowGenerator.dispose();
  46484. this._shadowGenerator = null;
  46485. }
  46486. // Animations
  46487. this.getScene().stopAnimation(this);
  46488. // Remove from meshes
  46489. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46490. var mesh = _a[_i];
  46491. mesh._removeLightSource(this);
  46492. }
  46493. this._uniformBuffer.dispose();
  46494. // Remove from scene
  46495. this.getScene().removeLight(this);
  46496. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  46497. };
  46498. /**
  46499. * Returns the light type ID (integer).
  46500. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46501. */
  46502. Light.prototype.getTypeID = function () {
  46503. return 0;
  46504. };
  46505. /**
  46506. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  46507. * @returns the scaled intensity in intensity mode unit
  46508. */
  46509. Light.prototype.getScaledIntensity = function () {
  46510. return this._photometricScale * this.intensity;
  46511. };
  46512. /**
  46513. * Returns a new Light object, named "name", from the current one.
  46514. * @param name The name of the cloned light
  46515. * @returns the new created light
  46516. */
  46517. Light.prototype.clone = function (name) {
  46518. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  46519. if (!constructor) {
  46520. return null;
  46521. }
  46522. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  46523. };
  46524. /**
  46525. * Serializes the current light into a Serialization object.
  46526. * @returns the serialized object.
  46527. */
  46528. Light.prototype.serialize = function () {
  46529. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  46530. // Type
  46531. serializationObject.type = this.getTypeID();
  46532. // Parent
  46533. if (this.parent) {
  46534. serializationObject.parentId = this.parent.id;
  46535. }
  46536. // Inclusion / exclusions
  46537. if (this.excludedMeshes.length > 0) {
  46538. serializationObject.excludedMeshesIds = [];
  46539. this.excludedMeshes.forEach(function (mesh) {
  46540. serializationObject.excludedMeshesIds.push(mesh.id);
  46541. });
  46542. }
  46543. if (this.includedOnlyMeshes.length > 0) {
  46544. serializationObject.includedOnlyMeshesIds = [];
  46545. this.includedOnlyMeshes.forEach(function (mesh) {
  46546. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  46547. });
  46548. }
  46549. // Animations
  46550. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  46551. serializationObject.ranges = this.serializeAnimationRanges();
  46552. return serializationObject;
  46553. };
  46554. /**
  46555. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  46556. * This new light is named "name" and added to the passed scene.
  46557. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  46558. * @param name The friendly name of the light
  46559. * @param scene The scene the new light will belong to
  46560. * @returns the constructor function
  46561. */
  46562. Light.GetConstructorFromName = function (type, name, scene) {
  46563. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  46564. if (constructorFunc) {
  46565. return constructorFunc;
  46566. }
  46567. // Default to no light for none present once.
  46568. return null;
  46569. };
  46570. /**
  46571. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  46572. * @param parsedLight The JSON representation of the light
  46573. * @param scene The scene to create the parsed light in
  46574. * @returns the created light after parsing
  46575. */
  46576. Light.Parse = function (parsedLight, scene) {
  46577. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  46578. if (!constructor) {
  46579. return null;
  46580. }
  46581. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  46582. // Inclusion / exclusions
  46583. if (parsedLight.excludedMeshesIds) {
  46584. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  46585. }
  46586. if (parsedLight.includedOnlyMeshesIds) {
  46587. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  46588. }
  46589. // Parent
  46590. if (parsedLight.parentId) {
  46591. light._waitingParentId = parsedLight.parentId;
  46592. }
  46593. // Animations
  46594. if (parsedLight.animations) {
  46595. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  46596. var parsedAnimation = parsedLight.animations[animationIndex];
  46597. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  46598. if (internalClass) {
  46599. light.animations.push(internalClass.Parse(parsedAnimation));
  46600. }
  46601. }
  46602. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  46603. }
  46604. if (parsedLight.autoAnimate) {
  46605. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  46606. }
  46607. return light;
  46608. };
  46609. Light.prototype._hookArrayForExcluded = function (array) {
  46610. var _this = this;
  46611. var oldPush = array.push;
  46612. array.push = function () {
  46613. var items = [];
  46614. for (var _i = 0; _i < arguments.length; _i++) {
  46615. items[_i] = arguments[_i];
  46616. }
  46617. var result = oldPush.apply(array, items);
  46618. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  46619. var item = items_1[_a];
  46620. item._resyncLighSource(_this);
  46621. }
  46622. return result;
  46623. };
  46624. var oldSplice = array.splice;
  46625. array.splice = function (index, deleteCount) {
  46626. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46627. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  46628. var item = deleted_1[_i];
  46629. item._resyncLighSource(_this);
  46630. }
  46631. return deleted;
  46632. };
  46633. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  46634. var item = array_1[_i];
  46635. item._resyncLighSource(this);
  46636. }
  46637. };
  46638. Light.prototype._hookArrayForIncludedOnly = function (array) {
  46639. var _this = this;
  46640. var oldPush = array.push;
  46641. array.push = function () {
  46642. var items = [];
  46643. for (var _i = 0; _i < arguments.length; _i++) {
  46644. items[_i] = arguments[_i];
  46645. }
  46646. var result = oldPush.apply(array, items);
  46647. _this._resyncMeshes();
  46648. return result;
  46649. };
  46650. var oldSplice = array.splice;
  46651. array.splice = function (index, deleteCount) {
  46652. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46653. _this._resyncMeshes();
  46654. return deleted;
  46655. };
  46656. this._resyncMeshes();
  46657. };
  46658. Light.prototype._resyncMeshes = function () {
  46659. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46660. var mesh = _a[_i];
  46661. mesh._resyncLighSource(this);
  46662. }
  46663. };
  46664. /**
  46665. * Forces the meshes to update their light related information in their rendering used effects
  46666. * @hidden Internal Use Only
  46667. */
  46668. Light.prototype._markMeshesAsLightDirty = function () {
  46669. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46670. var mesh = _a[_i];
  46671. if (mesh._lightSources.indexOf(this) !== -1) {
  46672. mesh._markSubMeshesAsLightDirty();
  46673. }
  46674. }
  46675. };
  46676. /**
  46677. * Recomputes the cached photometric scale if needed.
  46678. */
  46679. Light.prototype._computePhotometricScale = function () {
  46680. this._photometricScale = this._getPhotometricScale();
  46681. this.getScene().resetCachedMaterial();
  46682. };
  46683. /**
  46684. * Returns the Photometric Scale according to the light type and intensity mode.
  46685. */
  46686. Light.prototype._getPhotometricScale = function () {
  46687. var photometricScale = 0.0;
  46688. var lightTypeID = this.getTypeID();
  46689. //get photometric mode
  46690. var photometricMode = this.intensityMode;
  46691. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  46692. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  46693. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  46694. }
  46695. else {
  46696. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  46697. }
  46698. }
  46699. //compute photometric scale
  46700. switch (lightTypeID) {
  46701. case Light.LIGHTTYPEID_POINTLIGHT:
  46702. case Light.LIGHTTYPEID_SPOTLIGHT:
  46703. switch (photometricMode) {
  46704. case Light.INTENSITYMODE_LUMINOUSPOWER:
  46705. photometricScale = 1.0 / (4.0 * Math.PI);
  46706. break;
  46707. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  46708. photometricScale = 1.0;
  46709. break;
  46710. case Light.INTENSITYMODE_LUMINANCE:
  46711. photometricScale = this.radius * this.radius;
  46712. break;
  46713. }
  46714. break;
  46715. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  46716. switch (photometricMode) {
  46717. case Light.INTENSITYMODE_ILLUMINANCE:
  46718. photometricScale = 1.0;
  46719. break;
  46720. case Light.INTENSITYMODE_LUMINANCE:
  46721. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  46722. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  46723. var apexAngleRadians = this.radius;
  46724. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  46725. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  46726. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  46727. photometricScale = solidAngle;
  46728. break;
  46729. }
  46730. break;
  46731. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  46732. // No fall off in hemisperic light.
  46733. photometricScale = 1.0;
  46734. break;
  46735. }
  46736. return photometricScale;
  46737. };
  46738. /**
  46739. * Reorder the light in the scene according to their defined priority.
  46740. * @hidden Internal Use Only
  46741. */
  46742. Light.prototype._reorderLightsInScene = function () {
  46743. var scene = this.getScene();
  46744. if (this._renderPriority != 0) {
  46745. scene.requireLightSorting = true;
  46746. }
  46747. this.getScene().sortLightsByPriority();
  46748. };
  46749. /**
  46750. * Falloff Default: light is falling off following the material specification:
  46751. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  46752. */
  46753. Light.FALLOFF_DEFAULT = 0;
  46754. /**
  46755. * Falloff Physical: light is falling off following the inverse squared distance law.
  46756. */
  46757. Light.FALLOFF_PHYSICAL = 1;
  46758. /**
  46759. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  46760. * to enhance interoperability with other engines.
  46761. */
  46762. Light.FALLOFF_GLTF = 2;
  46763. /**
  46764. * Falloff Standard: light is falling off like in the standard material
  46765. * to enhance interoperability with other materials.
  46766. */
  46767. Light.FALLOFF_STANDARD = 3;
  46768. //lightmapMode Consts
  46769. /**
  46770. * If every light affecting the material is in this lightmapMode,
  46771. * material.lightmapTexture adds or multiplies
  46772. * (depends on material.useLightmapAsShadowmap)
  46773. * after every other light calculations.
  46774. */
  46775. Light.LIGHTMAP_DEFAULT = 0;
  46776. /**
  46777. * material.lightmapTexture as only diffuse lighting from this light
  46778. * adds only specular lighting from this light
  46779. * adds dynamic shadows
  46780. */
  46781. Light.LIGHTMAP_SPECULAR = 1;
  46782. /**
  46783. * material.lightmapTexture as only lighting
  46784. * no light calculation from this light
  46785. * only adds dynamic shadows from this light
  46786. */
  46787. Light.LIGHTMAP_SHADOWSONLY = 2;
  46788. // Intensity Mode Consts
  46789. /**
  46790. * Each light type uses the default quantity according to its type:
  46791. * point/spot lights use luminous intensity
  46792. * directional lights use illuminance
  46793. */
  46794. Light.INTENSITYMODE_AUTOMATIC = 0;
  46795. /**
  46796. * lumen (lm)
  46797. */
  46798. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  46799. /**
  46800. * candela (lm/sr)
  46801. */
  46802. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  46803. /**
  46804. * lux (lm/m^2)
  46805. */
  46806. Light.INTENSITYMODE_ILLUMINANCE = 3;
  46807. /**
  46808. * nit (cd/m^2)
  46809. */
  46810. Light.INTENSITYMODE_LUMINANCE = 4;
  46811. // Light types ids const.
  46812. /**
  46813. * Light type const id of the point light.
  46814. */
  46815. Light.LIGHTTYPEID_POINTLIGHT = 0;
  46816. /**
  46817. * Light type const id of the directional light.
  46818. */
  46819. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  46820. /**
  46821. * Light type const id of the spot light.
  46822. */
  46823. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  46824. /**
  46825. * Light type const id of the hemispheric light.
  46826. */
  46827. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  46828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46830. ], Light.prototype, "diffuse", void 0);
  46831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46833. ], Light.prototype, "specular", void 0);
  46834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46836. ], Light.prototype, "falloffType", void 0);
  46837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46839. ], Light.prototype, "intensity", void 0);
  46840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46842. ], Light.prototype, "range", null);
  46843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46845. ], Light.prototype, "intensityMode", null);
  46846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46848. ], Light.prototype, "radius", null);
  46849. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46851. ], Light.prototype, "_renderPriority", void 0);
  46852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  46854. ], Light.prototype, "renderPriority", void 0);
  46855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  46857. ], Light.prototype, "_shadowEnabled", void 0);
  46858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  46860. ], Light.prototype, "_excludeWithLayerMask", void 0);
  46861. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  46863. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  46864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  46866. ], Light.prototype, "_lightmapMode", void 0);
  46867. return Light;
  46868. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  46869. /***/ }),
  46870. /***/ "./Lights/pointLight.ts":
  46871. /*!******************************!*\
  46872. !*** ./Lights/pointLight.ts ***!
  46873. \******************************/
  46874. /*! exports provided: PointLight */
  46875. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46876. "use strict";
  46877. __webpack_require__.r(__webpack_exports__);
  46878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  46879. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46880. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46881. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46882. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46883. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46884. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46885. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  46886. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46887. });
  46888. /**
  46889. * A point light is a light defined by an unique point in world space.
  46890. * The light is emitted in every direction from this point.
  46891. * A good example of a point light is a standard light bulb.
  46892. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46893. */
  46894. var PointLight = /** @class */ (function (_super) {
  46895. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  46896. /**
  46897. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46898. * A PointLight emits the light in every direction.
  46899. * It can cast shadows.
  46900. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46901. * ```javascript
  46902. * var pointLight = new PointLight("pl", camera.position, scene);
  46903. * ```
  46904. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46905. * @param name The light friendly name
  46906. * @param position The position of the point light in the scene
  46907. * @param scene The scene the lights belongs to
  46908. */
  46909. function PointLight(name, position, scene) {
  46910. var _this = _super.call(this, name, scene) || this;
  46911. _this._shadowAngle = Math.PI / 2;
  46912. _this.position = position;
  46913. return _this;
  46914. }
  46915. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  46916. /**
  46917. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46918. * This specifies what angle the shadow will use to be created.
  46919. *
  46920. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46921. */
  46922. get: function () {
  46923. return this._shadowAngle;
  46924. },
  46925. /**
  46926. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46927. * This specifies what angle the shadow will use to be created.
  46928. *
  46929. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46930. */
  46931. set: function (value) {
  46932. this._shadowAngle = value;
  46933. this.forceProjectionMatrixCompute();
  46934. },
  46935. enumerable: true,
  46936. configurable: true
  46937. });
  46938. Object.defineProperty(PointLight.prototype, "direction", {
  46939. /**
  46940. * Gets the direction if it has been set.
  46941. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46942. */
  46943. get: function () {
  46944. return this._direction;
  46945. },
  46946. /**
  46947. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46948. */
  46949. set: function (value) {
  46950. var previousNeedCube = this.needCube();
  46951. this._direction = value;
  46952. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  46953. this._shadowGenerator.recreateShadowMap();
  46954. }
  46955. },
  46956. enumerable: true,
  46957. configurable: true
  46958. });
  46959. /**
  46960. * Returns the string "PointLight"
  46961. * @returns the class name
  46962. */
  46963. PointLight.prototype.getClassName = function () {
  46964. return "PointLight";
  46965. };
  46966. /**
  46967. * Returns the integer 0.
  46968. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46969. */
  46970. PointLight.prototype.getTypeID = function () {
  46971. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  46972. };
  46973. /**
  46974. * Specifies wether or not the shadowmap should be a cube texture.
  46975. * @returns true if the shadowmap needs to be a cube texture.
  46976. */
  46977. PointLight.prototype.needCube = function () {
  46978. return !this.direction;
  46979. };
  46980. /**
  46981. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46982. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46983. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46984. */
  46985. PointLight.prototype.getShadowDirection = function (faceIndex) {
  46986. if (this.direction) {
  46987. return _super.prototype.getShadowDirection.call(this, faceIndex);
  46988. }
  46989. else {
  46990. switch (faceIndex) {
  46991. case 0:
  46992. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  46993. case 1:
  46994. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  46995. case 2:
  46996. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  46997. case 3:
  46998. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  46999. case 4:
  47000. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  47001. case 5:
  47002. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  47003. }
  47004. }
  47005. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47006. };
  47007. /**
  47008. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47009. * - fov = PI / 2
  47010. * - aspect ratio : 1.0
  47011. * - z-near and far equal to the active camera minZ and maxZ.
  47012. * Returns the PointLight.
  47013. */
  47014. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47015. var activeCamera = this.getScene().activeCamera;
  47016. if (!activeCamera) {
  47017. return;
  47018. }
  47019. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47020. };
  47021. PointLight.prototype._buildUniformLayout = function () {
  47022. this._uniformBuffer.addUniform("vLightData", 4);
  47023. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47024. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47025. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47026. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47027. this._uniformBuffer.addUniform("depthValues", 2);
  47028. this._uniformBuffer.create();
  47029. };
  47030. /**
  47031. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47032. * @param effect The effect to update
  47033. * @param lightIndex The index of the light in the effect to update
  47034. * @returns The point light
  47035. */
  47036. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  47037. if (this.computeTransformedInformation()) {
  47038. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  47039. }
  47040. else {
  47041. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  47042. }
  47043. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  47044. return this;
  47045. };
  47046. /**
  47047. * Prepares the list of defines specific to the light type.
  47048. * @param defines the list of defines
  47049. * @param lightIndex defines the index of the light for the effect
  47050. */
  47051. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47052. defines["POINTLIGHT" + lightIndex] = true;
  47053. };
  47054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47056. ], PointLight.prototype, "shadowAngle", null);
  47057. return PointLight;
  47058. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47059. /***/ }),
  47060. /***/ "./Lights/shadowLight.ts":
  47061. /*!*******************************!*\
  47062. !*** ./Lights/shadowLight.ts ***!
  47063. \*******************************/
  47064. /*! exports provided: ShadowLight */
  47065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47066. "use strict";
  47067. __webpack_require__.r(__webpack_exports__);
  47068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  47069. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47070. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47071. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47072. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47073. /**
  47074. * Base implementation IShadowLight
  47075. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  47076. */
  47077. var ShadowLight = /** @class */ (function (_super) {
  47078. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  47079. function ShadowLight() {
  47080. var _this = _super !== null && _super.apply(this, arguments) || this;
  47081. _this._needProjectionMatrixCompute = true;
  47082. return _this;
  47083. }
  47084. ShadowLight.prototype._setPosition = function (value) {
  47085. this._position = value;
  47086. };
  47087. Object.defineProperty(ShadowLight.prototype, "position", {
  47088. /**
  47089. * Sets the position the shadow will be casted from. Also use as the light position for both
  47090. * point and spot lights.
  47091. */
  47092. get: function () {
  47093. return this._position;
  47094. },
  47095. /**
  47096. * Sets the position the shadow will be casted from. Also use as the light position for both
  47097. * point and spot lights.
  47098. */
  47099. set: function (value) {
  47100. this._setPosition(value);
  47101. },
  47102. enumerable: true,
  47103. configurable: true
  47104. });
  47105. ShadowLight.prototype._setDirection = function (value) {
  47106. this._direction = value;
  47107. };
  47108. Object.defineProperty(ShadowLight.prototype, "direction", {
  47109. /**
  47110. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  47111. * Also use as the light direction on spot and directional lights.
  47112. */
  47113. get: function () {
  47114. return this._direction;
  47115. },
  47116. /**
  47117. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  47118. * Also use as the light direction on spot and directional lights.
  47119. */
  47120. set: function (value) {
  47121. this._setDirection(value);
  47122. },
  47123. enumerable: true,
  47124. configurable: true
  47125. });
  47126. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47127. /**
  47128. * Gets the shadow projection clipping minimum z value.
  47129. */
  47130. get: function () {
  47131. return this._shadowMinZ;
  47132. },
  47133. /**
  47134. * Sets the shadow projection clipping minimum z value.
  47135. */
  47136. set: function (value) {
  47137. this._shadowMinZ = value;
  47138. this.forceProjectionMatrixCompute();
  47139. },
  47140. enumerable: true,
  47141. configurable: true
  47142. });
  47143. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47144. /**
  47145. * Sets the shadow projection clipping maximum z value.
  47146. */
  47147. get: function () {
  47148. return this._shadowMaxZ;
  47149. },
  47150. /**
  47151. * Gets the shadow projection clipping maximum z value.
  47152. */
  47153. set: function (value) {
  47154. this._shadowMaxZ = value;
  47155. this.forceProjectionMatrixCompute();
  47156. },
  47157. enumerable: true,
  47158. configurable: true
  47159. });
  47160. /**
  47161. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  47162. * @returns true if the information has been computed, false if it does not need to (no parenting)
  47163. */
  47164. ShadowLight.prototype.computeTransformedInformation = function () {
  47165. if (this.parent && this.parent.getWorldMatrix) {
  47166. if (!this.transformedPosition) {
  47167. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47168. }
  47169. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  47170. // In case the direction is present.
  47171. if (this.direction) {
  47172. if (!this.transformedDirection) {
  47173. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47174. }
  47175. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  47176. }
  47177. return true;
  47178. }
  47179. return false;
  47180. };
  47181. /**
  47182. * Return the depth scale used for the shadow map.
  47183. * @returns the depth scale.
  47184. */
  47185. ShadowLight.prototype.getDepthScale = function () {
  47186. return 50.0;
  47187. };
  47188. /**
  47189. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  47190. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47191. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47192. */
  47193. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  47194. return this.transformedDirection ? this.transformedDirection : this.direction;
  47195. };
  47196. /**
  47197. * Returns the ShadowLight absolute position in the World.
  47198. * @returns the position vector in world space
  47199. */
  47200. ShadowLight.prototype.getAbsolutePosition = function () {
  47201. return this.transformedPosition ? this.transformedPosition : this.position;
  47202. };
  47203. /**
  47204. * Sets the ShadowLight direction toward the passed target.
  47205. * @param target The point to target in local space
  47206. * @returns the updated ShadowLight direction
  47207. */
  47208. ShadowLight.prototype.setDirectionToTarget = function (target) {
  47209. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  47210. return this.direction;
  47211. };
  47212. /**
  47213. * Returns the light rotation in euler definition.
  47214. * @returns the x y z rotation in local space.
  47215. */
  47216. ShadowLight.prototype.getRotation = function () {
  47217. this.direction.normalize();
  47218. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  47219. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  47220. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  47221. };
  47222. /**
  47223. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  47224. * @returns true if a cube texture needs to be use
  47225. */
  47226. ShadowLight.prototype.needCube = function () {
  47227. return false;
  47228. };
  47229. /**
  47230. * Detects if the projection matrix requires to be recomputed this frame.
  47231. * @returns true if it requires to be recomputed otherwise, false.
  47232. */
  47233. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  47234. return this._needProjectionMatrixCompute;
  47235. };
  47236. /**
  47237. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  47238. */
  47239. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  47240. this._needProjectionMatrixCompute = true;
  47241. };
  47242. /** @hidden */
  47243. ShadowLight.prototype._initCache = function () {
  47244. _super.prototype._initCache.call(this);
  47245. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47246. };
  47247. /** @hidden */
  47248. ShadowLight.prototype._isSynchronized = function () {
  47249. if (!this._cache.position.equals(this.position)) {
  47250. return false;
  47251. }
  47252. return true;
  47253. };
  47254. /**
  47255. * Computes the world matrix of the node
  47256. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47257. * @returns the world matrix
  47258. */
  47259. ShadowLight.prototype.computeWorldMatrix = function (force) {
  47260. if (!force && this.isSynchronized()) {
  47261. this._currentRenderId = this.getScene().getRenderId();
  47262. return this._worldMatrix;
  47263. }
  47264. this._updateCache();
  47265. this._cache.position.copyFrom(this.position);
  47266. if (!this._worldMatrix) {
  47267. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47268. }
  47269. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  47270. if (this.parent && this.parent.getWorldMatrix) {
  47271. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  47272. this._markSyncedWithParent();
  47273. }
  47274. // Cache the determinant
  47275. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  47276. return this._worldMatrix;
  47277. };
  47278. /**
  47279. * Gets the minZ used for shadow according to both the scene and the light.
  47280. * @param activeCamera The camera we are returning the min for
  47281. * @returns the depth min z
  47282. */
  47283. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  47284. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  47285. };
  47286. /**
  47287. * Gets the maxZ used for shadow according to both the scene and the light.
  47288. * @param activeCamera The camera we are returning the max for
  47289. * @returns the depth max z
  47290. */
  47291. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  47292. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  47293. };
  47294. /**
  47295. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47296. * @param matrix The materix to updated with the projection information
  47297. * @param viewMatrix The transform matrix of the light
  47298. * @param renderList The list of mesh to render in the map
  47299. * @returns The current light
  47300. */
  47301. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47302. if (this.customProjectionMatrixBuilder) {
  47303. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  47304. }
  47305. else {
  47306. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47307. }
  47308. return this;
  47309. };
  47310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47312. ], ShadowLight.prototype, "position", null);
  47313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47315. ], ShadowLight.prototype, "direction", null);
  47316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47318. ], ShadowLight.prototype, "shadowMinZ", null);
  47319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47321. ], ShadowLight.prototype, "shadowMaxZ", null);
  47322. return ShadowLight;
  47323. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  47324. /***/ }),
  47325. /***/ "./Lights/spotLight.ts":
  47326. /*!*****************************!*\
  47327. !*** ./Lights/spotLight.ts ***!
  47328. \*****************************/
  47329. /*! exports provided: SpotLight */
  47330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47331. "use strict";
  47332. __webpack_require__.r(__webpack_exports__);
  47333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  47334. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47335. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47336. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47337. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47338. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47339. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47340. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  47341. 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); };
  47342. });
  47343. /**
  47344. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47345. * These values define a cone of light starting from the position, emitting toward the direction.
  47346. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47347. * and the exponent defines the speed of the decay of the light with distance (reach).
  47348. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47349. */
  47350. var SpotLight = /** @class */ (function (_super) {
  47351. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  47352. /**
  47353. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47354. * It can cast shadows.
  47355. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47356. * @param name The light friendly name
  47357. * @param position The position of the spot light in the scene
  47358. * @param direction The direction of the light in the scene
  47359. * @param angle The cone angle of the light in Radians
  47360. * @param exponent The light decay speed with the distance from the emission spot
  47361. * @param scene The scene the lights belongs to
  47362. */
  47363. function SpotLight(name, position, direction, angle, exponent, scene) {
  47364. var _this = _super.call(this, name, scene) || this;
  47365. _this._innerAngle = 0;
  47366. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47367. _this._projectionTextureLightNear = 1e-6;
  47368. _this._projectionTextureLightFar = 1000.0;
  47369. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47370. _this._projectionTextureViewLightDirty = true;
  47371. _this._projectionTextureProjectionLightDirty = true;
  47372. _this._projectionTextureDirty = true;
  47373. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47374. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47375. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47376. _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);
  47377. _this.position = position;
  47378. _this.direction = direction;
  47379. _this.angle = angle;
  47380. _this.exponent = exponent;
  47381. return _this;
  47382. }
  47383. Object.defineProperty(SpotLight.prototype, "angle", {
  47384. /**
  47385. * Gets the cone angle of the spot light in Radians.
  47386. */
  47387. get: function () {
  47388. return this._angle;
  47389. },
  47390. /**
  47391. * Sets the cone angle of the spot light in Radians.
  47392. */
  47393. set: function (value) {
  47394. this._angle = value;
  47395. this._cosHalfAngle = Math.cos(value * 0.5);
  47396. this._projectionTextureProjectionLightDirty = true;
  47397. this.forceProjectionMatrixCompute();
  47398. this._computeAngleValues();
  47399. },
  47400. enumerable: true,
  47401. configurable: true
  47402. });
  47403. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  47404. /**
  47405. * Only used in gltf falloff mode, this defines the angle where
  47406. * the directional falloff will start before cutting at angle which could be seen
  47407. * as outer angle.
  47408. */
  47409. get: function () {
  47410. return this._innerAngle;
  47411. },
  47412. /**
  47413. * Only used in gltf falloff mode, this defines the angle where
  47414. * the directional falloff will start before cutting at angle which could be seen
  47415. * as outer angle.
  47416. */
  47417. set: function (value) {
  47418. this._innerAngle = value;
  47419. this._computeAngleValues();
  47420. },
  47421. enumerable: true,
  47422. configurable: true
  47423. });
  47424. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  47425. /**
  47426. * Allows scaling the angle of the light for shadow generation only.
  47427. */
  47428. get: function () {
  47429. return this._shadowAngleScale;
  47430. },
  47431. /**
  47432. * Allows scaling the angle of the light for shadow generation only.
  47433. */
  47434. set: function (value) {
  47435. this._shadowAngleScale = value;
  47436. this.forceProjectionMatrixCompute();
  47437. },
  47438. enumerable: true,
  47439. configurable: true
  47440. });
  47441. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  47442. /**
  47443. * Allows reading the projecton texture
  47444. */
  47445. get: function () {
  47446. return this._projectionTextureMatrix;
  47447. },
  47448. enumerable: true,
  47449. configurable: true
  47450. });
  47451. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  47452. /**
  47453. * Gets the near clip of the Spotlight for texture projection.
  47454. */
  47455. get: function () {
  47456. return this._projectionTextureLightNear;
  47457. },
  47458. /**
  47459. * Sets the near clip of the Spotlight for texture projection.
  47460. */
  47461. set: function (value) {
  47462. this._projectionTextureLightNear = value;
  47463. this._projectionTextureProjectionLightDirty = true;
  47464. },
  47465. enumerable: true,
  47466. configurable: true
  47467. });
  47468. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  47469. /**
  47470. * Gets the far clip of the Spotlight for texture projection.
  47471. */
  47472. get: function () {
  47473. return this._projectionTextureLightFar;
  47474. },
  47475. /**
  47476. * Sets the far clip of the Spotlight for texture projection.
  47477. */
  47478. set: function (value) {
  47479. this._projectionTextureLightFar = value;
  47480. this._projectionTextureProjectionLightDirty = true;
  47481. },
  47482. enumerable: true,
  47483. configurable: true
  47484. });
  47485. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  47486. /**
  47487. * Gets the Up vector of the Spotlight for texture projection.
  47488. */
  47489. get: function () {
  47490. return this._projectionTextureUpDirection;
  47491. },
  47492. /**
  47493. * Sets the Up vector of the Spotlight for texture projection.
  47494. */
  47495. set: function (value) {
  47496. this._projectionTextureUpDirection = value;
  47497. this._projectionTextureProjectionLightDirty = true;
  47498. },
  47499. enumerable: true,
  47500. configurable: true
  47501. });
  47502. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  47503. /**
  47504. * Gets the projection texture of the light.
  47505. */
  47506. get: function () {
  47507. return this._projectionTexture;
  47508. },
  47509. /**
  47510. * Sets the projection texture of the light.
  47511. */
  47512. set: function (value) {
  47513. this._projectionTexture = value;
  47514. this._projectionTextureDirty = true;
  47515. },
  47516. enumerable: true,
  47517. configurable: true
  47518. });
  47519. /**
  47520. * Returns the string "SpotLight".
  47521. * @returns the class name
  47522. */
  47523. SpotLight.prototype.getClassName = function () {
  47524. return "SpotLight";
  47525. };
  47526. /**
  47527. * Returns the integer 2.
  47528. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47529. */
  47530. SpotLight.prototype.getTypeID = function () {
  47531. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  47532. };
  47533. /**
  47534. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47535. */
  47536. SpotLight.prototype._setDirection = function (value) {
  47537. _super.prototype._setDirection.call(this, value);
  47538. this._projectionTextureViewLightDirty = true;
  47539. };
  47540. /**
  47541. * Overrides the position setter to recompute the projection texture view light Matrix.
  47542. */
  47543. SpotLight.prototype._setPosition = function (value) {
  47544. _super.prototype._setPosition.call(this, value);
  47545. this._projectionTextureViewLightDirty = true;
  47546. };
  47547. /**
  47548. * 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.
  47549. * Returns the SpotLight.
  47550. */
  47551. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47552. var activeCamera = this.getScene().activeCamera;
  47553. if (!activeCamera) {
  47554. return;
  47555. }
  47556. this._shadowAngleScale = this._shadowAngleScale || 1;
  47557. var angle = this._shadowAngleScale * this._angle;
  47558. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47559. };
  47560. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  47561. this._projectionTextureViewLightDirty = false;
  47562. this._projectionTextureDirty = true;
  47563. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  47564. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  47565. };
  47566. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  47567. this._projectionTextureProjectionLightDirty = false;
  47568. this._projectionTextureDirty = true;
  47569. var light_far = this.projectionTextureLightFar;
  47570. var light_near = this.projectionTextureLightNear;
  47571. var P = light_far / (light_far - light_near);
  47572. var Q = -P * light_near;
  47573. var S = 1.0 / Math.tan(this._angle / 2.0);
  47574. var A = 1.0;
  47575. _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);
  47576. };
  47577. /**
  47578. * Main function for light texture projection matrix computing.
  47579. */
  47580. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  47581. this._projectionTextureDirty = false;
  47582. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  47583. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  47584. };
  47585. SpotLight.prototype._buildUniformLayout = function () {
  47586. this._uniformBuffer.addUniform("vLightData", 4);
  47587. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47588. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47589. this._uniformBuffer.addUniform("vLightDirection", 3);
  47590. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47591. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47592. this._uniformBuffer.addUniform("depthValues", 2);
  47593. this._uniformBuffer.create();
  47594. };
  47595. SpotLight.prototype._computeAngleValues = function () {
  47596. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  47597. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  47598. };
  47599. /**
  47600. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47601. * @param effect The effect to update
  47602. * @param lightIndex The index of the light in the effect to update
  47603. * @returns The spot light
  47604. */
  47605. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  47606. var normalizeDirection;
  47607. if (this.computeTransformedInformation()) {
  47608. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  47609. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  47610. }
  47611. else {
  47612. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  47613. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47614. }
  47615. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  47616. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  47617. if (this.projectionTexture && this.projectionTexture.isReady()) {
  47618. if (this._projectionTextureViewLightDirty) {
  47619. this._computeProjectionTextureViewLightMatrix();
  47620. }
  47621. if (this._projectionTextureProjectionLightDirty) {
  47622. this._computeProjectionTextureProjectionLightMatrix();
  47623. }
  47624. if (this._projectionTextureDirty) {
  47625. this._computeProjectionTextureMatrix();
  47626. }
  47627. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  47628. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  47629. }
  47630. return this;
  47631. };
  47632. /**
  47633. * Disposes the light and the associated resources.
  47634. */
  47635. SpotLight.prototype.dispose = function () {
  47636. _super.prototype.dispose.call(this);
  47637. if (this._projectionTexture) {
  47638. this._projectionTexture.dispose();
  47639. }
  47640. };
  47641. /**
  47642. * Prepares the list of defines specific to the light type.
  47643. * @param defines the list of defines
  47644. * @param lightIndex defines the index of the light for the effect
  47645. */
  47646. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47647. defines["SPOTLIGHT" + lightIndex] = true;
  47648. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  47649. };
  47650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47652. ], SpotLight.prototype, "angle", null);
  47653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47655. ], SpotLight.prototype, "innerAngle", null);
  47656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47658. ], SpotLight.prototype, "shadowAngleScale", null);
  47659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47661. ], SpotLight.prototype, "exponent", void 0);
  47662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47664. ], SpotLight.prototype, "projectionTextureLightNear", null);
  47665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47667. ], SpotLight.prototype, "projectionTextureLightFar", null);
  47668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47670. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  47671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  47673. ], SpotLight.prototype, "_projectionTexture", void 0);
  47674. return SpotLight;
  47675. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47676. /***/ }),
  47677. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  47678. /*!**********************************************!*\
  47679. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  47680. \**********************************************/
  47681. /*! exports provided: _BabylonLoaderRegistered */
  47682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47683. "use strict";
  47684. __webpack_require__.r(__webpack_exports__);
  47685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  47686. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  47687. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  47688. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  47689. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  47690. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  47691. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  47692. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  47693. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  47694. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  47695. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  47696. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  47697. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  47698. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  47699. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  47700. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  47701. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  47702. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  47703. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  47704. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  47705. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  47706. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  47707. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  47708. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  47709. /** @hidden */
  47710. var _BabylonLoaderRegistered = true;
  47711. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  47712. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47713. var parsedMaterial = parsedData.materials[index];
  47714. if (parsedMaterial.id === id) {
  47715. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47716. }
  47717. }
  47718. return null;
  47719. };
  47720. var isDescendantOf = function (mesh, names, hierarchyIds) {
  47721. for (var i in names) {
  47722. if (mesh.name === names[i]) {
  47723. hierarchyIds.push(mesh.id);
  47724. return true;
  47725. }
  47726. }
  47727. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  47728. hierarchyIds.push(mesh.id);
  47729. return true;
  47730. }
  47731. return false;
  47732. };
  47733. var logOperation = function (operation, producer) {
  47734. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  47735. };
  47736. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  47737. if (addToScene === void 0) { addToScene = false; }
  47738. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  47739. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47740. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47741. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47742. // and avoid problems with multiple concurrent .babylon loads.
  47743. var log = "importScene has failed JSON parse";
  47744. try {
  47745. var parsedData = JSON.parse(data);
  47746. log = "";
  47747. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47748. var index;
  47749. var cache;
  47750. // Lights
  47751. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  47752. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  47753. var parsedLight = parsedData.lights[index];
  47754. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  47755. if (light) {
  47756. container.lights.push(light);
  47757. log += (index === 0 ? "\n\tLights:" : "");
  47758. log += "\n\t\t" + light.toString(fullDetails);
  47759. }
  47760. }
  47761. }
  47762. // Reflection probes
  47763. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  47764. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  47765. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  47766. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  47767. if (reflectionProbe) {
  47768. container.reflectionProbes.push(reflectionProbe);
  47769. log += (index === 0 ? "\n\tReflection Probes:" : "");
  47770. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  47771. }
  47772. }
  47773. }
  47774. // Animations
  47775. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  47776. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  47777. var parsedAnimation = parsedData.animations[index];
  47778. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  47779. if (internalClass) {
  47780. var animation = internalClass.Parse(parsedAnimation);
  47781. scene.animations.push(animation);
  47782. container.animations.push(animation);
  47783. log += (index === 0 ? "\n\tAnimations:" : "");
  47784. log += "\n\t\t" + animation.toString(fullDetails);
  47785. }
  47786. }
  47787. }
  47788. // Materials
  47789. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  47790. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47791. var parsedMaterial = parsedData.materials[index];
  47792. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47793. container.materials.push(mat);
  47794. log += (index === 0 ? "\n\tMaterials:" : "");
  47795. log += "\n\t\t" + mat.toString(fullDetails);
  47796. }
  47797. }
  47798. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47799. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  47800. var parsedMultiMaterial = parsedData.multiMaterials[index];
  47801. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47802. container.multiMaterials.push(mmat);
  47803. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  47804. log += "\n\t\t" + mmat.toString(fullDetails);
  47805. }
  47806. }
  47807. // Morph targets
  47808. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47809. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47810. var managerData = _a[_i];
  47811. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  47812. }
  47813. }
  47814. // Skeletons
  47815. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47816. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  47817. var parsedSkeleton = parsedData.skeletons[index];
  47818. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  47819. container.skeletons.push(skeleton);
  47820. log += (index === 0 ? "\n\tSkeletons:" : "");
  47821. log += "\n\t\t" + skeleton.toString(fullDetails);
  47822. }
  47823. }
  47824. // Geometries
  47825. var geometries = parsedData.geometries;
  47826. if (geometries !== undefined && geometries !== null) {
  47827. var addedGeometry = new Array();
  47828. // VertexData
  47829. var vertexData = geometries.vertexData;
  47830. if (vertexData !== undefined && vertexData !== null) {
  47831. for (index = 0, cache = vertexData.length; index < cache; index++) {
  47832. var parsedVertexData = vertexData[index];
  47833. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  47834. }
  47835. }
  47836. addedGeometry.forEach(function (g) {
  47837. if (g) {
  47838. container.geometries.push(g);
  47839. }
  47840. });
  47841. }
  47842. // Transform nodes
  47843. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  47844. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  47845. var parsedTransformNode = parsedData.transformNodes[index];
  47846. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  47847. container.transformNodes.push(node);
  47848. }
  47849. }
  47850. // Meshes
  47851. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47852. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47853. var parsedMesh = parsedData.meshes[index];
  47854. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47855. container.meshes.push(mesh);
  47856. log += (index === 0 ? "\n\tMeshes:" : "");
  47857. log += "\n\t\t" + mesh.toString(fullDetails);
  47858. }
  47859. }
  47860. // Cameras
  47861. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  47862. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  47863. var parsedCamera = parsedData.cameras[index];
  47864. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  47865. container.cameras.push(camera);
  47866. log += (index === 0 ? "\n\tCameras:" : "");
  47867. log += "\n\t\t" + camera.toString(fullDetails);
  47868. }
  47869. }
  47870. // Animation Groups
  47871. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  47872. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  47873. var parsedAnimationGroup = parsedData.animationGroups[index];
  47874. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  47875. container.animationGroups.push(animationGroup);
  47876. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  47877. log += "\n\t\t" + animationGroup.toString(fullDetails);
  47878. }
  47879. }
  47880. // Browsing all the graph to connect the dots
  47881. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  47882. var camera = scene.cameras[index];
  47883. if (camera._waitingParentId) {
  47884. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  47885. camera._waitingParentId = null;
  47886. }
  47887. }
  47888. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47889. var light_1 = scene.lights[index];
  47890. if (light_1 && light_1._waitingParentId) {
  47891. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  47892. light_1._waitingParentId = null;
  47893. }
  47894. }
  47895. // Connect parents & children and parse actions
  47896. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  47897. var transformNode = scene.transformNodes[index];
  47898. if (transformNode._waitingParentId) {
  47899. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  47900. transformNode._waitingParentId = null;
  47901. }
  47902. }
  47903. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47904. var mesh = scene.meshes[index];
  47905. if (mesh._waitingParentId) {
  47906. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  47907. mesh._waitingParentId = null;
  47908. }
  47909. }
  47910. // freeze world matrix application
  47911. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47912. var currentMesh = scene.meshes[index];
  47913. if (currentMesh._waitingFreezeWorldMatrix) {
  47914. currentMesh.freezeWorldMatrix();
  47915. currentMesh._waitingFreezeWorldMatrix = null;
  47916. }
  47917. else {
  47918. currentMesh.computeWorldMatrix(true);
  47919. }
  47920. }
  47921. // Lights exclusions / inclusions
  47922. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47923. var light_2 = scene.lights[index];
  47924. // Excluded check
  47925. if (light_2._excludedMeshesIds.length > 0) {
  47926. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  47927. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  47928. if (excludedMesh) {
  47929. light_2.excludedMeshes.push(excludedMesh);
  47930. }
  47931. }
  47932. light_2._excludedMeshesIds = [];
  47933. }
  47934. // Included check
  47935. if (light_2._includedOnlyMeshesIds.length > 0) {
  47936. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  47937. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  47938. if (includedOnlyMesh) {
  47939. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  47940. }
  47941. }
  47942. light_2._includedOnlyMeshesIds = [];
  47943. }
  47944. }
  47945. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  47946. // Actions (scene) Done last as it can access other objects.
  47947. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47948. var mesh = scene.meshes[index];
  47949. if (mesh._waitingActions) {
  47950. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  47951. mesh._waitingActions = null;
  47952. }
  47953. }
  47954. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  47955. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  47956. }
  47957. if (!addToScene) {
  47958. container.removeAllFromScene();
  47959. }
  47960. }
  47961. catch (err) {
  47962. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  47963. if (onError) {
  47964. onError(msg, err);
  47965. }
  47966. else {
  47967. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47968. throw err;
  47969. }
  47970. }
  47971. finally {
  47972. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  47973. _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 : ""));
  47974. }
  47975. }
  47976. return container;
  47977. };
  47978. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  47979. name: "babylon.js",
  47980. extensions: ".babylon",
  47981. canDirectLoad: function (data) {
  47982. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  47983. return true;
  47984. }
  47985. return false;
  47986. },
  47987. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  47988. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47989. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47990. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47991. // and avoid problems with multiple concurrent .babylon loads.
  47992. var log = "importMesh has failed JSON parse";
  47993. try {
  47994. var parsedData = JSON.parse(data);
  47995. log = "";
  47996. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47997. if (!meshesNames) {
  47998. meshesNames = null;
  47999. }
  48000. else if (!Array.isArray(meshesNames)) {
  48001. meshesNames = [meshesNames];
  48002. }
  48003. var hierarchyIds = new Array();
  48004. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48005. var loadedSkeletonsIds = [];
  48006. var loadedMaterialsIds = [];
  48007. var index;
  48008. var cache;
  48009. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48010. var parsedMesh = parsedData.meshes[index];
  48011. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  48012. if (meshesNames !== null) {
  48013. // Remove found mesh name from list.
  48014. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  48015. }
  48016. //Geometry?
  48017. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  48018. //does the file contain geometries?
  48019. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  48020. //find the correct geometry and add it to the scene
  48021. var found = false;
  48022. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  48023. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  48024. return;
  48025. }
  48026. else {
  48027. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  48028. if (parsedGeometryData.id === parsedMesh.geometryId) {
  48029. switch (geometryType) {
  48030. case "vertexData":
  48031. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  48032. break;
  48033. }
  48034. found = true;
  48035. }
  48036. });
  48037. }
  48038. });
  48039. if (found === false) {
  48040. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  48041. }
  48042. }
  48043. }
  48044. // Material ?
  48045. if (parsedMesh.materialId) {
  48046. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  48047. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48048. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  48049. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  48050. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  48051. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  48052. var subMatId = parsedMultiMaterial.materials[matIndex];
  48053. loadedMaterialsIds.push(subMatId);
  48054. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  48055. if (mat) {
  48056. log += "\n\tMaterial " + mat.toString(fullDetails);
  48057. }
  48058. }
  48059. loadedMaterialsIds.push(parsedMultiMaterial.id);
  48060. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48061. if (mmat) {
  48062. materialFound = true;
  48063. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  48064. }
  48065. break;
  48066. }
  48067. }
  48068. }
  48069. if (materialFound === false) {
  48070. loadedMaterialsIds.push(parsedMesh.materialId);
  48071. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  48072. if (!mat) {
  48073. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  48074. }
  48075. else {
  48076. log += "\n\tMaterial " + mat.toString(fullDetails);
  48077. }
  48078. }
  48079. }
  48080. // Skeleton ?
  48081. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48082. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  48083. if (skeletonAlreadyLoaded === false) {
  48084. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  48085. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  48086. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  48087. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48088. skeletons.push(skeleton);
  48089. loadedSkeletonsIds.push(parsedSkeleton.id);
  48090. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  48091. }
  48092. }
  48093. }
  48094. }
  48095. // Morph targets ?
  48096. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48097. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48098. var managerData = _a[_i];
  48099. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  48100. }
  48101. }
  48102. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48103. meshes.push(mesh);
  48104. log += "\n\tMesh " + mesh.toString(fullDetails);
  48105. }
  48106. }
  48107. // Connecting parents
  48108. var currentMesh;
  48109. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48110. currentMesh = scene.meshes[index];
  48111. if (currentMesh._waitingParentId) {
  48112. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  48113. currentMesh._waitingParentId = null;
  48114. }
  48115. }
  48116. // freeze and compute world matrix application
  48117. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48118. currentMesh = scene.meshes[index];
  48119. if (currentMesh._waitingFreezeWorldMatrix) {
  48120. currentMesh.freezeWorldMatrix();
  48121. currentMesh._waitingFreezeWorldMatrix = null;
  48122. }
  48123. else {
  48124. currentMesh.computeWorldMatrix(true);
  48125. }
  48126. }
  48127. }
  48128. // Particles
  48129. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48130. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48131. if (parser) {
  48132. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48133. var parsedParticleSystem = parsedData.particleSystems[index];
  48134. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  48135. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  48136. }
  48137. }
  48138. }
  48139. }
  48140. return true;
  48141. }
  48142. catch (err) {
  48143. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  48144. if (onError) {
  48145. onError(msg, err);
  48146. }
  48147. else {
  48148. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48149. throw err;
  48150. }
  48151. }
  48152. finally {
  48153. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48154. _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 : ""));
  48155. }
  48156. }
  48157. return false;
  48158. },
  48159. load: function (scene, data, rootUrl, onError) {
  48160. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48161. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48162. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48163. // and avoid problems with multiple concurrent .babylon loads.
  48164. var log = "importScene has failed JSON parse";
  48165. try {
  48166. var parsedData = JSON.parse(data);
  48167. log = "";
  48168. // Scene
  48169. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  48170. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  48171. }
  48172. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  48173. scene.autoClear = parsedData.autoClear;
  48174. }
  48175. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  48176. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  48177. }
  48178. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  48179. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  48180. }
  48181. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  48182. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  48183. }
  48184. // Fog
  48185. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  48186. scene.fogMode = parsedData.fogMode;
  48187. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  48188. scene.fogStart = parsedData.fogStart;
  48189. scene.fogEnd = parsedData.fogEnd;
  48190. scene.fogDensity = parsedData.fogDensity;
  48191. log += "\tFog mode for scene: ";
  48192. switch (scene.fogMode) {
  48193. // getters not compiling, so using hardcoded
  48194. case 1:
  48195. log += "exp\n";
  48196. break;
  48197. case 2:
  48198. log += "exp2\n";
  48199. break;
  48200. case 3:
  48201. log += "linear\n";
  48202. break;
  48203. }
  48204. }
  48205. //Physics
  48206. if (parsedData.physicsEnabled) {
  48207. var physicsPlugin;
  48208. if (parsedData.physicsEngine === "cannon") {
  48209. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  48210. }
  48211. else if (parsedData.physicsEngine === "oimo") {
  48212. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  48213. }
  48214. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  48215. //else - default engine, which is currently oimo
  48216. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  48217. scene.enablePhysics(physicsGravity, physicsPlugin);
  48218. }
  48219. // Metadata
  48220. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  48221. scene.metadata = parsedData.metadata;
  48222. }
  48223. //collisions, if defined. otherwise, default is true
  48224. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  48225. scene.collisionsEnabled = parsedData.collisionsEnabled;
  48226. }
  48227. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  48228. if (!container) {
  48229. return false;
  48230. }
  48231. if (parsedData.autoAnimate) {
  48232. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  48233. }
  48234. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  48235. scene.setActiveCameraByID(parsedData.activeCameraID);
  48236. }
  48237. // Environment texture
  48238. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48239. // PBR needed for both HDR texture (gamma space) & a sky box
  48240. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48241. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48242. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48243. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48244. if (parsedData.environmentTextureRotationY) {
  48245. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48246. }
  48247. scene.environmentTexture = hdrTexture;
  48248. }
  48249. else {
  48250. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  48251. if (parsedData.environmentTextureRotationY) {
  48252. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48253. }
  48254. scene.environmentTexture = cubeTexture;
  48255. }
  48256. if (parsedData.createDefaultSkybox === true) {
  48257. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48258. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48259. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48260. }
  48261. }
  48262. // Finish
  48263. return true;
  48264. }
  48265. catch (err) {
  48266. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  48267. if (onError) {
  48268. onError(msg, err);
  48269. }
  48270. else {
  48271. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48272. throw err;
  48273. }
  48274. }
  48275. finally {
  48276. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48277. _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 : ""));
  48278. }
  48279. }
  48280. return false;
  48281. },
  48282. loadAssetContainer: function (scene, data, rootUrl, onError) {
  48283. var container = loadAssetContainer(scene, data, rootUrl, onError);
  48284. return container;
  48285. }
  48286. });
  48287. /***/ }),
  48288. /***/ "./Loading/Plugins/index.ts":
  48289. /*!**********************************!*\
  48290. !*** ./Loading/Plugins/index.ts ***!
  48291. \**********************************/
  48292. /*! exports provided: _BabylonLoaderRegistered */
  48293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48294. "use strict";
  48295. __webpack_require__.r(__webpack_exports__);
  48296. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48298. /***/ }),
  48299. /***/ "./Loading/index.ts":
  48300. /*!**************************!*\
  48301. !*** ./Loading/index.ts ***!
  48302. \**************************/
  48303. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  48304. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48305. "use strict";
  48306. __webpack_require__.r(__webpack_exports__);
  48307. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  48308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  48309. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  48310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  48311. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  48312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  48313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  48314. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  48316. /***/ }),
  48317. /***/ "./Loading/loadingScreen.ts":
  48318. /*!**********************************!*\
  48319. !*** ./Loading/loadingScreen.ts ***!
  48320. \**********************************/
  48321. /*! exports provided: DefaultLoadingScreen */
  48322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48323. "use strict";
  48324. __webpack_require__.r(__webpack_exports__);
  48325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  48326. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48327. /**
  48328. * Class used for the default loading screen
  48329. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  48330. */
  48331. var DefaultLoadingScreen = /** @class */ (function () {
  48332. /**
  48333. * Creates a new default loading screen
  48334. * @param _renderingCanvas defines the canvas used to render the scene
  48335. * @param _loadingText defines the default text to display
  48336. * @param _loadingDivBackgroundColor defines the default background color
  48337. */
  48338. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  48339. if (_loadingText === void 0) { _loadingText = ""; }
  48340. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  48341. var _this = this;
  48342. this._renderingCanvas = _renderingCanvas;
  48343. this._loadingText = _loadingText;
  48344. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  48345. // Resize
  48346. this._resizeLoadingUI = function () {
  48347. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  48348. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  48349. if (!_this._loadingDiv) {
  48350. return;
  48351. }
  48352. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  48353. _this._loadingDiv.style.left = canvasRect.left + "px";
  48354. _this._loadingDiv.style.top = canvasRect.top + "px";
  48355. _this._loadingDiv.style.width = canvasRect.width + "px";
  48356. _this._loadingDiv.style.height = canvasRect.height + "px";
  48357. };
  48358. }
  48359. /**
  48360. * Function called to display the loading screen
  48361. */
  48362. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  48363. if (this._loadingDiv) {
  48364. // Do not add a loading screen if there is already one
  48365. return;
  48366. }
  48367. this._loadingDiv = document.createElement("div");
  48368. this._loadingDiv.id = "babylonjsLoadingDiv";
  48369. this._loadingDiv.style.opacity = "0";
  48370. this._loadingDiv.style.transition = "opacity 1.5s ease";
  48371. this._loadingDiv.style.pointerEvents = "none";
  48372. // Loading text
  48373. this._loadingTextDiv = document.createElement("div");
  48374. this._loadingTextDiv.style.position = "absolute";
  48375. this._loadingTextDiv.style.left = "0";
  48376. this._loadingTextDiv.style.top = "50%";
  48377. this._loadingTextDiv.style.marginTop = "80px";
  48378. this._loadingTextDiv.style.width = "100%";
  48379. this._loadingTextDiv.style.height = "20px";
  48380. this._loadingTextDiv.style.fontFamily = "Arial";
  48381. this._loadingTextDiv.style.fontSize = "14px";
  48382. this._loadingTextDiv.style.color = "white";
  48383. this._loadingTextDiv.style.textAlign = "center";
  48384. this._loadingTextDiv.innerHTML = "Loading";
  48385. this._loadingDiv.appendChild(this._loadingTextDiv);
  48386. //set the predefined text
  48387. this._loadingTextDiv.innerHTML = this._loadingText;
  48388. // Generating keyframes
  48389. var style = document.createElement('style');
  48390. style.type = 'text/css';
  48391. 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 }";
  48392. style.innerHTML = keyFrames;
  48393. document.getElementsByTagName('head')[0].appendChild(style);
  48394. // Loading img
  48395. var imgBack = new Image();
  48396. 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";
  48397. imgBack.style.position = "absolute";
  48398. imgBack.style.left = "50%";
  48399. imgBack.style.top = "50%";
  48400. imgBack.style.marginLeft = "-60px";
  48401. imgBack.style.marginTop = "-60px";
  48402. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  48403. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  48404. imgBack.style.transformOrigin = "50% 50%";
  48405. imgBack.style.webkitTransformOrigin = "50% 50%";
  48406. this._loadingDiv.appendChild(imgBack);
  48407. this._resizeLoadingUI();
  48408. window.addEventListener("resize", this._resizeLoadingUI);
  48409. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48410. document.body.appendChild(this._loadingDiv);
  48411. this._loadingDiv.style.opacity = "1";
  48412. };
  48413. /**
  48414. * Function called to hide the loading screen
  48415. */
  48416. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  48417. var _this = this;
  48418. if (!this._loadingDiv) {
  48419. return;
  48420. }
  48421. var onTransitionEnd = function () {
  48422. if (!_this._loadingDiv) {
  48423. return;
  48424. }
  48425. if (_this._loadingDiv.parentElement) {
  48426. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  48427. }
  48428. window.removeEventListener("resize", _this._resizeLoadingUI);
  48429. _this._loadingDiv = null;
  48430. };
  48431. this._loadingDiv.style.opacity = "0";
  48432. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  48433. };
  48434. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  48435. get: function () {
  48436. return this._loadingText;
  48437. },
  48438. /**
  48439. * Gets or sets the text to display while loading
  48440. */
  48441. set: function (text) {
  48442. this._loadingText = text;
  48443. if (this._loadingTextDiv) {
  48444. this._loadingTextDiv.innerHTML = this._loadingText;
  48445. }
  48446. },
  48447. enumerable: true,
  48448. configurable: true
  48449. });
  48450. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  48451. /**
  48452. * Gets or sets the color to use for the background
  48453. */
  48454. get: function () {
  48455. return this._loadingDivBackgroundColor;
  48456. },
  48457. set: function (color) {
  48458. this._loadingDivBackgroundColor = color;
  48459. if (!this._loadingDiv) {
  48460. return;
  48461. }
  48462. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48463. },
  48464. enumerable: true,
  48465. configurable: true
  48466. });
  48467. return DefaultLoadingScreen;
  48468. }());
  48469. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  48470. /***/ }),
  48471. /***/ "./Loading/sceneLoader.ts":
  48472. /*!********************************!*\
  48473. !*** ./Loading/sceneLoader.ts ***!
  48474. \********************************/
  48475. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  48476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48477. "use strict";
  48478. __webpack_require__.r(__webpack_exports__);
  48479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  48480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  48481. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  48482. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  48483. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  48484. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  48485. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48486. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  48487. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  48488. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48489. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48490. /**
  48491. * Class used to represent data loading progression
  48492. */
  48493. var SceneLoaderProgressEvent = /** @class */ (function () {
  48494. /**
  48495. * Create a new progress event
  48496. * @param lengthComputable defines if data length to load can be evaluated
  48497. * @param loaded defines the loaded data length
  48498. * @param total defines the data length to load
  48499. */
  48500. function SceneLoaderProgressEvent(
  48501. /** defines if data length to load can be evaluated */
  48502. lengthComputable,
  48503. /** defines the loaded data length */
  48504. loaded,
  48505. /** defines the data length to load */
  48506. total) {
  48507. this.lengthComputable = lengthComputable;
  48508. this.loaded = loaded;
  48509. this.total = total;
  48510. }
  48511. /**
  48512. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48513. * @param event defines the source event
  48514. * @returns a new SceneLoaderProgressEvent
  48515. */
  48516. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  48517. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  48518. };
  48519. return SceneLoaderProgressEvent;
  48520. }());
  48521. /**
  48522. * Class used to load scene from various file formats using registered plugins
  48523. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48524. */
  48525. var SceneLoader = /** @class */ (function () {
  48526. function SceneLoader() {
  48527. }
  48528. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  48529. /**
  48530. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48531. */
  48532. get: function () {
  48533. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  48534. },
  48535. set: function (value) {
  48536. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  48537. },
  48538. enumerable: true,
  48539. configurable: true
  48540. });
  48541. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  48542. /**
  48543. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48544. */
  48545. get: function () {
  48546. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  48547. },
  48548. set: function (value) {
  48549. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  48550. },
  48551. enumerable: true,
  48552. configurable: true
  48553. });
  48554. Object.defineProperty(SceneLoader, "loggingLevel", {
  48555. /**
  48556. * Defines the current logging level (while loading the scene)
  48557. * @ignorenaming
  48558. */
  48559. get: function () {
  48560. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  48561. },
  48562. set: function (value) {
  48563. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  48564. },
  48565. enumerable: true,
  48566. configurable: true
  48567. });
  48568. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  48569. /**
  48570. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48571. */
  48572. get: function () {
  48573. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  48574. },
  48575. set: function (value) {
  48576. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  48577. },
  48578. enumerable: true,
  48579. configurable: true
  48580. });
  48581. SceneLoader._getDefaultPlugin = function () {
  48582. return SceneLoader._registeredPlugins[".babylon"];
  48583. };
  48584. SceneLoader._getPluginForExtension = function (extension) {
  48585. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  48586. if (registeredPlugin) {
  48587. return registeredPlugin;
  48588. }
  48589. _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");
  48590. return SceneLoader._getDefaultPlugin();
  48591. };
  48592. SceneLoader._getPluginForDirectLoad = function (data) {
  48593. for (var extension in SceneLoader._registeredPlugins) {
  48594. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  48595. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  48596. return SceneLoader._registeredPlugins[extension];
  48597. }
  48598. }
  48599. return SceneLoader._getDefaultPlugin();
  48600. };
  48601. SceneLoader._getPluginForFilename = function (sceneFilename) {
  48602. var queryStringPosition = sceneFilename.indexOf("?");
  48603. if (queryStringPosition !== -1) {
  48604. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  48605. }
  48606. var dotPosition = sceneFilename.lastIndexOf(".");
  48607. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  48608. return SceneLoader._getPluginForExtension(extension);
  48609. };
  48610. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  48611. SceneLoader._getDirectLoad = function (sceneFilename) {
  48612. if (sceneFilename.substr(0, 5) === "data:") {
  48613. return sceneFilename.substr(5);
  48614. }
  48615. return null;
  48616. };
  48617. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  48618. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  48619. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  48620. var plugin;
  48621. if (registeredPlugin.plugin.createPlugin) {
  48622. plugin = registeredPlugin.plugin.createPlugin();
  48623. }
  48624. else {
  48625. plugin = registeredPlugin.plugin;
  48626. }
  48627. if (!plugin) {
  48628. 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.";
  48629. }
  48630. var useArrayBuffer = registeredPlugin.isBinary;
  48631. var offlineProvider;
  48632. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  48633. var dataCallback = function (data, responseURL) {
  48634. if (scene.isDisposed) {
  48635. onError("Scene has been disposed");
  48636. return;
  48637. }
  48638. scene.offlineProvider = offlineProvider;
  48639. onSuccess(plugin, data, responseURL);
  48640. };
  48641. var request = null;
  48642. var pluginDisposed = false;
  48643. var onDisposeObservable = plugin.onDisposeObservable;
  48644. if (onDisposeObservable) {
  48645. onDisposeObservable.add(function () {
  48646. pluginDisposed = true;
  48647. if (request) {
  48648. request.abort();
  48649. request = null;
  48650. }
  48651. onDispose();
  48652. });
  48653. }
  48654. var manifestChecked = function () {
  48655. if (pluginDisposed) {
  48656. return;
  48657. }
  48658. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  48659. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  48660. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  48661. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  48662. });
  48663. };
  48664. if (directLoad) {
  48665. dataCallback(directLoad);
  48666. return plugin;
  48667. }
  48668. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  48669. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  48670. var engine = scene.getEngine();
  48671. var canUseOfflineSupport = engine.enableOfflineSupport;
  48672. if (canUseOfflineSupport) {
  48673. // Also check for exceptions
  48674. var exceptionFound = false;
  48675. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  48676. var regex = _a[_i];
  48677. if (regex.test(fileInfo.url)) {
  48678. exceptionFound = true;
  48679. break;
  48680. }
  48681. }
  48682. canUseOfflineSupport = !exceptionFound;
  48683. }
  48684. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  48685. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  48686. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  48687. }
  48688. else {
  48689. manifestChecked();
  48690. }
  48691. }
  48692. // Loading file from disk via input file or drag'n'drop
  48693. else {
  48694. if (file) {
  48695. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  48696. }
  48697. else {
  48698. onError("Unable to find file named " + fileInfo.name);
  48699. }
  48700. }
  48701. return plugin;
  48702. };
  48703. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  48704. var url;
  48705. var name;
  48706. var file = null;
  48707. if (!sceneFilename) {
  48708. url = rootUrl;
  48709. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  48710. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  48711. }
  48712. else if (sceneFilename.lastModified) {
  48713. var sceneFile = sceneFilename;
  48714. url = rootUrl + sceneFile.name;
  48715. name = sceneFile.name;
  48716. file = sceneFile;
  48717. }
  48718. else {
  48719. var filename = sceneFilename;
  48720. if (filename.substr(0, 1) === "/") {
  48721. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  48722. return null;
  48723. }
  48724. url = rootUrl + filename;
  48725. name = filename;
  48726. }
  48727. return {
  48728. url: url,
  48729. rootUrl: rootUrl,
  48730. name: name,
  48731. file: file
  48732. };
  48733. };
  48734. // Public functions
  48735. /**
  48736. * Gets a plugin that can load the given extension
  48737. * @param extension defines the extension to load
  48738. * @returns a plugin or null if none works
  48739. */
  48740. SceneLoader.GetPluginForExtension = function (extension) {
  48741. return SceneLoader._getPluginForExtension(extension).plugin;
  48742. };
  48743. /**
  48744. * Gets a boolean indicating that the given extension can be loaded
  48745. * @param extension defines the extension to load
  48746. * @returns true if the extension is supported
  48747. */
  48748. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  48749. return !!SceneLoader._registeredPlugins[extension];
  48750. };
  48751. /**
  48752. * Adds a new plugin to the list of registered plugins
  48753. * @param plugin defines the plugin to add
  48754. */
  48755. SceneLoader.RegisterPlugin = function (plugin) {
  48756. if (typeof plugin.extensions === "string") {
  48757. var extension = plugin.extensions;
  48758. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48759. plugin: plugin,
  48760. isBinary: false
  48761. };
  48762. }
  48763. else {
  48764. var extensions = plugin.extensions;
  48765. Object.keys(extensions).forEach(function (extension) {
  48766. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48767. plugin: plugin,
  48768. isBinary: extensions[extension].isBinary
  48769. };
  48770. });
  48771. }
  48772. };
  48773. /**
  48774. * Import meshes into a scene
  48775. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48776. * @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)
  48777. * @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)
  48778. * @param scene the instance of BABYLON.Scene to append to
  48779. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48780. * @param onProgress a callback with a progress event for each file being loaded
  48781. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48782. * @param pluginExtension the extension used to determine the plugin
  48783. * @returns The loaded plugin
  48784. */
  48785. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48786. if (sceneFilename === void 0) { sceneFilename = ""; }
  48787. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48788. if (onSuccess === void 0) { onSuccess = null; }
  48789. if (onProgress === void 0) { onProgress = null; }
  48790. if (onError === void 0) { onError = null; }
  48791. if (pluginExtension === void 0) { pluginExtension = null; }
  48792. if (!scene) {
  48793. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  48794. return null;
  48795. }
  48796. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48797. if (!fileInfo) {
  48798. return null;
  48799. }
  48800. var loadingToken = {};
  48801. scene._addPendingData(loadingToken);
  48802. var disposeHandler = function () {
  48803. scene._removePendingData(loadingToken);
  48804. };
  48805. var errorHandler = function (message, exception) {
  48806. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  48807. if (onError) {
  48808. onError(scene, errorMessage, exception);
  48809. }
  48810. else {
  48811. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48812. // should the exception be thrown?
  48813. }
  48814. disposeHandler();
  48815. };
  48816. var progressHandler = onProgress ? function (event) {
  48817. try {
  48818. onProgress(event);
  48819. }
  48820. catch (e) {
  48821. errorHandler("Error in onProgress callback", e);
  48822. }
  48823. } : undefined;
  48824. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  48825. scene.importedMeshesFiles.push(fileInfo.url);
  48826. if (onSuccess) {
  48827. try {
  48828. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  48829. }
  48830. catch (e) {
  48831. errorHandler("Error in onSuccess callback", e);
  48832. }
  48833. }
  48834. scene._removePendingData(loadingToken);
  48835. };
  48836. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  48837. if (plugin.rewriteRootURL) {
  48838. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  48839. }
  48840. if (plugin.importMesh) {
  48841. var syncedPlugin = plugin;
  48842. var meshes = new Array();
  48843. var particleSystems = new Array();
  48844. var skeletons = new Array();
  48845. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  48846. return;
  48847. }
  48848. scene.loadingPluginName = plugin.name;
  48849. successHandler(meshes, particleSystems, skeletons, []);
  48850. }
  48851. else {
  48852. var asyncedPlugin = plugin;
  48853. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  48854. scene.loadingPluginName = plugin.name;
  48855. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  48856. }).catch(function (error) {
  48857. errorHandler(error.message, error);
  48858. });
  48859. }
  48860. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48861. };
  48862. /**
  48863. * Import meshes into a scene
  48864. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48865. * @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)
  48866. * @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)
  48867. * @param scene the instance of BABYLON.Scene to append to
  48868. * @param onProgress a callback with a progress event for each file being loaded
  48869. * @param pluginExtension the extension used to determine the plugin
  48870. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48871. */
  48872. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48873. if (sceneFilename === void 0) { sceneFilename = ""; }
  48874. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48875. if (onProgress === void 0) { onProgress = null; }
  48876. if (pluginExtension === void 0) { pluginExtension = null; }
  48877. return new Promise(function (resolve, reject) {
  48878. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  48879. resolve({
  48880. meshes: meshes,
  48881. particleSystems: particleSystems,
  48882. skeletons: skeletons,
  48883. animationGroups: animationGroups
  48884. });
  48885. }, onProgress, function (scene, message, exception) {
  48886. reject(exception || new Error(message));
  48887. }, pluginExtension);
  48888. });
  48889. };
  48890. /**
  48891. * Load a scene
  48892. * @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)
  48893. * @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)
  48894. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48895. * @param onSuccess a callback with the scene when import succeeds
  48896. * @param onProgress a callback with a progress event for each file being loaded
  48897. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48898. * @param pluginExtension the extension used to determine the plugin
  48899. * @returns The loaded plugin
  48900. */
  48901. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  48902. if (sceneFilename === void 0) { sceneFilename = ""; }
  48903. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48904. if (onSuccess === void 0) { onSuccess = null; }
  48905. if (onProgress === void 0) { onProgress = null; }
  48906. if (onError === void 0) { onError = null; }
  48907. if (pluginExtension === void 0) { pluginExtension = null; }
  48908. if (!engine) {
  48909. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  48910. return null;
  48911. }
  48912. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  48913. };
  48914. /**
  48915. * Load a scene
  48916. * @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)
  48917. * @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)
  48918. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48919. * @param onProgress a callback with a progress event for each file being loaded
  48920. * @param pluginExtension the extension used to determine the plugin
  48921. * @returns The loaded scene
  48922. */
  48923. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  48924. if (sceneFilename === void 0) { sceneFilename = ""; }
  48925. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48926. if (onProgress === void 0) { onProgress = null; }
  48927. if (pluginExtension === void 0) { pluginExtension = null; }
  48928. return new Promise(function (resolve, reject) {
  48929. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  48930. resolve(scene);
  48931. }, onProgress, function (scene, message, exception) {
  48932. reject(exception || new Error(message));
  48933. }, pluginExtension);
  48934. });
  48935. };
  48936. /**
  48937. * Append a scene
  48938. * @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)
  48939. * @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)
  48940. * @param scene is the instance of BABYLON.Scene to append to
  48941. * @param onSuccess a callback with the scene when import succeeds
  48942. * @param onProgress a callback with a progress event for each file being loaded
  48943. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48944. * @param pluginExtension the extension used to determine the plugin
  48945. * @returns The loaded plugin
  48946. */
  48947. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48948. if (sceneFilename === void 0) { sceneFilename = ""; }
  48949. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48950. if (onSuccess === void 0) { onSuccess = null; }
  48951. if (onProgress === void 0) { onProgress = null; }
  48952. if (onError === void 0) { onError = null; }
  48953. if (pluginExtension === void 0) { pluginExtension = null; }
  48954. if (!scene) {
  48955. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  48956. return null;
  48957. }
  48958. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48959. if (!fileInfo) {
  48960. return null;
  48961. }
  48962. if (SceneLoader.ShowLoadingScreen) {
  48963. scene.getEngine().displayLoadingUI();
  48964. }
  48965. var loadingToken = {};
  48966. scene._addPendingData(loadingToken);
  48967. var disposeHandler = function () {
  48968. scene._removePendingData(loadingToken);
  48969. scene.getEngine().hideLoadingUI();
  48970. };
  48971. var errorHandler = function (message, exception) {
  48972. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  48973. if (onError) {
  48974. onError(scene, errorMessage, exception);
  48975. }
  48976. else {
  48977. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48978. // should the exception be thrown?
  48979. }
  48980. disposeHandler();
  48981. };
  48982. var progressHandler = onProgress ? function (event) {
  48983. try {
  48984. onProgress(event);
  48985. }
  48986. catch (e) {
  48987. errorHandler("Error in onProgress callback", e);
  48988. }
  48989. } : undefined;
  48990. var successHandler = function () {
  48991. if (onSuccess) {
  48992. try {
  48993. onSuccess(scene);
  48994. }
  48995. catch (e) {
  48996. errorHandler("Error in onSuccess callback", e);
  48997. }
  48998. }
  48999. scene._removePendingData(loadingToken);
  49000. };
  49001. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49002. if (plugin.load) {
  49003. var syncedPlugin = plugin;
  49004. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  49005. return;
  49006. }
  49007. scene.loadingPluginName = plugin.name;
  49008. successHandler();
  49009. }
  49010. else {
  49011. var asyncedPlugin = plugin;
  49012. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  49013. scene.loadingPluginName = plugin.name;
  49014. successHandler();
  49015. }).catch(function (error) {
  49016. errorHandler(error.message, error);
  49017. });
  49018. }
  49019. if (SceneLoader.ShowLoadingScreen) {
  49020. scene.executeWhenReady(function () {
  49021. scene.getEngine().hideLoadingUI();
  49022. });
  49023. }
  49024. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49025. };
  49026. /**
  49027. * Append a scene
  49028. * @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)
  49029. * @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)
  49030. * @param scene is the instance of BABYLON.Scene to append to
  49031. * @param onProgress a callback with a progress event for each file being loaded
  49032. * @param pluginExtension the extension used to determine the plugin
  49033. * @returns The given scene
  49034. */
  49035. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49036. if (sceneFilename === void 0) { sceneFilename = ""; }
  49037. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49038. if (onProgress === void 0) { onProgress = null; }
  49039. if (pluginExtension === void 0) { pluginExtension = null; }
  49040. return new Promise(function (resolve, reject) {
  49041. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  49042. resolve(scene);
  49043. }, onProgress, function (scene, message, exception) {
  49044. reject(exception || new Error(message));
  49045. }, pluginExtension);
  49046. });
  49047. };
  49048. /**
  49049. * Load a scene into an asset container
  49050. * @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)
  49051. * @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)
  49052. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49053. * @param onSuccess a callback with the scene when import succeeds
  49054. * @param onProgress a callback with a progress event for each file being loaded
  49055. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49056. * @param pluginExtension the extension used to determine the plugin
  49057. * @returns The loaded plugin
  49058. */
  49059. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49060. if (sceneFilename === void 0) { sceneFilename = ""; }
  49061. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49062. if (onSuccess === void 0) { onSuccess = null; }
  49063. if (onProgress === void 0) { onProgress = null; }
  49064. if (onError === void 0) { onError = null; }
  49065. if (pluginExtension === void 0) { pluginExtension = null; }
  49066. if (!scene) {
  49067. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  49068. return null;
  49069. }
  49070. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49071. if (!fileInfo) {
  49072. return null;
  49073. }
  49074. var loadingToken = {};
  49075. scene._addPendingData(loadingToken);
  49076. var disposeHandler = function () {
  49077. scene._removePendingData(loadingToken);
  49078. };
  49079. var errorHandler = function (message, exception) {
  49080. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  49081. if (onError) {
  49082. onError(scene, errorMessage, exception);
  49083. }
  49084. else {
  49085. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49086. // should the exception be thrown?
  49087. }
  49088. disposeHandler();
  49089. };
  49090. var progressHandler = onProgress ? function (event) {
  49091. try {
  49092. onProgress(event);
  49093. }
  49094. catch (e) {
  49095. errorHandler("Error in onProgress callback", e);
  49096. }
  49097. } : undefined;
  49098. var successHandler = function (assets) {
  49099. if (onSuccess) {
  49100. try {
  49101. onSuccess(assets);
  49102. }
  49103. catch (e) {
  49104. errorHandler("Error in onSuccess callback", e);
  49105. }
  49106. }
  49107. scene._removePendingData(loadingToken);
  49108. };
  49109. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49110. if (plugin.loadAssetContainer) {
  49111. var syncedPlugin = plugin;
  49112. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  49113. if (!assetContainer) {
  49114. return;
  49115. }
  49116. scene.loadingPluginName = plugin.name;
  49117. successHandler(assetContainer);
  49118. }
  49119. else if (plugin.loadAssetContainerAsync) {
  49120. var asyncedPlugin = plugin;
  49121. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49122. scene.loadingPluginName = plugin.name;
  49123. successHandler(assetContainer);
  49124. }).catch(function (error) {
  49125. errorHandler(error.message, error);
  49126. });
  49127. }
  49128. else {
  49129. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49130. }
  49131. if (SceneLoader.ShowLoadingScreen) {
  49132. scene.executeWhenReady(function () {
  49133. scene.getEngine().hideLoadingUI();
  49134. });
  49135. }
  49136. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49137. };
  49138. /**
  49139. * Load a scene into an asset container
  49140. * @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)
  49141. * @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)
  49142. * @param scene is the instance of Scene to append to
  49143. * @param onProgress a callback with a progress event for each file being loaded
  49144. * @param pluginExtension the extension used to determine the plugin
  49145. * @returns The loaded asset container
  49146. */
  49147. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49148. if (sceneFilename === void 0) { sceneFilename = ""; }
  49149. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49150. if (onProgress === void 0) { onProgress = null; }
  49151. if (pluginExtension === void 0) { pluginExtension = null; }
  49152. return new Promise(function (resolve, reject) {
  49153. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  49154. resolve(assetContainer);
  49155. }, onProgress, function (scene, message, exception) {
  49156. reject(exception || new Error(message));
  49157. }, pluginExtension);
  49158. });
  49159. };
  49160. /**
  49161. * No logging while loading
  49162. */
  49163. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  49164. /**
  49165. * Minimal logging while loading
  49166. */
  49167. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  49168. /**
  49169. * Summary logging while loading
  49170. */
  49171. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  49172. /**
  49173. * Detailled logging while loading
  49174. */
  49175. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  49176. // Members
  49177. /**
  49178. * Event raised when a plugin is used to load a scene
  49179. */
  49180. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  49181. SceneLoader._registeredPlugins = {};
  49182. return SceneLoader;
  49183. }());
  49184. /***/ }),
  49185. /***/ "./Loading/sceneLoaderFlags.ts":
  49186. /*!*************************************!*\
  49187. !*** ./Loading/sceneLoaderFlags.ts ***!
  49188. \*************************************/
  49189. /*! exports provided: SceneLoaderFlags */
  49190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49191. "use strict";
  49192. __webpack_require__.r(__webpack_exports__);
  49193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  49194. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49195. /**
  49196. * Class used to represent data loading progression
  49197. */
  49198. var SceneLoaderFlags = /** @class */ (function () {
  49199. function SceneLoaderFlags() {
  49200. }
  49201. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  49202. /**
  49203. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49204. */
  49205. get: function () {
  49206. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  49207. },
  49208. set: function (value) {
  49209. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  49210. },
  49211. enumerable: true,
  49212. configurable: true
  49213. });
  49214. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  49215. /**
  49216. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49217. */
  49218. get: function () {
  49219. return SceneLoaderFlags._ShowLoadingScreen;
  49220. },
  49221. set: function (value) {
  49222. SceneLoaderFlags._ShowLoadingScreen = value;
  49223. },
  49224. enumerable: true,
  49225. configurable: true
  49226. });
  49227. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  49228. /**
  49229. * Defines the current logging level (while loading the scene)
  49230. * @ignorenaming
  49231. */
  49232. get: function () {
  49233. return SceneLoaderFlags._loggingLevel;
  49234. },
  49235. set: function (value) {
  49236. SceneLoaderFlags._loggingLevel = value;
  49237. },
  49238. enumerable: true,
  49239. configurable: true
  49240. });
  49241. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  49242. /**
  49243. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49244. */
  49245. get: function () {
  49246. return SceneLoaderFlags._CleanBoneMatrixWeights;
  49247. },
  49248. set: function (value) {
  49249. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  49250. },
  49251. enumerable: true,
  49252. configurable: true
  49253. });
  49254. // Flags
  49255. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  49256. SceneLoaderFlags._ShowLoadingScreen = true;
  49257. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  49258. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  49259. return SceneLoaderFlags;
  49260. }());
  49261. /***/ }),
  49262. /***/ "./Materials/Background/backgroundMaterial.ts":
  49263. /*!****************************************************!*\
  49264. !*** ./Materials/Background/backgroundMaterial.ts ***!
  49265. \****************************************************/
  49266. /*! exports provided: BackgroundMaterial */
  49267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49268. "use strict";
  49269. __webpack_require__.r(__webpack_exports__);
  49270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  49271. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49272. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49273. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49274. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49275. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49276. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49277. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49278. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49279. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49280. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49281. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49282. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49283. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49284. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49285. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49286. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  49287. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  49288. /**
  49289. * Background material defines definition.
  49290. * @hidden Mainly internal Use
  49291. */
  49292. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  49293. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49294. /**
  49295. * Constructor of the defines.
  49296. */
  49297. function BackgroundMaterialDefines() {
  49298. var _this = _super.call(this) || this;
  49299. /**
  49300. * True if the diffuse texture is in use.
  49301. */
  49302. _this.DIFFUSE = false;
  49303. /**
  49304. * The direct UV channel to use.
  49305. */
  49306. _this.DIFFUSEDIRECTUV = 0;
  49307. /**
  49308. * True if the diffuse texture is in gamma space.
  49309. */
  49310. _this.GAMMADIFFUSE = false;
  49311. /**
  49312. * True if the diffuse texture has opacity in the alpha channel.
  49313. */
  49314. _this.DIFFUSEHASALPHA = false;
  49315. /**
  49316. * True if you want the material to fade to transparent at grazing angle.
  49317. */
  49318. _this.OPACITYFRESNEL = false;
  49319. /**
  49320. * True if an extra blur needs to be added in the reflection.
  49321. */
  49322. _this.REFLECTIONBLUR = false;
  49323. /**
  49324. * True if you want the material to fade to reflection at grazing angle.
  49325. */
  49326. _this.REFLECTIONFRESNEL = false;
  49327. /**
  49328. * True if you want the material to falloff as far as you move away from the scene center.
  49329. */
  49330. _this.REFLECTIONFALLOFF = false;
  49331. /**
  49332. * False if the current Webgl implementation does not support the texture lod extension.
  49333. */
  49334. _this.TEXTURELODSUPPORT = false;
  49335. /**
  49336. * True to ensure the data are premultiplied.
  49337. */
  49338. _this.PREMULTIPLYALPHA = false;
  49339. /**
  49340. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  49341. */
  49342. _this.USERGBCOLOR = false;
  49343. /**
  49344. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  49345. * stays aligned with the desired configuration.
  49346. */
  49347. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  49348. /**
  49349. * True to add noise in order to reduce the banding effect.
  49350. */
  49351. _this.NOISE = false;
  49352. /**
  49353. * is the reflection texture in BGR color scheme?
  49354. * Mainly used to solve a bug in ios10 video tag
  49355. */
  49356. _this.REFLECTIONBGR = false;
  49357. _this.IMAGEPROCESSING = false;
  49358. _this.VIGNETTE = false;
  49359. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49360. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49361. _this.TONEMAPPING = false;
  49362. _this.TONEMAPPING_ACES = false;
  49363. _this.CONTRAST = false;
  49364. _this.COLORCURVES = false;
  49365. _this.COLORGRADING = false;
  49366. _this.COLORGRADING3D = false;
  49367. _this.SAMPLER3DGREENDEPTH = false;
  49368. _this.SAMPLER3DBGRMAP = false;
  49369. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49370. _this.EXPOSURE = false;
  49371. // Reflection.
  49372. _this.REFLECTION = false;
  49373. _this.REFLECTIONMAP_3D = false;
  49374. _this.REFLECTIONMAP_SPHERICAL = false;
  49375. _this.REFLECTIONMAP_PLANAR = false;
  49376. _this.REFLECTIONMAP_CUBIC = false;
  49377. _this.REFLECTIONMAP_PROJECTION = false;
  49378. _this.REFLECTIONMAP_SKYBOX = false;
  49379. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49380. _this.REFLECTIONMAP_EXPLICIT = false;
  49381. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49382. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49383. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49384. _this.INVERTCUBICMAP = false;
  49385. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49386. _this.LODINREFLECTIONALPHA = false;
  49387. _this.GAMMAREFLECTION = false;
  49388. _this.RGBDREFLECTION = false;
  49389. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  49390. // Default BJS.
  49391. _this.MAINUV1 = false;
  49392. _this.MAINUV2 = false;
  49393. _this.UV1 = false;
  49394. _this.UV2 = false;
  49395. _this.CLIPPLANE = false;
  49396. _this.CLIPPLANE2 = false;
  49397. _this.CLIPPLANE3 = false;
  49398. _this.CLIPPLANE4 = false;
  49399. _this.POINTSIZE = false;
  49400. _this.FOG = false;
  49401. _this.NORMAL = false;
  49402. _this.NUM_BONE_INFLUENCERS = 0;
  49403. _this.BonesPerMesh = 0;
  49404. _this.INSTANCES = false;
  49405. _this.SHADOWFLOAT = false;
  49406. _this.rebuild();
  49407. return _this;
  49408. }
  49409. return BackgroundMaterialDefines;
  49410. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  49411. /**
  49412. * Background material used to create an efficient environement around your scene.
  49413. */
  49414. var BackgroundMaterial = /** @class */ (function (_super) {
  49415. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  49416. /**
  49417. * Instantiates a Background Material in the given scene
  49418. * @param name The friendly name of the material
  49419. * @param scene The scene to add the material to
  49420. */
  49421. function BackgroundMaterial(name, scene) {
  49422. var _this = _super.call(this, name, scene) || this;
  49423. /**
  49424. * Key light Color (multiply against the environement texture)
  49425. */
  49426. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49427. _this._primaryColorShadowLevel = 0;
  49428. _this._primaryColorHighlightLevel = 0;
  49429. /**
  49430. * Reflection Texture used in the material.
  49431. * Should be author in a specific way for the best result (refer to the documentation).
  49432. */
  49433. _this.reflectionTexture = null;
  49434. /**
  49435. * Reflection Texture level of blur.
  49436. *
  49437. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49438. * texture twice.
  49439. */
  49440. _this.reflectionBlur = 0;
  49441. /**
  49442. * Diffuse Texture used in the material.
  49443. * Should be author in a specific way for the best result (refer to the documentation).
  49444. */
  49445. _this.diffuseTexture = null;
  49446. _this._shadowLights = null;
  49447. /**
  49448. * Specify the list of lights casting shadow on the material.
  49449. * All scene shadow lights will be included if null.
  49450. */
  49451. _this.shadowLights = null;
  49452. /**
  49453. * Helps adjusting the shadow to a softer level if required.
  49454. * 0 means black shadows and 1 means no shadows.
  49455. */
  49456. _this.shadowLevel = 0;
  49457. /**
  49458. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49459. * It is usually zero but might be interesting to modify according to your setup.
  49460. */
  49461. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  49462. /**
  49463. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49464. * This helps ensuring a nice transition when the camera goes under the ground.
  49465. */
  49466. _this.opacityFresnel = true;
  49467. /**
  49468. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49469. * This helps adding a mirror texture on the ground.
  49470. */
  49471. _this.reflectionFresnel = false;
  49472. /**
  49473. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49474. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49475. */
  49476. _this.reflectionFalloffDistance = 0.0;
  49477. /**
  49478. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49479. */
  49480. _this.reflectionAmount = 1.0;
  49481. /**
  49482. * This specifies the weight of the reflection at grazing angle.
  49483. */
  49484. _this.reflectionReflectance0 = 0.05;
  49485. /**
  49486. * This specifies the weight of the reflection at a perpendicular point of view.
  49487. */
  49488. _this.reflectionReflectance90 = 0.5;
  49489. /**
  49490. * Helps to directly use the maps channels instead of their level.
  49491. */
  49492. _this.useRGBColor = true;
  49493. /**
  49494. * This helps reducing the banding effect that could occur on the background.
  49495. */
  49496. _this.enableNoise = false;
  49497. _this._fovMultiplier = 1.0;
  49498. /**
  49499. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49500. */
  49501. _this.useEquirectangularFOV = false;
  49502. _this._maxSimultaneousLights = 4;
  49503. /**
  49504. * Number of Simultaneous lights allowed on the material.
  49505. */
  49506. _this.maxSimultaneousLights = 4;
  49507. /**
  49508. * Keep track of the image processing observer to allow dispose and replace.
  49509. */
  49510. _this._imageProcessingObserver = null;
  49511. /**
  49512. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49513. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49514. */
  49515. _this.switchToBGR = false;
  49516. // Temp values kept as cache in the material.
  49517. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  49518. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  49519. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49520. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49521. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49522. // Setup the default processing configuration to the scene.
  49523. _this._attachImageProcessingConfiguration(null);
  49524. _this.getRenderTargetTextures = function () {
  49525. _this._renderTargets.reset();
  49526. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  49527. _this._renderTargets.push(_this._diffuseTexture);
  49528. }
  49529. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  49530. _this._renderTargets.push(_this._reflectionTexture);
  49531. }
  49532. return _this._renderTargets;
  49533. };
  49534. return _this;
  49535. }
  49536. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  49537. /**
  49538. * Experimental Internal Use Only.
  49539. *
  49540. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49541. * This acts as a helper to set the primary color to a more "human friendly" value.
  49542. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49543. * output color as close as possible from the chosen value.
  49544. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49545. * part of lighting setup.)
  49546. */
  49547. get: function () {
  49548. return this.__perceptualColor;
  49549. },
  49550. set: function (value) {
  49551. this.__perceptualColor = value;
  49552. this._computePrimaryColorFromPerceptualColor();
  49553. this._markAllSubMeshesAsLightsDirty();
  49554. },
  49555. enumerable: true,
  49556. configurable: true
  49557. });
  49558. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  49559. /**
  49560. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49561. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49562. */
  49563. get: function () {
  49564. return this._primaryColorShadowLevel;
  49565. },
  49566. set: function (value) {
  49567. this._primaryColorShadowLevel = value;
  49568. this._computePrimaryColors();
  49569. this._markAllSubMeshesAsLightsDirty();
  49570. },
  49571. enumerable: true,
  49572. configurable: true
  49573. });
  49574. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  49575. /**
  49576. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49577. * The primary color is used at the level chosen to define what the white area would look.
  49578. */
  49579. get: function () {
  49580. return this._primaryColorHighlightLevel;
  49581. },
  49582. set: function (value) {
  49583. this._primaryColorHighlightLevel = value;
  49584. this._computePrimaryColors();
  49585. this._markAllSubMeshesAsLightsDirty();
  49586. },
  49587. enumerable: true,
  49588. configurable: true
  49589. });
  49590. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  49591. /**
  49592. * Sets the reflection reflectance fresnel values according to the default standard
  49593. * empirically know to work well :-)
  49594. */
  49595. set: function (value) {
  49596. var reflectionWeight = value;
  49597. if (reflectionWeight < 0.5) {
  49598. reflectionWeight = reflectionWeight * 2.0;
  49599. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  49600. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  49601. }
  49602. else {
  49603. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  49604. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  49605. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  49606. }
  49607. },
  49608. enumerable: true,
  49609. configurable: true
  49610. });
  49611. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  49612. /**
  49613. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49614. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49615. * Recommended to be keep at 1.0 except for special cases.
  49616. */
  49617. get: function () {
  49618. return this._fovMultiplier;
  49619. },
  49620. set: function (value) {
  49621. if (isNaN(value)) {
  49622. value = 1.0;
  49623. }
  49624. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  49625. },
  49626. enumerable: true,
  49627. configurable: true
  49628. });
  49629. /**
  49630. * Attaches a new image processing configuration to the PBR Material.
  49631. * @param configuration (if null the scene configuration will be use)
  49632. */
  49633. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  49634. var _this = this;
  49635. if (configuration === this._imageProcessingConfiguration) {
  49636. return;
  49637. }
  49638. // Detaches observer.
  49639. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49640. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49641. }
  49642. // Pick the scene configuration if needed.
  49643. if (!configuration) {
  49644. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  49645. }
  49646. else {
  49647. this._imageProcessingConfiguration = configuration;
  49648. }
  49649. // Attaches observer.
  49650. if (this._imageProcessingConfiguration) {
  49651. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  49652. _this._computePrimaryColorFromPerceptualColor();
  49653. _this._markAllSubMeshesAsImageProcessingDirty();
  49654. });
  49655. }
  49656. };
  49657. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  49658. /**
  49659. * Gets the image processing configuration used either in this material.
  49660. */
  49661. get: function () {
  49662. return this._imageProcessingConfiguration;
  49663. },
  49664. /**
  49665. * Sets the Default image processing configuration used either in the this material.
  49666. *
  49667. * If sets to null, the scene one is in use.
  49668. */
  49669. set: function (value) {
  49670. this._attachImageProcessingConfiguration(value);
  49671. // Ensure the effect will be rebuilt.
  49672. this._markAllSubMeshesAsTexturesDirty();
  49673. },
  49674. enumerable: true,
  49675. configurable: true
  49676. });
  49677. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  49678. /**
  49679. * Gets wether the color curves effect is enabled.
  49680. */
  49681. get: function () {
  49682. return this.imageProcessingConfiguration.colorCurvesEnabled;
  49683. },
  49684. /**
  49685. * Sets wether the color curves effect is enabled.
  49686. */
  49687. set: function (value) {
  49688. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  49689. },
  49690. enumerable: true,
  49691. configurable: true
  49692. });
  49693. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  49694. /**
  49695. * Gets wether the color grading effect is enabled.
  49696. */
  49697. get: function () {
  49698. return this.imageProcessingConfiguration.colorGradingEnabled;
  49699. },
  49700. /**
  49701. * Gets wether the color grading effect is enabled.
  49702. */
  49703. set: function (value) {
  49704. this.imageProcessingConfiguration.colorGradingEnabled = value;
  49705. },
  49706. enumerable: true,
  49707. configurable: true
  49708. });
  49709. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  49710. /**
  49711. * Gets wether tonemapping is enabled or not.
  49712. */
  49713. get: function () {
  49714. return this._imageProcessingConfiguration.toneMappingEnabled;
  49715. },
  49716. /**
  49717. * Sets wether tonemapping is enabled or not
  49718. */
  49719. set: function (value) {
  49720. this._imageProcessingConfiguration.toneMappingEnabled = value;
  49721. },
  49722. enumerable: true,
  49723. configurable: true
  49724. });
  49725. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  49726. /**
  49727. * The camera exposure used on this material.
  49728. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49729. * This corresponds to a photographic exposure.
  49730. */
  49731. get: function () {
  49732. return this._imageProcessingConfiguration.exposure;
  49733. },
  49734. /**
  49735. * The camera exposure used on this material.
  49736. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49737. * This corresponds to a photographic exposure.
  49738. */
  49739. set: function (value) {
  49740. this._imageProcessingConfiguration.exposure = value;
  49741. },
  49742. enumerable: true,
  49743. configurable: true
  49744. });
  49745. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  49746. /**
  49747. * Gets The camera contrast used on this material.
  49748. */
  49749. get: function () {
  49750. return this._imageProcessingConfiguration.contrast;
  49751. },
  49752. /**
  49753. * Sets The camera contrast used on this material.
  49754. */
  49755. set: function (value) {
  49756. this._imageProcessingConfiguration.contrast = value;
  49757. },
  49758. enumerable: true,
  49759. configurable: true
  49760. });
  49761. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  49762. /**
  49763. * Gets the Color Grading 2D Lookup Texture.
  49764. */
  49765. get: function () {
  49766. return this._imageProcessingConfiguration.colorGradingTexture;
  49767. },
  49768. /**
  49769. * Sets the Color Grading 2D Lookup Texture.
  49770. */
  49771. set: function (value) {
  49772. this.imageProcessingConfiguration.colorGradingTexture = value;
  49773. },
  49774. enumerable: true,
  49775. configurable: true
  49776. });
  49777. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  49778. /**
  49779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49781. * 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;
  49782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49783. */
  49784. get: function () {
  49785. return this.imageProcessingConfiguration.colorCurves;
  49786. },
  49787. /**
  49788. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49789. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49790. * 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;
  49791. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49792. */
  49793. set: function (value) {
  49794. this.imageProcessingConfiguration.colorCurves = value;
  49795. },
  49796. enumerable: true,
  49797. configurable: true
  49798. });
  49799. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  49800. /**
  49801. * Gets a boolean indicating that current material needs to register RTT
  49802. */
  49803. get: function () {
  49804. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49805. return true;
  49806. }
  49807. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49808. return true;
  49809. }
  49810. return false;
  49811. },
  49812. enumerable: true,
  49813. configurable: true
  49814. });
  49815. /**
  49816. * The entire material has been created in order to prevent overdraw.
  49817. * @returns false
  49818. */
  49819. BackgroundMaterial.prototype.needAlphaTesting = function () {
  49820. return true;
  49821. };
  49822. /**
  49823. * The entire material has been created in order to prevent overdraw.
  49824. * @returns true if blending is enable
  49825. */
  49826. BackgroundMaterial.prototype.needAlphaBlending = function () {
  49827. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  49828. };
  49829. /**
  49830. * Checks wether the material is ready to be rendered for a given mesh.
  49831. * @param mesh The mesh to render
  49832. * @param subMesh The submesh to check against
  49833. * @param useInstances Specify wether or not the material is used with instances
  49834. * @returns true if all the dependencies are ready (Textures, Effects...)
  49835. */
  49836. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  49837. var _this = this;
  49838. if (useInstances === void 0) { useInstances = false; }
  49839. if (subMesh.effect && this.isFrozen) {
  49840. if (this._wasPreviouslyReady) {
  49841. return true;
  49842. }
  49843. }
  49844. if (!subMesh._materialDefines) {
  49845. subMesh._materialDefines = new BackgroundMaterialDefines();
  49846. }
  49847. var scene = this.getScene();
  49848. var defines = subMesh._materialDefines;
  49849. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  49850. if (defines._renderId === scene.getRenderId()) {
  49851. return true;
  49852. }
  49853. }
  49854. var engine = scene.getEngine();
  49855. // Lights
  49856. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  49857. defines._needNormals = true;
  49858. // Textures
  49859. if (defines._areTexturesDirty) {
  49860. defines._needUVs = false;
  49861. if (scene.texturesEnabled) {
  49862. if (scene.getEngine().getCaps().textureLOD) {
  49863. defines.TEXTURELODSUPPORT = true;
  49864. }
  49865. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49866. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  49867. return false;
  49868. }
  49869. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  49870. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  49871. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  49872. defines.OPACITYFRESNEL = this._opacityFresnel;
  49873. }
  49874. else {
  49875. defines.DIFFUSE = false;
  49876. defines.DIFFUSEHASALPHA = false;
  49877. defines.GAMMADIFFUSE = false;
  49878. defines.OPACITYFRESNEL = false;
  49879. }
  49880. var reflectionTexture = this._reflectionTexture;
  49881. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49882. if (!reflectionTexture.isReadyOrNotBlocking()) {
  49883. return false;
  49884. }
  49885. defines.REFLECTION = true;
  49886. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  49887. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  49888. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  49889. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  49890. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  49891. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  49892. defines.REFLECTIONBGR = this.switchToBGR;
  49893. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  49894. defines.INVERTCUBICMAP = true;
  49895. }
  49896. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  49897. switch (reflectionTexture.coordinatesMode) {
  49898. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  49899. defines.REFLECTIONMAP_EXPLICIT = true;
  49900. break;
  49901. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  49902. defines.REFLECTIONMAP_PLANAR = true;
  49903. break;
  49904. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  49905. defines.REFLECTIONMAP_PROJECTION = true;
  49906. break;
  49907. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  49908. defines.REFLECTIONMAP_SKYBOX = true;
  49909. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  49910. break;
  49911. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  49912. defines.REFLECTIONMAP_SPHERICAL = true;
  49913. break;
  49914. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  49915. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  49916. break;
  49917. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  49918. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  49919. break;
  49920. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  49921. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  49922. break;
  49923. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  49924. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  49925. default:
  49926. defines.REFLECTIONMAP_CUBIC = true;
  49927. break;
  49928. }
  49929. if (this.reflectionFresnel) {
  49930. defines.REFLECTIONFRESNEL = true;
  49931. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  49932. this._reflectionControls.x = this.reflectionAmount;
  49933. this._reflectionControls.y = this.reflectionReflectance0;
  49934. this._reflectionControls.z = this.reflectionReflectance90;
  49935. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  49936. }
  49937. else {
  49938. defines.REFLECTIONFRESNEL = false;
  49939. defines.REFLECTIONFALLOFF = false;
  49940. }
  49941. }
  49942. else {
  49943. defines.REFLECTION = false;
  49944. defines.REFLECTIONFRESNEL = false;
  49945. defines.REFLECTIONFALLOFF = false;
  49946. defines.REFLECTIONBLUR = false;
  49947. defines.REFLECTIONMAP_3D = false;
  49948. defines.REFLECTIONMAP_SPHERICAL = false;
  49949. defines.REFLECTIONMAP_PLANAR = false;
  49950. defines.REFLECTIONMAP_CUBIC = false;
  49951. defines.REFLECTIONMAP_PROJECTION = false;
  49952. defines.REFLECTIONMAP_SKYBOX = false;
  49953. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49954. defines.REFLECTIONMAP_EXPLICIT = false;
  49955. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49956. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49957. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49958. defines.INVERTCUBICMAP = false;
  49959. defines.REFLECTIONMAP_OPPOSITEZ = false;
  49960. defines.LODINREFLECTIONALPHA = false;
  49961. defines.GAMMAREFLECTION = false;
  49962. defines.RGBDREFLECTION = false;
  49963. }
  49964. }
  49965. 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);
  49966. defines.USERGBCOLOR = this._useRGBColor;
  49967. defines.NOISE = this._enableNoise;
  49968. }
  49969. if (defines._areLightsDirty) {
  49970. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  49971. }
  49972. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  49973. if (!this._imageProcessingConfiguration.isReady()) {
  49974. return false;
  49975. }
  49976. this._imageProcessingConfiguration.prepareDefines(defines);
  49977. }
  49978. // Misc.
  49979. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  49980. // Values that need to be evaluated on every frame
  49981. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  49982. // Attribs
  49983. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  49984. if (mesh) {
  49985. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  49986. mesh.createNormals(true);
  49987. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  49988. }
  49989. }
  49990. }
  49991. // Get correct effect
  49992. if (defines.isDirty) {
  49993. defines.markAsProcessed();
  49994. scene.resetCachedMaterial();
  49995. // Fallbacks
  49996. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  49997. if (defines.FOG) {
  49998. fallbacks.addFallback(0, "FOG");
  49999. }
  50000. if (defines.POINTSIZE) {
  50001. fallbacks.addFallback(1, "POINTSIZE");
  50002. }
  50003. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  50004. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50005. fallbacks.addCPUSkinningFallback(0, mesh);
  50006. }
  50007. //Attributes
  50008. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  50009. if (defines.NORMAL) {
  50010. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  50011. }
  50012. if (defines.UV1) {
  50013. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  50014. }
  50015. if (defines.UV2) {
  50016. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  50017. }
  50018. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50019. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50020. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  50021. "vFogInfos", "vFogColor", "pointSize",
  50022. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  50023. "vPrimaryColor", "vPrimaryColorShadow",
  50024. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  50025. "shadowLevel", "alpha",
  50026. "vBackgroundCenter", "vReflectionControl",
  50027. "vDiffuseInfos", "diffuseMatrix",
  50028. ];
  50029. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  50030. var uniformBuffers = ["Material", "Scene"];
  50031. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  50032. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50033. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50034. }
  50035. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50036. uniformsNames: uniforms,
  50037. uniformBuffersNames: uniformBuffers,
  50038. samplers: samplers,
  50039. defines: defines,
  50040. maxSimultaneousLights: this._maxSimultaneousLights
  50041. });
  50042. var onCompiled = function (effect) {
  50043. if (_this.onCompiled) {
  50044. _this.onCompiled(effect);
  50045. }
  50046. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  50047. };
  50048. var join = defines.toString();
  50049. subMesh.setEffect(scene.getEngine().createEffect("background", {
  50050. attributes: attribs,
  50051. uniformsNames: uniforms,
  50052. uniformBuffersNames: uniformBuffers,
  50053. samplers: samplers,
  50054. defines: join,
  50055. fallbacks: fallbacks,
  50056. onCompiled: onCompiled,
  50057. onError: this.onError,
  50058. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  50059. }, engine), defines);
  50060. this.buildUniformLayout();
  50061. }
  50062. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50063. return false;
  50064. }
  50065. defines._renderId = scene.getRenderId();
  50066. this._wasPreviouslyReady = true;
  50067. return true;
  50068. };
  50069. /**
  50070. * Compute the primary color according to the chosen perceptual color.
  50071. */
  50072. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  50073. if (!this.__perceptualColor) {
  50074. return;
  50075. }
  50076. this._primaryColor.copyFrom(this.__perceptualColor);
  50077. // Revert gamma space.
  50078. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  50079. // Revert image processing configuration.
  50080. if (this._imageProcessingConfiguration) {
  50081. // Revert Exposure.
  50082. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  50083. }
  50084. this._computePrimaryColors();
  50085. };
  50086. /**
  50087. * Compute the highlights and shadow colors according to their chosen levels.
  50088. */
  50089. BackgroundMaterial.prototype._computePrimaryColors = function () {
  50090. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  50091. return;
  50092. }
  50093. // Find the highlight color based on the configuration.
  50094. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  50095. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  50096. // Find the shadow color based on the configuration.
  50097. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  50098. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  50099. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  50100. };
  50101. /**
  50102. * Build the uniform buffer used in the material.
  50103. */
  50104. BackgroundMaterial.prototype.buildUniformLayout = function () {
  50105. // Order is important !
  50106. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  50107. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  50108. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  50109. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50110. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  50111. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50112. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50113. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  50114. this._uniformBuffer.addUniform("pointSize", 1);
  50115. this._uniformBuffer.addUniform("shadowLevel", 1);
  50116. this._uniformBuffer.addUniform("alpha", 1);
  50117. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  50118. this._uniformBuffer.addUniform("vReflectionControl", 4);
  50119. this._uniformBuffer.create();
  50120. };
  50121. /**
  50122. * Unbind the material.
  50123. */
  50124. BackgroundMaterial.prototype.unbind = function () {
  50125. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50126. this._uniformBuffer.setTexture("diffuseSampler", null);
  50127. }
  50128. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50129. this._uniformBuffer.setTexture("reflectionSampler", null);
  50130. }
  50131. _super.prototype.unbind.call(this);
  50132. };
  50133. /**
  50134. * Bind only the world matrix to the material.
  50135. * @param world The world matrix to bind.
  50136. */
  50137. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  50138. this._activeEffect.setMatrix("world", world);
  50139. };
  50140. /**
  50141. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50142. * @param world The world matrix to bind.
  50143. * @param subMesh The submesh to bind for.
  50144. */
  50145. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50146. var scene = this.getScene();
  50147. var defines = subMesh._materialDefines;
  50148. if (!defines) {
  50149. return;
  50150. }
  50151. var effect = subMesh.effect;
  50152. if (!effect) {
  50153. return;
  50154. }
  50155. this._activeEffect = effect;
  50156. // Matrices
  50157. this.bindOnlyWorldMatrix(world);
  50158. // Bones
  50159. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50160. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50161. if (mustRebind) {
  50162. this._uniformBuffer.bindToEffect(effect, "Material");
  50163. this.bindViewProjection(effect);
  50164. var reflectionTexture = this._reflectionTexture;
  50165. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50166. // Texture uniforms
  50167. if (scene.texturesEnabled) {
  50168. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50169. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  50170. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  50171. }
  50172. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50173. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50174. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  50175. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50176. }
  50177. }
  50178. if (this.shadowLevel > 0) {
  50179. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  50180. }
  50181. this._uniformBuffer.updateFloat("alpha", this.alpha);
  50182. // Point size
  50183. if (this.pointsCloud) {
  50184. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50185. }
  50186. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  50187. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  50188. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  50189. }
  50190. else {
  50191. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  50192. }
  50193. }
  50194. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  50195. // Textures
  50196. if (scene.texturesEnabled) {
  50197. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50198. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  50199. }
  50200. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50201. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  50202. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50203. }
  50204. else if (!defines.REFLECTIONBLUR) {
  50205. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50206. }
  50207. else {
  50208. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50209. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50210. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50211. }
  50212. if (defines.REFLECTIONFRESNEL) {
  50213. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  50214. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  50215. }
  50216. }
  50217. }
  50218. // Clip plane
  50219. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50220. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  50221. }
  50222. if (mustRebind || !this.isFrozen) {
  50223. if (scene.lightsEnabled) {
  50224. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  50225. }
  50226. // View
  50227. this.bindView(effect);
  50228. // Fog
  50229. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50230. // image processing
  50231. if (this._imageProcessingConfiguration) {
  50232. this._imageProcessingConfiguration.bind(this._activeEffect);
  50233. }
  50234. }
  50235. this._uniformBuffer.update();
  50236. this._afterBind(mesh, this._activeEffect);
  50237. };
  50238. /**
  50239. * Dispose the material.
  50240. * @param forceDisposeEffect Force disposal of the associated effect.
  50241. * @param forceDisposeTextures Force disposal of the associated textures.
  50242. */
  50243. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50244. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  50245. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  50246. if (forceDisposeTextures) {
  50247. if (this.diffuseTexture) {
  50248. this.diffuseTexture.dispose();
  50249. }
  50250. if (this.reflectionTexture) {
  50251. this.reflectionTexture.dispose();
  50252. }
  50253. }
  50254. this._renderTargets.dispose();
  50255. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50256. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50257. }
  50258. _super.prototype.dispose.call(this, forceDisposeEffect);
  50259. };
  50260. /**
  50261. * Clones the material.
  50262. * @param name The cloned name.
  50263. * @returns The cloned material.
  50264. */
  50265. BackgroundMaterial.prototype.clone = function (name) {
  50266. var _this = this;
  50267. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  50268. };
  50269. /**
  50270. * Serializes the current material to its JSON representation.
  50271. * @returns The JSON representation.
  50272. */
  50273. BackgroundMaterial.prototype.serialize = function () {
  50274. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50275. serializationObject.customType = "BABYLON.BackgroundMaterial";
  50276. return serializationObject;
  50277. };
  50278. /**
  50279. * Gets the class name of the material
  50280. * @returns "BackgroundMaterial"
  50281. */
  50282. BackgroundMaterial.prototype.getClassName = function () {
  50283. return "BackgroundMaterial";
  50284. };
  50285. /**
  50286. * Parse a JSON input to create back a background material.
  50287. * @param source The JSON data to parse
  50288. * @param scene The scene to create the parsed material in
  50289. * @param rootUrl The root url of the assets the material depends upon
  50290. * @returns the instantiated BackgroundMaterial.
  50291. */
  50292. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  50293. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50294. };
  50295. /**
  50296. * Standard reflectance value at parallel view angle.
  50297. */
  50298. BackgroundMaterial.StandardReflectance0 = 0.05;
  50299. /**
  50300. * Standard reflectance value at grazing angle.
  50301. */
  50302. BackgroundMaterial.StandardReflectance90 = 0.5;
  50303. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50304. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50305. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  50306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50308. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  50309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50311. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  50312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50314. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  50315. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50316. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50317. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  50318. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50320. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  50321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50323. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  50324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50326. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  50327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50329. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  50330. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50332. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  50333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50335. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  50336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50338. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  50339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50341. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  50342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50344. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  50345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50347. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  50348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50350. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  50351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50353. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  50354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50356. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  50357. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50359. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  50360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50362. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  50363. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50364. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50365. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  50366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50368. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  50369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50371. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  50372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50374. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  50375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50377. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  50378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50380. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  50381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50383. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  50384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50386. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  50387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50389. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  50390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50392. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  50393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50395. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  50396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50398. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  50399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50401. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  50402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50404. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  50405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50407. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  50408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  50410. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  50411. return BackgroundMaterial;
  50412. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  50413. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  50414. /***/ }),
  50415. /***/ "./Materials/Background/index.ts":
  50416. /*!***************************************!*\
  50417. !*** ./Materials/Background/index.ts ***!
  50418. \***************************************/
  50419. /*! exports provided: BackgroundMaterial */
  50420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50421. "use strict";
  50422. __webpack_require__.r(__webpack_exports__);
  50423. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  50424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  50425. /***/ }),
  50426. /***/ "./Materials/PBR/index.ts":
  50427. /*!********************************!*\
  50428. !*** ./Materials/PBR/index.ts ***!
  50429. \********************************/
  50430. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  50431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50432. "use strict";
  50433. __webpack_require__.r(__webpack_exports__);
  50434. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  50435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  50436. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  50437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  50438. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  50439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  50440. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  50441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  50442. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  50443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  50444. /***/ }),
  50445. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  50446. /*!******************************************!*\
  50447. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  50448. \******************************************/
  50449. /*! exports provided: PBRBaseMaterial */
  50450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50451. "use strict";
  50452. __webpack_require__.r(__webpack_exports__);
  50453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  50454. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50455. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50456. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50457. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50458. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  50459. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  50460. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50461. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50462. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50463. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50464. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50465. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50466. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50467. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50468. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50469. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50470. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  50471. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  50472. /**
  50473. * Manages the defines for the PBR Material.
  50474. * @hiddenChildren
  50475. */
  50476. var PBRMaterialDefines = /** @class */ (function (_super) {
  50477. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  50478. /**
  50479. * Initializes the PBR Material defines.
  50480. */
  50481. function PBRMaterialDefines() {
  50482. var _this = _super.call(this) || this;
  50483. _this.PBR = true;
  50484. _this.MAINUV1 = false;
  50485. _this.MAINUV2 = false;
  50486. _this.UV1 = false;
  50487. _this.UV2 = false;
  50488. _this.ALBEDO = false;
  50489. _this.ALBEDODIRECTUV = 0;
  50490. _this.VERTEXCOLOR = false;
  50491. _this.AMBIENT = false;
  50492. _this.AMBIENTDIRECTUV = 0;
  50493. _this.AMBIENTINGRAYSCALE = false;
  50494. _this.OPACITY = false;
  50495. _this.VERTEXALPHA = false;
  50496. _this.OPACITYDIRECTUV = 0;
  50497. _this.OPACITYRGB = false;
  50498. _this.ALPHATEST = false;
  50499. _this.DEPTHPREPASS = false;
  50500. _this.ALPHABLEND = false;
  50501. _this.ALPHAFROMALBEDO = false;
  50502. _this.ALPHATESTVALUE = "0.5";
  50503. _this.SPECULAROVERALPHA = false;
  50504. _this.RADIANCEOVERALPHA = false;
  50505. _this.ALPHAFRESNEL = false;
  50506. _this.LINEARALPHAFRESNEL = false;
  50507. _this.PREMULTIPLYALPHA = false;
  50508. _this.EMISSIVE = false;
  50509. _this.EMISSIVEDIRECTUV = 0;
  50510. _this.REFLECTIVITY = false;
  50511. _this.REFLECTIVITYDIRECTUV = 0;
  50512. _this.SPECULARTERM = false;
  50513. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  50514. _this.MICROSURFACEAUTOMATIC = false;
  50515. _this.LODBASEDMICROSFURACE = false;
  50516. _this.MICROSURFACEMAP = false;
  50517. _this.MICROSURFACEMAPDIRECTUV = 0;
  50518. _this.METALLICWORKFLOW = false;
  50519. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  50520. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  50521. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  50522. _this.AOSTOREINMETALMAPRED = false;
  50523. _this.ENVIRONMENTBRDF = false;
  50524. _this.NORMAL = false;
  50525. _this.TANGENT = false;
  50526. _this.BUMP = false;
  50527. _this.BUMPDIRECTUV = 0;
  50528. _this.OBJECTSPACE_NORMALMAP = false;
  50529. _this.PARALLAX = false;
  50530. _this.PARALLAXOCCLUSION = false;
  50531. _this.NORMALXYSCALE = true;
  50532. _this.LIGHTMAP = false;
  50533. _this.LIGHTMAPDIRECTUV = 0;
  50534. _this.USELIGHTMAPASSHADOWMAP = false;
  50535. _this.GAMMALIGHTMAP = false;
  50536. _this.REFLECTION = false;
  50537. _this.REFLECTIONMAP_3D = false;
  50538. _this.REFLECTIONMAP_SPHERICAL = false;
  50539. _this.REFLECTIONMAP_PLANAR = false;
  50540. _this.REFLECTIONMAP_CUBIC = false;
  50541. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50542. _this.REFLECTIONMAP_PROJECTION = false;
  50543. _this.REFLECTIONMAP_SKYBOX = false;
  50544. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50545. _this.REFLECTIONMAP_EXPLICIT = false;
  50546. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50547. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50548. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50549. _this.INVERTCUBICMAP = false;
  50550. _this.USESPHERICALFROMREFLECTIONMAP = false;
  50551. _this.USESPHERICALINVERTEX = false;
  50552. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50553. _this.LODINREFLECTIONALPHA = false;
  50554. _this.GAMMAREFLECTION = false;
  50555. _this.RGBDREFLECTION = false;
  50556. _this.RADIANCEOCCLUSION = false;
  50557. _this.HORIZONOCCLUSION = false;
  50558. _this.REFRACTION = false;
  50559. _this.REFRACTIONMAP_3D = false;
  50560. _this.REFRACTIONMAP_OPPOSITEZ = false;
  50561. _this.LODINREFRACTIONALPHA = false;
  50562. _this.GAMMAREFRACTION = false;
  50563. _this.RGBDREFRACTION = false;
  50564. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  50565. _this.INSTANCES = false;
  50566. _this.NUM_BONE_INFLUENCERS = 0;
  50567. _this.BonesPerMesh = 0;
  50568. _this.BONETEXTURE = false;
  50569. _this.NONUNIFORMSCALING = false;
  50570. _this.MORPHTARGETS = false;
  50571. _this.MORPHTARGETS_NORMAL = false;
  50572. _this.MORPHTARGETS_TANGENT = false;
  50573. _this.NUM_MORPH_INFLUENCERS = 0;
  50574. _this.IMAGEPROCESSING = false;
  50575. _this.VIGNETTE = false;
  50576. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50577. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50578. _this.TONEMAPPING = false;
  50579. _this.TONEMAPPING_ACES = false;
  50580. _this.CONTRAST = false;
  50581. _this.COLORCURVES = false;
  50582. _this.COLORGRADING = false;
  50583. _this.COLORGRADING3D = false;
  50584. _this.SAMPLER3DGREENDEPTH = false;
  50585. _this.SAMPLER3DBGRMAP = false;
  50586. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50587. _this.EXPOSURE = false;
  50588. _this.USEPHYSICALLIGHTFALLOFF = false;
  50589. _this.USEGLTFLIGHTFALLOFF = false;
  50590. _this.TWOSIDEDLIGHTING = false;
  50591. _this.SHADOWFLOAT = false;
  50592. _this.CLIPPLANE = false;
  50593. _this.CLIPPLANE2 = false;
  50594. _this.CLIPPLANE3 = false;
  50595. _this.CLIPPLANE4 = false;
  50596. _this.POINTSIZE = false;
  50597. _this.FOG = false;
  50598. _this.LOGARITHMICDEPTH = false;
  50599. _this.FORCENORMALFORWARD = false;
  50600. _this.SPECULARAA = false;
  50601. _this.UNLIT = false;
  50602. _this.rebuild();
  50603. return _this;
  50604. }
  50605. /**
  50606. * Resets the PBR Material defines.
  50607. */
  50608. PBRMaterialDefines.prototype.reset = function () {
  50609. _super.prototype.reset.call(this);
  50610. this.ALPHATESTVALUE = "0.5";
  50611. this.PBR = true;
  50612. };
  50613. return PBRMaterialDefines;
  50614. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  50615. /**
  50616. * The Physically based material base class of BJS.
  50617. *
  50618. * This offers the main features of a standard PBR material.
  50619. * For more information, please refer to the documentation :
  50620. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  50621. */
  50622. var PBRBaseMaterial = /** @class */ (function (_super) {
  50623. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  50624. /**
  50625. * Instantiates a new PBRMaterial instance.
  50626. *
  50627. * @param name The material name
  50628. * @param scene The scene the material will be use in.
  50629. */
  50630. function PBRBaseMaterial(name, scene) {
  50631. var _this = _super.call(this, name, scene) || this;
  50632. /**
  50633. * Intensity of the direct lights e.g. the four lights available in your scene.
  50634. * This impacts both the direct diffuse and specular highlights.
  50635. */
  50636. _this._directIntensity = 1.0;
  50637. /**
  50638. * Intensity of the emissive part of the material.
  50639. * This helps controlling the emissive effect without modifying the emissive color.
  50640. */
  50641. _this._emissiveIntensity = 1.0;
  50642. /**
  50643. * Intensity of the environment e.g. how much the environment will light the object
  50644. * either through harmonics for rough material or through the refelction for shiny ones.
  50645. */
  50646. _this._environmentIntensity = 1.0;
  50647. /**
  50648. * This is a special control allowing the reduction of the specular highlights coming from the
  50649. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50650. */
  50651. _this._specularIntensity = 1.0;
  50652. /**
  50653. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50654. */
  50655. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  50656. /**
  50657. * Debug Control allowing disabling the bump map on this material.
  50658. */
  50659. _this._disableBumpMap = false;
  50660. /**
  50661. * AKA Occlusion Texture Intensity in other nomenclature.
  50662. */
  50663. _this._ambientTextureStrength = 1.0;
  50664. /**
  50665. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50666. * 1 means it completely occludes it
  50667. * 0 mean it has no impact
  50668. */
  50669. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  50670. /**
  50671. * The color of a material in ambient lighting.
  50672. */
  50673. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50674. /**
  50675. * AKA Diffuse Color in other nomenclature.
  50676. */
  50677. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50678. /**
  50679. * AKA Specular Color in other nomenclature.
  50680. */
  50681. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50682. /**
  50683. * The color applied when light is reflected from a material.
  50684. */
  50685. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50686. /**
  50687. * The color applied when light is emitted from a material.
  50688. */
  50689. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50690. /**
  50691. * AKA Glossiness in other nomenclature.
  50692. */
  50693. _this._microSurface = 0.9;
  50694. /**
  50695. * source material index of refraction (IOR)' / 'destination material IOR.
  50696. */
  50697. _this._indexOfRefraction = 0.66;
  50698. /**
  50699. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50700. */
  50701. _this._invertRefractionY = false;
  50702. /**
  50703. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50704. * Materials half opaque for instance using refraction could benefit from this control.
  50705. */
  50706. _this._linkRefractionWithTransparency = false;
  50707. /**
  50708. * Specifies that the material will use the light map as a show map.
  50709. */
  50710. _this._useLightmapAsShadowmap = false;
  50711. /**
  50712. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50713. * makes the reflect vector face the model (under horizon).
  50714. */
  50715. _this._useHorizonOcclusion = true;
  50716. /**
  50717. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50718. * too much the area relying on ambient texture to define their ambient occlusion.
  50719. */
  50720. _this._useRadianceOcclusion = true;
  50721. /**
  50722. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50723. */
  50724. _this._useAlphaFromAlbedoTexture = false;
  50725. /**
  50726. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50727. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50728. */
  50729. _this._useSpecularOverAlpha = true;
  50730. /**
  50731. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50732. */
  50733. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  50734. /**
  50735. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50736. */
  50737. _this._useRoughnessFromMetallicTextureAlpha = true;
  50738. /**
  50739. * Specifies if the metallic texture contains the roughness information in its green channel.
  50740. */
  50741. _this._useRoughnessFromMetallicTextureGreen = false;
  50742. /**
  50743. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50744. */
  50745. _this._useMetallnessFromMetallicTextureBlue = false;
  50746. /**
  50747. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50748. */
  50749. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  50750. /**
  50751. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50752. */
  50753. _this._useAmbientInGrayScale = false;
  50754. /**
  50755. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50756. * The material will try to infer what glossiness each pixel should be.
  50757. */
  50758. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  50759. /**
  50760. * Defines the falloff type used in this material.
  50761. * It by default is Physical.
  50762. */
  50763. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  50764. /**
  50765. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50766. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50767. */
  50768. _this._useRadianceOverAlpha = true;
  50769. /**
  50770. * Allows using an object space normal map (instead of tangent space).
  50771. */
  50772. _this._useObjectSpaceNormalMap = false;
  50773. /**
  50774. * Allows using the bump map in parallax mode.
  50775. */
  50776. _this._useParallax = false;
  50777. /**
  50778. * Allows using the bump map in parallax occlusion mode.
  50779. */
  50780. _this._useParallaxOcclusion = false;
  50781. /**
  50782. * Controls the scale bias of the parallax mode.
  50783. */
  50784. _this._parallaxScaleBias = 0.05;
  50785. /**
  50786. * If sets to true, disables all the lights affecting the material.
  50787. */
  50788. _this._disableLighting = false;
  50789. /**
  50790. * Number of Simultaneous lights allowed on the material.
  50791. */
  50792. _this._maxSimultaneousLights = 4;
  50793. /**
  50794. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50795. */
  50796. _this._invertNormalMapX = false;
  50797. /**
  50798. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50799. */
  50800. _this._invertNormalMapY = false;
  50801. /**
  50802. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50803. */
  50804. _this._twoSidedLighting = false;
  50805. /**
  50806. * Defines the alpha limits in alpha test mode.
  50807. */
  50808. _this._alphaCutOff = 0.4;
  50809. /**
  50810. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50811. */
  50812. _this._forceAlphaTest = false;
  50813. /**
  50814. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50815. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50816. */
  50817. _this._useAlphaFresnel = false;
  50818. /**
  50819. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50820. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50821. */
  50822. _this._useLinearAlphaFresnel = false;
  50823. /**
  50824. * The transparency mode of the material.
  50825. */
  50826. _this._transparencyMode = null;
  50827. /**
  50828. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50829. * from cos thetav and roughness:
  50830. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50831. */
  50832. _this._environmentBRDFTexture = null;
  50833. /**
  50834. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50835. */
  50836. _this._forceIrradianceInFragment = false;
  50837. /**
  50838. * Force normal to face away from face.
  50839. */
  50840. _this._forceNormalForward = false;
  50841. /**
  50842. * Enables specular anti aliasing in the PBR shader.
  50843. * It will both interacts on the Geometry for analytical and IBL lighting.
  50844. * It also prefilter the roughness map based on the bump values.
  50845. */
  50846. _this._enableSpecularAntiAliasing = false;
  50847. /**
  50848. * Stores the available render targets.
  50849. */
  50850. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  50851. /**
  50852. * Sets the global ambient color for the material used in lighting calculations.
  50853. */
  50854. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50855. /**
  50856. * If set to true, no lighting calculations will be applied.
  50857. */
  50858. _this._unlit = false;
  50859. // Setup the default processing configuration to the scene.
  50860. _this._attachImageProcessingConfiguration(null);
  50861. _this.getRenderTargetTextures = function () {
  50862. _this._renderTargets.reset();
  50863. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50864. _this._renderTargets.push(_this._reflectionTexture);
  50865. }
  50866. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  50867. _this._renderTargets.push(_this._refractionTexture);
  50868. }
  50869. return _this._renderTargets;
  50870. };
  50871. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  50872. return _this;
  50873. }
  50874. /**
  50875. * Attaches a new image processing configuration to the PBR Material.
  50876. * @param configuration
  50877. */
  50878. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50879. var _this = this;
  50880. if (configuration === this._imageProcessingConfiguration) {
  50881. return;
  50882. }
  50883. // Detaches observer.
  50884. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50885. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50886. }
  50887. // Pick the scene configuration if needed.
  50888. if (!configuration) {
  50889. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50890. }
  50891. else {
  50892. this._imageProcessingConfiguration = configuration;
  50893. }
  50894. // Attaches observer.
  50895. if (this._imageProcessingConfiguration) {
  50896. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50897. _this._markAllSubMeshesAsImageProcessingDirty();
  50898. });
  50899. }
  50900. };
  50901. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  50902. /**
  50903. * Gets a boolean indicating that current material needs to register RTT
  50904. */
  50905. get: function () {
  50906. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50907. return true;
  50908. }
  50909. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50910. return true;
  50911. }
  50912. return false;
  50913. },
  50914. enumerable: true,
  50915. configurable: true
  50916. });
  50917. /**
  50918. * Gets the name of the material class.
  50919. */
  50920. PBRBaseMaterial.prototype.getClassName = function () {
  50921. return "PBRBaseMaterial";
  50922. };
  50923. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  50924. /**
  50925. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50926. */
  50927. get: function () {
  50928. return this._useLogarithmicDepth;
  50929. },
  50930. /**
  50931. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50932. */
  50933. set: function (value) {
  50934. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  50935. },
  50936. enumerable: true,
  50937. configurable: true
  50938. });
  50939. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  50940. /**
  50941. * Gets the current transparency mode.
  50942. */
  50943. get: function () {
  50944. return this._transparencyMode;
  50945. },
  50946. /**
  50947. * Sets the transparency mode of the material.
  50948. *
  50949. * | Value | Type | Description |
  50950. * | ----- | ----------------------------------- | ----------- |
  50951. * | 0 | OPAQUE | |
  50952. * | 1 | ALPHATEST | |
  50953. * | 2 | ALPHABLEND | |
  50954. * | 3 | ALPHATESTANDBLEND | |
  50955. *
  50956. */
  50957. set: function (value) {
  50958. if (this._transparencyMode === value) {
  50959. return;
  50960. }
  50961. this._transparencyMode = value;
  50962. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  50963. this._markAllSubMeshesAsTexturesAndMiscDirty();
  50964. },
  50965. enumerable: true,
  50966. configurable: true
  50967. });
  50968. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  50969. /**
  50970. * Returns true if alpha blending should be disabled.
  50971. */
  50972. get: function () {
  50973. return (this._linkRefractionWithTransparency ||
  50974. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  50975. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50976. },
  50977. enumerable: true,
  50978. configurable: true
  50979. });
  50980. /**
  50981. * Specifies whether or not this material should be rendered in alpha blend mode.
  50982. */
  50983. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  50984. if (this._disableAlphaBlending) {
  50985. return false;
  50986. }
  50987. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  50988. };
  50989. /**
  50990. * Specifies if the mesh will require alpha blending.
  50991. * @param mesh - BJS mesh.
  50992. */
  50993. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  50994. if (this._disableAlphaBlending) {
  50995. return false;
  50996. }
  50997. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  50998. };
  50999. /**
  51000. * Specifies whether or not this material should be rendered in alpha test mode.
  51001. */
  51002. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  51003. if (this._forceAlphaTest) {
  51004. return true;
  51005. }
  51006. if (this._linkRefractionWithTransparency) {
  51007. return false;
  51008. }
  51009. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  51010. };
  51011. /**
  51012. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51013. */
  51014. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  51015. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  51016. };
  51017. /**
  51018. * Gets the texture used for the alpha test.
  51019. */
  51020. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  51021. return this._albedoTexture;
  51022. };
  51023. /**
  51024. * Specifies that the submesh is ready to be used.
  51025. * @param mesh - BJS mesh.
  51026. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51027. * @param useInstances - Specifies that instances should be used.
  51028. * @returns - boolean indicating that the submesh is ready or not.
  51029. */
  51030. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51031. if (subMesh.effect && this.isFrozen) {
  51032. if (this._wasPreviouslyReady) {
  51033. return true;
  51034. }
  51035. }
  51036. if (!subMesh._materialDefines) {
  51037. subMesh._materialDefines = new PBRMaterialDefines();
  51038. }
  51039. var defines = subMesh._materialDefines;
  51040. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51041. if (defines._renderId === this.getScene().getRenderId()) {
  51042. return true;
  51043. }
  51044. }
  51045. var scene = this.getScene();
  51046. var engine = scene.getEngine();
  51047. if (defines._areTexturesDirty) {
  51048. if (scene.texturesEnabled) {
  51049. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51050. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  51051. return false;
  51052. }
  51053. }
  51054. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51055. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  51056. return false;
  51057. }
  51058. }
  51059. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51060. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  51061. return false;
  51062. }
  51063. }
  51064. var reflectionTexture = this._getReflectionTexture();
  51065. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51066. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51067. return false;
  51068. }
  51069. }
  51070. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51071. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  51072. return false;
  51073. }
  51074. }
  51075. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51076. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  51077. return false;
  51078. }
  51079. }
  51080. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51081. if (this._metallicTexture) {
  51082. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  51083. return false;
  51084. }
  51085. }
  51086. else if (this._reflectivityTexture) {
  51087. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  51088. return false;
  51089. }
  51090. }
  51091. if (this._microSurfaceTexture) {
  51092. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  51093. return false;
  51094. }
  51095. }
  51096. }
  51097. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51098. // Bump texture cannot be not blocking.
  51099. if (!this._bumpTexture.isReady()) {
  51100. return false;
  51101. }
  51102. }
  51103. var refractionTexture = this._getRefractionTexture();
  51104. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51105. if (!refractionTexture.isReadyOrNotBlocking()) {
  51106. return false;
  51107. }
  51108. }
  51109. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51110. // This is blocking.
  51111. if (!this._environmentBRDFTexture.isReady()) {
  51112. return false;
  51113. }
  51114. }
  51115. }
  51116. }
  51117. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51118. if (!this._imageProcessingConfiguration.isReady()) {
  51119. return false;
  51120. }
  51121. }
  51122. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  51123. mesh.createNormals(true);
  51124. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  51125. }
  51126. var previousEffect = subMesh.effect;
  51127. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  51128. if (effect) {
  51129. // Use previous effect while new one is compiling
  51130. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  51131. effect = previousEffect;
  51132. defines.markAsUnprocessed();
  51133. }
  51134. else {
  51135. scene.resetCachedMaterial();
  51136. subMesh.setEffect(effect, defines);
  51137. this.buildUniformLayout();
  51138. }
  51139. }
  51140. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51141. return false;
  51142. }
  51143. defines._renderId = scene.getRenderId();
  51144. this._wasPreviouslyReady = true;
  51145. return true;
  51146. };
  51147. /**
  51148. * Specifies if the material uses metallic roughness workflow.
  51149. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51150. */
  51151. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  51152. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  51153. return true;
  51154. }
  51155. return false;
  51156. };
  51157. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  51158. if (onCompiled === void 0) { onCompiled = null; }
  51159. if (onError === void 0) { onError = null; }
  51160. if (useInstances === void 0) { useInstances = null; }
  51161. if (useClipPlane === void 0) { useClipPlane = null; }
  51162. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  51163. if (!defines.isDirty) {
  51164. return null;
  51165. }
  51166. defines.markAsProcessed();
  51167. var scene = this.getScene();
  51168. var engine = scene.getEngine();
  51169. // Fallbacks
  51170. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["EffectFallbacks"]();
  51171. var fallbackRank = 0;
  51172. if (defines.USESPHERICALINVERTEX) {
  51173. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  51174. }
  51175. if (defines.FOG) {
  51176. fallbacks.addFallback(fallbackRank, "FOG");
  51177. }
  51178. if (defines.SPECULARAA) {
  51179. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  51180. }
  51181. if (defines.POINTSIZE) {
  51182. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  51183. }
  51184. if (defines.LOGARITHMICDEPTH) {
  51185. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  51186. }
  51187. if (defines.PARALLAX) {
  51188. fallbacks.addFallback(fallbackRank, "PARALLAX");
  51189. }
  51190. if (defines.PARALLAXOCCLUSION) {
  51191. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  51192. }
  51193. if (defines.ENVIRONMENTBRDF) {
  51194. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  51195. }
  51196. if (defines.TANGENT) {
  51197. fallbacks.addFallback(fallbackRank++, "TANGENT");
  51198. }
  51199. if (defines.BUMP) {
  51200. fallbacks.addFallback(fallbackRank++, "BUMP");
  51201. }
  51202. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  51203. if (defines.SPECULARTERM) {
  51204. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  51205. }
  51206. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  51207. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  51208. }
  51209. if (defines.LIGHTMAP) {
  51210. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  51211. }
  51212. if (defines.NORMAL) {
  51213. fallbacks.addFallback(fallbackRank++, "NORMAL");
  51214. }
  51215. if (defines.AMBIENT) {
  51216. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  51217. }
  51218. if (defines.EMISSIVE) {
  51219. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  51220. }
  51221. if (defines.VERTEXCOLOR) {
  51222. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  51223. }
  51224. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51225. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  51226. }
  51227. if (defines.MORPHTARGETS) {
  51228. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  51229. }
  51230. //Attributes
  51231. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  51232. if (defines.NORMAL) {
  51233. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  51234. }
  51235. if (defines.TANGENT) {
  51236. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  51237. }
  51238. if (defines.UV1) {
  51239. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  51240. }
  51241. if (defines.UV2) {
  51242. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  51243. }
  51244. if (defines.VERTEXCOLOR) {
  51245. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  51246. }
  51247. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51248. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51249. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  51250. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  51251. "vFogInfos", "vFogColor", "pointSize",
  51252. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  51253. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  51254. "mBones",
  51255. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  51256. "vLightingIntensity",
  51257. "logarithmicDepthConstant",
  51258. "vSphericalX", "vSphericalY", "vSphericalZ",
  51259. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  51260. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  51261. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  51262. "vTangentSpaceParams", "boneTextureWidth"
  51263. ];
  51264. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  51265. "bumpSampler", "lightmapSampler", "opacitySampler",
  51266. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  51267. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  51268. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  51269. var uniformBuffers = ["Material", "Scene"];
  51270. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"]) {
  51271. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51272. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51273. }
  51274. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51275. uniformsNames: uniforms,
  51276. uniformBuffersNames: uniformBuffers,
  51277. samplers: samplers,
  51278. defines: defines,
  51279. maxSimultaneousLights: this._maxSimultaneousLights
  51280. });
  51281. var join = defines.toString();
  51282. return engine.createEffect("pbr", {
  51283. attributes: attribs,
  51284. uniformsNames: uniforms,
  51285. uniformBuffersNames: uniformBuffers,
  51286. samplers: samplers,
  51287. defines: join,
  51288. fallbacks: fallbacks,
  51289. onCompiled: onCompiled,
  51290. onError: onError,
  51291. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  51292. }, engine);
  51293. };
  51294. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  51295. if (useInstances === void 0) { useInstances = null; }
  51296. if (useClipPlane === void 0) { useClipPlane = null; }
  51297. var scene = this.getScene();
  51298. var engine = scene.getEngine();
  51299. // Lights
  51300. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  51301. defines._needNormals = true;
  51302. // Textures
  51303. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  51304. if (defines._areTexturesDirty) {
  51305. defines._needUVs = false;
  51306. if (scene.texturesEnabled) {
  51307. if (scene.getEngine().getCaps().textureLOD) {
  51308. defines.LODBASEDMICROSFURACE = true;
  51309. }
  51310. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51311. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  51312. }
  51313. else {
  51314. defines.ALBEDO = false;
  51315. }
  51316. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51317. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  51318. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  51319. }
  51320. else {
  51321. defines.AMBIENT = false;
  51322. }
  51323. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51324. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  51325. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  51326. }
  51327. else {
  51328. defines.OPACITY = false;
  51329. }
  51330. var reflectionTexture = this._getReflectionTexture();
  51331. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51332. defines.REFLECTION = true;
  51333. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51334. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51335. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51336. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51337. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE) {
  51338. defines.INVERTCUBICMAP = true;
  51339. }
  51340. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51341. defines.REFLECTIONMAP_CUBIC = false;
  51342. defines.REFLECTIONMAP_EXPLICIT = false;
  51343. defines.REFLECTIONMAP_PLANAR = false;
  51344. defines.REFLECTIONMAP_PROJECTION = false;
  51345. defines.REFLECTIONMAP_SKYBOX = false;
  51346. defines.REFLECTIONMAP_SPHERICAL = false;
  51347. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51348. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51349. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51350. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51351. switch (reflectionTexture.coordinatesMode) {
  51352. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EXPLICIT_MODE:
  51353. defines.REFLECTIONMAP_EXPLICIT = true;
  51354. break;
  51355. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PLANAR_MODE:
  51356. defines.REFLECTIONMAP_PLANAR = true;
  51357. break;
  51358. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PROJECTION_MODE:
  51359. defines.REFLECTIONMAP_PROJECTION = true;
  51360. break;
  51361. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE:
  51362. defines.REFLECTIONMAP_SKYBOX = true;
  51363. break;
  51364. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SPHERICAL_MODE:
  51365. defines.REFLECTIONMAP_SPHERICAL = true;
  51366. break;
  51367. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EQUIRECTANGULAR_MODE:
  51368. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51369. break;
  51370. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51371. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51372. break;
  51373. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51374. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51375. break;
  51376. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].CUBIC_MODE:
  51377. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE:
  51378. default:
  51379. defines.REFLECTIONMAP_CUBIC = true;
  51380. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  51381. break;
  51382. }
  51383. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE) {
  51384. if (reflectionTexture.sphericalPolynomial) {
  51385. defines.USESPHERICALFROMREFLECTIONMAP = true;
  51386. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  51387. defines.USESPHERICALINVERTEX = false;
  51388. }
  51389. else {
  51390. defines.USESPHERICALINVERTEX = true;
  51391. }
  51392. }
  51393. }
  51394. else {
  51395. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51396. }
  51397. }
  51398. else {
  51399. defines.REFLECTION = false;
  51400. defines.REFLECTIONMAP_3D = false;
  51401. defines.REFLECTIONMAP_SPHERICAL = false;
  51402. defines.REFLECTIONMAP_PLANAR = false;
  51403. defines.REFLECTIONMAP_CUBIC = false;
  51404. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51405. defines.REFLECTIONMAP_PROJECTION = false;
  51406. defines.REFLECTIONMAP_SKYBOX = false;
  51407. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51408. defines.REFLECTIONMAP_EXPLICIT = false;
  51409. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51410. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51411. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51412. defines.INVERTCUBICMAP = false;
  51413. defines.USESPHERICALFROMREFLECTIONMAP = false;
  51414. defines.USESPHERICALINVERTEX = false;
  51415. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51416. defines.LODINREFLECTIONALPHA = false;
  51417. defines.GAMMAREFLECTION = false;
  51418. defines.RGBDREFLECTION = false;
  51419. }
  51420. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51421. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  51422. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  51423. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  51424. }
  51425. else {
  51426. defines.LIGHTMAP = false;
  51427. }
  51428. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51429. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  51430. }
  51431. else {
  51432. defines.EMISSIVE = false;
  51433. }
  51434. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51435. if (this._metallicTexture) {
  51436. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  51437. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  51438. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  51439. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  51440. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  51441. }
  51442. else if (this._reflectivityTexture) {
  51443. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  51444. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  51445. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  51446. }
  51447. else {
  51448. defines.REFLECTIVITY = false;
  51449. }
  51450. if (this._microSurfaceTexture) {
  51451. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  51452. }
  51453. else {
  51454. defines.MICROSURFACEMAP = false;
  51455. }
  51456. }
  51457. else {
  51458. defines.REFLECTIVITY = false;
  51459. defines.MICROSURFACEMAP = false;
  51460. }
  51461. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51462. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  51463. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51464. defines.PARALLAX = true;
  51465. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  51466. }
  51467. else {
  51468. defines.PARALLAX = false;
  51469. }
  51470. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  51471. }
  51472. else {
  51473. defines.BUMP = false;
  51474. }
  51475. var refractionTexture = this._getRefractionTexture();
  51476. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51477. defines.REFRACTION = true;
  51478. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  51479. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  51480. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  51481. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  51482. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  51483. if (this._linkRefractionWithTransparency) {
  51484. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  51485. }
  51486. }
  51487. else {
  51488. defines.REFRACTION = false;
  51489. }
  51490. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51491. defines.ENVIRONMENTBRDF = true;
  51492. }
  51493. else {
  51494. defines.ENVIRONMENTBRDF = false;
  51495. }
  51496. if (this._shouldUseAlphaFromAlbedoTexture()) {
  51497. defines.ALPHAFROMALBEDO = true;
  51498. }
  51499. else {
  51500. defines.ALPHAFROMALBEDO = false;
  51501. }
  51502. }
  51503. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  51504. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  51505. defines.USEPHYSICALLIGHTFALLOFF = false;
  51506. defines.USEGLTFLIGHTFALLOFF = false;
  51507. }
  51508. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  51509. defines.USEPHYSICALLIGHTFALLOFF = false;
  51510. defines.USEGLTFLIGHTFALLOFF = true;
  51511. }
  51512. else {
  51513. defines.USEPHYSICALLIGHTFALLOFF = true;
  51514. defines.USEGLTFLIGHTFALLOFF = false;
  51515. }
  51516. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  51517. if (!this.backFaceCulling && this._twoSidedLighting) {
  51518. defines.TWOSIDEDLIGHTING = true;
  51519. }
  51520. else {
  51521. defines.TWOSIDEDLIGHTING = false;
  51522. }
  51523. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  51524. 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);
  51525. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  51526. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  51527. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  51528. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  51529. }
  51530. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51531. this._imageProcessingConfiguration.prepareDefines(defines);
  51532. }
  51533. defines.FORCENORMALFORWARD = this._forceNormalForward;
  51534. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  51535. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  51536. // Misc.
  51537. if (defines._areMiscDirty) {
  51538. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  51539. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  51540. }
  51541. // Values that need to be evaluated on every frame
  51542. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  51543. // Attribs
  51544. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  51545. };
  51546. /**
  51547. * Force shader compilation
  51548. */
  51549. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  51550. var _this = this;
  51551. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  51552. var defines = new PBRMaterialDefines();
  51553. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  51554. if (effect.isReady()) {
  51555. if (onCompiled) {
  51556. onCompiled(this);
  51557. }
  51558. }
  51559. else {
  51560. effect.onCompileObservable.add(function () {
  51561. if (onCompiled) {
  51562. onCompiled(_this);
  51563. }
  51564. });
  51565. }
  51566. };
  51567. /**
  51568. * Initializes the uniform buffer layout for the shader.
  51569. */
  51570. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  51571. // Order is important !
  51572. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  51573. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  51574. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  51575. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  51576. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  51577. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  51578. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  51579. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  51580. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51581. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  51582. this._uniformBuffer.addUniform("vReflectionSize", 3);
  51583. this._uniformBuffer.addUniform("vBumpInfos", 3);
  51584. this._uniformBuffer.addUniform("albedoMatrix", 16);
  51585. this._uniformBuffer.addUniform("ambientMatrix", 16);
  51586. this._uniformBuffer.addUniform("opacityMatrix", 16);
  51587. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  51588. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  51589. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  51590. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  51591. this._uniformBuffer.addUniform("bumpMatrix", 16);
  51592. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  51593. this._uniformBuffer.addUniform("refractionMatrix", 16);
  51594. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51595. this._uniformBuffer.addUniform("vReflectionColor", 3);
  51596. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  51597. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  51598. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  51599. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51600. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  51601. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  51602. this._uniformBuffer.addUniform("pointSize", 1);
  51603. this._uniformBuffer.create();
  51604. };
  51605. /**
  51606. * Unbinds the textures.
  51607. */
  51608. PBRBaseMaterial.prototype.unbind = function () {
  51609. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51610. this._uniformBuffer.setTexture("reflectionSampler", null);
  51611. }
  51612. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51613. this._uniformBuffer.setTexture("refractionSampler", null);
  51614. }
  51615. _super.prototype.unbind.call(this);
  51616. };
  51617. /**
  51618. * Binds the submesh data.
  51619. * @param world - The world matrix.
  51620. * @param mesh - The BJS mesh.
  51621. * @param subMesh - A submesh of the BJS mesh.
  51622. */
  51623. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51624. var scene = this.getScene();
  51625. var defines = subMesh._materialDefines;
  51626. if (!defines) {
  51627. return;
  51628. }
  51629. var effect = subMesh.effect;
  51630. if (!effect) {
  51631. return;
  51632. }
  51633. this._activeEffect = effect;
  51634. // Matrices
  51635. this.bindOnlyWorldMatrix(world);
  51636. // Normal Matrix
  51637. if (defines.OBJECTSPACE_NORMALMAP) {
  51638. world.toNormalMatrix(this._normalMatrix);
  51639. this.bindOnlyNormalMatrix(this._normalMatrix);
  51640. }
  51641. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51642. // Bones
  51643. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51644. var reflectionTexture = null;
  51645. if (mustRebind) {
  51646. this._uniformBuffer.bindToEffect(effect, "Material");
  51647. this.bindViewProjection(effect);
  51648. reflectionTexture = this._getReflectionTexture();
  51649. var refractionTexture = this._getRefractionTexture();
  51650. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51651. // Texture uniforms
  51652. if (scene.texturesEnabled) {
  51653. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51654. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  51655. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  51656. }
  51657. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51658. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  51659. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  51660. }
  51661. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51662. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  51663. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  51664. }
  51665. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51666. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51667. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  51668. if (reflectionTexture.boundingBoxSize) {
  51669. var cubeTexture = reflectionTexture;
  51670. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  51671. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  51672. }
  51673. var polynomials = reflectionTexture.sphericalPolynomial;
  51674. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  51675. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  51676. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  51677. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  51678. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  51679. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  51680. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  51681. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  51682. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  51683. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  51684. }
  51685. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51686. }
  51687. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51688. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  51689. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  51690. }
  51691. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51692. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  51693. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  51694. }
  51695. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51696. if (this._metallicTexture) {
  51697. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  51698. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  51699. }
  51700. else if (this._reflectivityTexture) {
  51701. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  51702. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  51703. }
  51704. if (this._microSurfaceTexture) {
  51705. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  51706. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  51707. }
  51708. }
  51709. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51710. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  51711. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  51712. if (scene._mirroredCameraPosition) {
  51713. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  51714. }
  51715. else {
  51716. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  51717. }
  51718. }
  51719. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51720. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  51721. var depth = 1.0;
  51722. if (!refractionTexture.isCube) {
  51723. if (refractionTexture.depth) {
  51724. depth = refractionTexture.depth;
  51725. }
  51726. }
  51727. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  51728. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  51729. }
  51730. }
  51731. // Point size
  51732. if (this.pointsCloud) {
  51733. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51734. }
  51735. // Colors
  51736. if (defines.METALLICWORKFLOW) {
  51737. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  51738. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  51739. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  51740. }
  51741. else {
  51742. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  51743. }
  51744. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  51745. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  51746. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  51747. // Misc
  51748. this._lightingInfos.x = this._directIntensity;
  51749. this._lightingInfos.y = this._emissiveIntensity;
  51750. this._lightingInfos.z = this._environmentIntensity;
  51751. this._lightingInfos.w = this._specularIntensity;
  51752. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  51753. }
  51754. // Textures
  51755. if (scene.texturesEnabled) {
  51756. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51757. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  51758. }
  51759. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51760. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  51761. }
  51762. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51763. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  51764. }
  51765. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51766. if (defines.LODBASEDMICROSFURACE) {
  51767. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51768. }
  51769. else {
  51770. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51771. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51772. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51773. }
  51774. }
  51775. if (defines.ENVIRONMENTBRDF) {
  51776. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  51777. }
  51778. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51779. if (defines.LODBASEDMICROSFURACE) {
  51780. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  51781. }
  51782. else {
  51783. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  51784. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  51785. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  51786. }
  51787. }
  51788. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51789. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  51790. }
  51791. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51792. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  51793. }
  51794. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51795. if (this._metallicTexture) {
  51796. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  51797. }
  51798. else if (this._reflectivityTexture) {
  51799. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  51800. }
  51801. if (this._microSurfaceTexture) {
  51802. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  51803. }
  51804. }
  51805. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51806. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  51807. }
  51808. }
  51809. // Clip plane
  51810. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51811. // Colors
  51812. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  51813. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  51814. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  51815. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  51816. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  51817. }
  51818. if (mustRebind || !this.isFrozen) {
  51819. // Lights
  51820. if (scene.lightsEnabled && !this._disableLighting) {
  51821. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  51822. }
  51823. // View
  51824. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  51825. this.bindView(effect);
  51826. }
  51827. // Fog
  51828. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51829. // Morph targets
  51830. if (defines.NUM_MORPH_INFLUENCERS) {
  51831. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  51832. }
  51833. // image processing
  51834. this._imageProcessingConfiguration.bind(this._activeEffect);
  51835. // Log. depth
  51836. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  51837. }
  51838. this._uniformBuffer.update();
  51839. this._afterBind(mesh, this._activeEffect);
  51840. };
  51841. /**
  51842. * Returns the animatable textures.
  51843. * @returns - Array of animatable textures.
  51844. */
  51845. PBRBaseMaterial.prototype.getAnimatables = function () {
  51846. var results = [];
  51847. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  51848. results.push(this._albedoTexture);
  51849. }
  51850. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  51851. results.push(this._ambientTexture);
  51852. }
  51853. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  51854. results.push(this._opacityTexture);
  51855. }
  51856. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  51857. results.push(this._reflectionTexture);
  51858. }
  51859. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  51860. results.push(this._emissiveTexture);
  51861. }
  51862. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  51863. results.push(this._metallicTexture);
  51864. }
  51865. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  51866. results.push(this._reflectivityTexture);
  51867. }
  51868. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  51869. results.push(this._bumpTexture);
  51870. }
  51871. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  51872. results.push(this._lightmapTexture);
  51873. }
  51874. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  51875. results.push(this._refractionTexture);
  51876. }
  51877. return results;
  51878. };
  51879. /**
  51880. * Returns the texture used for reflections.
  51881. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51882. */
  51883. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  51884. if (this._reflectionTexture) {
  51885. return this._reflectionTexture;
  51886. }
  51887. return this.getScene().environmentTexture;
  51888. };
  51889. /**
  51890. * Returns the texture used for refraction or null if none is used.
  51891. * @returns - Refection texture if present. If no refraction texture and refraction
  51892. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51893. */
  51894. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  51895. if (this._refractionTexture) {
  51896. return this._refractionTexture;
  51897. }
  51898. if (this._linkRefractionWithTransparency) {
  51899. return this.getScene().environmentTexture;
  51900. }
  51901. return null;
  51902. };
  51903. /**
  51904. * Disposes the resources of the material.
  51905. * @param forceDisposeEffect - Forces the disposal of effects.
  51906. * @param forceDisposeTextures - Forces the disposal of all textures.
  51907. */
  51908. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51909. if (forceDisposeTextures) {
  51910. if (this._albedoTexture) {
  51911. this._albedoTexture.dispose();
  51912. }
  51913. if (this._ambientTexture) {
  51914. this._ambientTexture.dispose();
  51915. }
  51916. if (this._opacityTexture) {
  51917. this._opacityTexture.dispose();
  51918. }
  51919. if (this._reflectionTexture) {
  51920. this._reflectionTexture.dispose();
  51921. }
  51922. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  51923. this._environmentBRDFTexture.dispose();
  51924. }
  51925. if (this._emissiveTexture) {
  51926. this._emissiveTexture.dispose();
  51927. }
  51928. if (this._metallicTexture) {
  51929. this._metallicTexture.dispose();
  51930. }
  51931. if (this._reflectivityTexture) {
  51932. this._reflectivityTexture.dispose();
  51933. }
  51934. if (this._bumpTexture) {
  51935. this._bumpTexture.dispose();
  51936. }
  51937. if (this._lightmapTexture) {
  51938. this._lightmapTexture.dispose();
  51939. }
  51940. if (this._refractionTexture) {
  51941. this._refractionTexture.dispose();
  51942. }
  51943. }
  51944. this._renderTargets.dispose();
  51945. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51946. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51947. }
  51948. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  51949. };
  51950. /**
  51951. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51952. */
  51953. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  51954. /**
  51955. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51956. */
  51957. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  51958. /**
  51959. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51960. */
  51961. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  51962. /**
  51963. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51964. * They are also discarded below the alpha cutoff threshold to improve performances.
  51965. */
  51966. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  51967. /**
  51968. * Defines the default value of how much AO map is occluding the analytical lights
  51969. * (point spot...).
  51970. */
  51971. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  51972. /**
  51973. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51974. */
  51975. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  51976. /**
  51977. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51978. * to enhance interoperability with other engines.
  51979. */
  51980. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  51981. /**
  51982. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51983. * to enhance interoperability with other materials.
  51984. */
  51985. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  51986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51988. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51991. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  51992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51994. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  51995. return PBRBaseMaterial;
  51996. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__["PushMaterial"]));
  51997. /***/ }),
  51998. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  51999. /*!************************************************!*\
  52000. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  52001. \************************************************/
  52002. /*! exports provided: PBRBaseSimpleMaterial */
  52003. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52004. "use strict";
  52005. __webpack_require__.r(__webpack_exports__);
  52006. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  52007. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52008. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52009. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52010. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52011. /**
  52012. * The Physically based simple base material of BJS.
  52013. *
  52014. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52015. * It is used as the base class for both the specGloss and metalRough conventions.
  52016. */
  52017. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  52018. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  52019. /**
  52020. * Instantiates a new PBRMaterial instance.
  52021. *
  52022. * @param name The material name
  52023. * @param scene The scene the material will be use in.
  52024. */
  52025. function PBRBaseSimpleMaterial(name, scene) {
  52026. var _this = _super.call(this, name, scene) || this;
  52027. /**
  52028. * Number of Simultaneous lights allowed on the material.
  52029. */
  52030. _this.maxSimultaneousLights = 4;
  52031. /**
  52032. * If sets to true, disables all the lights affecting the material.
  52033. */
  52034. _this.disableLighting = false;
  52035. /**
  52036. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52037. */
  52038. _this.invertNormalMapX = false;
  52039. /**
  52040. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52041. */
  52042. _this.invertNormalMapY = false;
  52043. /**
  52044. * Emissivie color used to self-illuminate the model.
  52045. */
  52046. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  52047. /**
  52048. * Occlusion Channel Strenght.
  52049. */
  52050. _this.occlusionStrength = 1.0;
  52051. /**
  52052. * If true, the light map contains occlusion information instead of lighting info.
  52053. */
  52054. _this.useLightmapAsShadowmap = false;
  52055. _this._useAlphaFromAlbedoTexture = true;
  52056. _this._useAmbientInGrayScale = true;
  52057. return _this;
  52058. }
  52059. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  52060. /**
  52061. * Gets the current double sided mode.
  52062. */
  52063. get: function () {
  52064. return this._twoSidedLighting;
  52065. },
  52066. /**
  52067. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52068. */
  52069. set: function (value) {
  52070. if (this._twoSidedLighting === value) {
  52071. return;
  52072. }
  52073. this._twoSidedLighting = value;
  52074. this.backFaceCulling = !value;
  52075. this._markAllSubMeshesAsTexturesDirty();
  52076. },
  52077. enumerable: true,
  52078. configurable: true
  52079. });
  52080. /**
  52081. * Return the active textures of the material.
  52082. */
  52083. PBRBaseSimpleMaterial.prototype.getActiveTextures = function () {
  52084. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52085. if (this.environmentTexture) {
  52086. activeTextures.push(this.environmentTexture);
  52087. }
  52088. if (this.normalTexture) {
  52089. activeTextures.push(this.normalTexture);
  52090. }
  52091. if (this.emissiveTexture) {
  52092. activeTextures.push(this.emissiveTexture);
  52093. }
  52094. if (this.occlusionTexture) {
  52095. activeTextures.push(this.occlusionTexture);
  52096. }
  52097. if (this.lightmapTexture) {
  52098. activeTextures.push(this.lightmapTexture);
  52099. }
  52100. return activeTextures;
  52101. };
  52102. PBRBaseSimpleMaterial.prototype.hasTexture = function (texture) {
  52103. if (_super.prototype.hasTexture.call(this, texture)) {
  52104. return true;
  52105. }
  52106. if (this.lightmapTexture === texture) {
  52107. return true;
  52108. }
  52109. return false;
  52110. };
  52111. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  52112. return "PBRBaseSimpleMaterial";
  52113. };
  52114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52117. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  52118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52121. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  52122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  52125. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  52126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52129. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  52130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52133. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  52134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  52137. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  52138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52141. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  52142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52145. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  52146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  52149. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  52150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  52153. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  52154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  52157. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  52158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52160. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  52161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52164. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  52165. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52166. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52168. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52169. return PBRBaseSimpleMaterial;
  52170. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  52171. /***/ }),
  52172. /***/ "./Materials/PBR/pbrMaterial.ts":
  52173. /*!**************************************!*\
  52174. !*** ./Materials/PBR/pbrMaterial.ts ***!
  52175. \**************************************/
  52176. /*! exports provided: PBRMaterial */
  52177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52178. "use strict";
  52179. __webpack_require__.r(__webpack_exports__);
  52180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  52181. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52182. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52183. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  52184. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52185. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52186. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52187. /**
  52188. * The Physically based material of BJS.
  52189. *
  52190. * This offers the main features of a standard PBR material.
  52191. * For more information, please refer to the documentation :
  52192. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52193. */
  52194. var PBRMaterial = /** @class */ (function (_super) {
  52195. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  52196. /**
  52197. * Instantiates a new PBRMaterial instance.
  52198. *
  52199. * @param name The material name
  52200. * @param scene The scene the material will be use in.
  52201. */
  52202. function PBRMaterial(name, scene) {
  52203. var _this = _super.call(this, name, scene) || this;
  52204. /**
  52205. * Intensity of the direct lights e.g. the four lights available in your scene.
  52206. * This impacts both the direct diffuse and specular highlights.
  52207. */
  52208. _this.directIntensity = 1.0;
  52209. /**
  52210. * Intensity of the emissive part of the material.
  52211. * This helps controlling the emissive effect without modifying the emissive color.
  52212. */
  52213. _this.emissiveIntensity = 1.0;
  52214. /**
  52215. * Intensity of the environment e.g. how much the environment will light the object
  52216. * either through harmonics for rough material or through the refelction for shiny ones.
  52217. */
  52218. _this.environmentIntensity = 1.0;
  52219. /**
  52220. * This is a special control allowing the reduction of the specular highlights coming from the
  52221. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52222. */
  52223. _this.specularIntensity = 1.0;
  52224. /**
  52225. * Debug Control allowing disabling the bump map on this material.
  52226. */
  52227. _this.disableBumpMap = false;
  52228. /**
  52229. * AKA Occlusion Texture Intensity in other nomenclature.
  52230. */
  52231. _this.ambientTextureStrength = 1.0;
  52232. /**
  52233. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52234. * 1 means it completely occludes it
  52235. * 0 mean it has no impact
  52236. */
  52237. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52238. /**
  52239. * The color of a material in ambient lighting.
  52240. */
  52241. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52242. /**
  52243. * AKA Diffuse Color in other nomenclature.
  52244. */
  52245. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52246. /**
  52247. * AKA Specular Color in other nomenclature.
  52248. */
  52249. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52250. /**
  52251. * The color reflected from the material.
  52252. */
  52253. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  52254. /**
  52255. * The color emitted from the material.
  52256. */
  52257. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52258. /**
  52259. * AKA Glossiness in other nomenclature.
  52260. */
  52261. _this.microSurface = 1.0;
  52262. /**
  52263. * source material index of refraction (IOR)' / 'destination material IOR.
  52264. */
  52265. _this.indexOfRefraction = 0.66;
  52266. /**
  52267. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52268. */
  52269. _this.invertRefractionY = false;
  52270. /**
  52271. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52272. * Materials half opaque for instance using refraction could benefit from this control.
  52273. */
  52274. _this.linkRefractionWithTransparency = false;
  52275. /**
  52276. * If true, the light map contains occlusion information instead of lighting info.
  52277. */
  52278. _this.useLightmapAsShadowmap = false;
  52279. /**
  52280. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52281. */
  52282. _this.useAlphaFromAlbedoTexture = false;
  52283. /**
  52284. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52285. */
  52286. _this.forceAlphaTest = false;
  52287. /**
  52288. * Defines the alpha limits in alpha test mode.
  52289. */
  52290. _this.alphaCutOff = 0.4;
  52291. /**
  52292. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52293. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52294. */
  52295. _this.useSpecularOverAlpha = true;
  52296. /**
  52297. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52298. */
  52299. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  52300. /**
  52301. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52302. */
  52303. _this.useRoughnessFromMetallicTextureAlpha = true;
  52304. /**
  52305. * Specifies if the metallic texture contains the roughness information in its green channel.
  52306. */
  52307. _this.useRoughnessFromMetallicTextureGreen = false;
  52308. /**
  52309. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52310. */
  52311. _this.useMetallnessFromMetallicTextureBlue = false;
  52312. /**
  52313. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52314. */
  52315. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  52316. /**
  52317. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52318. */
  52319. _this.useAmbientInGrayScale = false;
  52320. /**
  52321. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52322. * The material will try to infer what glossiness each pixel should be.
  52323. */
  52324. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  52325. /**
  52326. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52327. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52328. */
  52329. _this.useRadianceOverAlpha = true;
  52330. /**
  52331. * Allows using an object space normal map (instead of tangent space).
  52332. */
  52333. _this.useObjectSpaceNormalMap = false;
  52334. /**
  52335. * Allows using the bump map in parallax mode.
  52336. */
  52337. _this.useParallax = false;
  52338. /**
  52339. * Allows using the bump map in parallax occlusion mode.
  52340. */
  52341. _this.useParallaxOcclusion = false;
  52342. /**
  52343. * Controls the scale bias of the parallax mode.
  52344. */
  52345. _this.parallaxScaleBias = 0.05;
  52346. /**
  52347. * If sets to true, disables all the lights affecting the material.
  52348. */
  52349. _this.disableLighting = false;
  52350. /**
  52351. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52352. */
  52353. _this.forceIrradianceInFragment = false;
  52354. /**
  52355. * Number of Simultaneous lights allowed on the material.
  52356. */
  52357. _this.maxSimultaneousLights = 4;
  52358. /**
  52359. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52360. */
  52361. _this.invertNormalMapX = false;
  52362. /**
  52363. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52364. */
  52365. _this.invertNormalMapY = false;
  52366. /**
  52367. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52368. */
  52369. _this.twoSidedLighting = false;
  52370. /**
  52371. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52372. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52373. */
  52374. _this.useAlphaFresnel = false;
  52375. /**
  52376. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52377. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52378. */
  52379. _this.useLinearAlphaFresnel = false;
  52380. /**
  52381. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52382. * And/Or occlude the blended part.
  52383. */
  52384. _this.environmentBRDFTexture = null;
  52385. /**
  52386. * Force normal to face away from face.
  52387. */
  52388. _this.forceNormalForward = false;
  52389. /**
  52390. * Enables specular anti aliasing in the PBR shader.
  52391. * It will both interacts on the Geometry for analytical and IBL lighting.
  52392. * It also prefilter the roughness map based on the bump values.
  52393. */
  52394. _this.enableSpecularAntiAliasing = false;
  52395. /**
  52396. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52397. * makes the reflect vector face the model (under horizon).
  52398. */
  52399. _this.useHorizonOcclusion = true;
  52400. /**
  52401. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52402. * too much the area relying on ambient texture to define their ambient occlusion.
  52403. */
  52404. _this.useRadianceOcclusion = true;
  52405. /**
  52406. * If set to true, no lighting calculations will be applied.
  52407. */
  52408. _this.unlit = false;
  52409. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  52410. return _this;
  52411. }
  52412. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  52413. /**
  52414. * BJS is using an harcoded light falloff based on a manually sets up range.
  52415. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52416. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52417. */
  52418. get: function () {
  52419. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52420. },
  52421. /**
  52422. * BJS is using an harcoded light falloff based on a manually sets up range.
  52423. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52424. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52425. */
  52426. set: function (value) {
  52427. if (value !== this.usePhysicalLightFalloff) {
  52428. // Ensure the effect will be rebuilt.
  52429. this._markAllSubMeshesAsTexturesDirty();
  52430. if (value) {
  52431. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52432. }
  52433. else {
  52434. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52435. }
  52436. }
  52437. },
  52438. enumerable: true,
  52439. configurable: true
  52440. });
  52441. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  52442. /**
  52443. * In order to support the falloff compatibility with gltf, a special mode has been added
  52444. * to reproduce the gltf light falloff.
  52445. */
  52446. get: function () {
  52447. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52448. },
  52449. /**
  52450. * In order to support the falloff compatibility with gltf, a special mode has been added
  52451. * to reproduce the gltf light falloff.
  52452. */
  52453. set: function (value) {
  52454. if (value !== this.useGLTFLightFalloff) {
  52455. // Ensure the effect will be rebuilt.
  52456. this._markAllSubMeshesAsTexturesDirty();
  52457. if (value) {
  52458. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52459. }
  52460. else {
  52461. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52462. }
  52463. }
  52464. },
  52465. enumerable: true,
  52466. configurable: true
  52467. });
  52468. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  52469. /**
  52470. * Gets the image processing configuration used either in this material.
  52471. */
  52472. get: function () {
  52473. return this._imageProcessingConfiguration;
  52474. },
  52475. /**
  52476. * Sets the Default image processing configuration used either in the this material.
  52477. *
  52478. * If sets to null, the scene one is in use.
  52479. */
  52480. set: function (value) {
  52481. this._attachImageProcessingConfiguration(value);
  52482. // Ensure the effect will be rebuilt.
  52483. this._markAllSubMeshesAsTexturesDirty();
  52484. },
  52485. enumerable: true,
  52486. configurable: true
  52487. });
  52488. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  52489. /**
  52490. * Gets wether the color curves effect is enabled.
  52491. */
  52492. get: function () {
  52493. return this.imageProcessingConfiguration.colorCurvesEnabled;
  52494. },
  52495. /**
  52496. * Sets wether the color curves effect is enabled.
  52497. */
  52498. set: function (value) {
  52499. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  52500. },
  52501. enumerable: true,
  52502. configurable: true
  52503. });
  52504. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  52505. /**
  52506. * Gets wether the color grading effect is enabled.
  52507. */
  52508. get: function () {
  52509. return this.imageProcessingConfiguration.colorGradingEnabled;
  52510. },
  52511. /**
  52512. * Gets wether the color grading effect is enabled.
  52513. */
  52514. set: function (value) {
  52515. this.imageProcessingConfiguration.colorGradingEnabled = value;
  52516. },
  52517. enumerable: true,
  52518. configurable: true
  52519. });
  52520. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  52521. /**
  52522. * Gets wether tonemapping is enabled or not.
  52523. */
  52524. get: function () {
  52525. return this._imageProcessingConfiguration.toneMappingEnabled;
  52526. },
  52527. /**
  52528. * Sets wether tonemapping is enabled or not
  52529. */
  52530. set: function (value) {
  52531. this._imageProcessingConfiguration.toneMappingEnabled = value;
  52532. },
  52533. enumerable: true,
  52534. configurable: true
  52535. });
  52536. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  52537. /**
  52538. * The camera exposure used on this material.
  52539. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52540. * This corresponds to a photographic exposure.
  52541. */
  52542. get: function () {
  52543. return this._imageProcessingConfiguration.exposure;
  52544. },
  52545. /**
  52546. * The camera exposure used on this material.
  52547. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52548. * This corresponds to a photographic exposure.
  52549. */
  52550. set: function (value) {
  52551. this._imageProcessingConfiguration.exposure = value;
  52552. },
  52553. enumerable: true,
  52554. configurable: true
  52555. });
  52556. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  52557. /**
  52558. * Gets The camera contrast used on this material.
  52559. */
  52560. get: function () {
  52561. return this._imageProcessingConfiguration.contrast;
  52562. },
  52563. /**
  52564. * Sets The camera contrast used on this material.
  52565. */
  52566. set: function (value) {
  52567. this._imageProcessingConfiguration.contrast = value;
  52568. },
  52569. enumerable: true,
  52570. configurable: true
  52571. });
  52572. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  52573. /**
  52574. * Gets the Color Grading 2D Lookup Texture.
  52575. */
  52576. get: function () {
  52577. return this._imageProcessingConfiguration.colorGradingTexture;
  52578. },
  52579. /**
  52580. * Sets the Color Grading 2D Lookup Texture.
  52581. */
  52582. set: function (value) {
  52583. this._imageProcessingConfiguration.colorGradingTexture = value;
  52584. },
  52585. enumerable: true,
  52586. configurable: true
  52587. });
  52588. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  52589. /**
  52590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52592. * 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;
  52593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52594. */
  52595. get: function () {
  52596. return this._imageProcessingConfiguration.colorCurves;
  52597. },
  52598. /**
  52599. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52600. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52601. * 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;
  52602. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52603. */
  52604. set: function (value) {
  52605. this._imageProcessingConfiguration.colorCurves = value;
  52606. },
  52607. enumerable: true,
  52608. configurable: true
  52609. });
  52610. /**
  52611. * Returns the name of this material class.
  52612. */
  52613. PBRMaterial.prototype.getClassName = function () {
  52614. return "PBRMaterial";
  52615. };
  52616. /**
  52617. * Returns an array of the actively used textures.
  52618. * @returns - Array of BaseTextures
  52619. */
  52620. PBRMaterial.prototype.getActiveTextures = function () {
  52621. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52622. if (this._albedoTexture) {
  52623. activeTextures.push(this._albedoTexture);
  52624. }
  52625. if (this._ambientTexture) {
  52626. activeTextures.push(this._ambientTexture);
  52627. }
  52628. if (this._opacityTexture) {
  52629. activeTextures.push(this._opacityTexture);
  52630. }
  52631. if (this._reflectionTexture) {
  52632. activeTextures.push(this._reflectionTexture);
  52633. }
  52634. if (this._emissiveTexture) {
  52635. activeTextures.push(this._emissiveTexture);
  52636. }
  52637. if (this._reflectivityTexture) {
  52638. activeTextures.push(this._reflectivityTexture);
  52639. }
  52640. if (this._metallicTexture) {
  52641. activeTextures.push(this._metallicTexture);
  52642. }
  52643. if (this._microSurfaceTexture) {
  52644. activeTextures.push(this._microSurfaceTexture);
  52645. }
  52646. if (this._bumpTexture) {
  52647. activeTextures.push(this._bumpTexture);
  52648. }
  52649. if (this._lightmapTexture) {
  52650. activeTextures.push(this._lightmapTexture);
  52651. }
  52652. if (this._refractionTexture) {
  52653. activeTextures.push(this._refractionTexture);
  52654. }
  52655. return activeTextures;
  52656. };
  52657. /**
  52658. * Checks to see if a texture is used in the material.
  52659. * @param texture - Base texture to use.
  52660. * @returns - Boolean specifying if a texture is used in the material.
  52661. */
  52662. PBRMaterial.prototype.hasTexture = function (texture) {
  52663. if (_super.prototype.hasTexture.call(this, texture)) {
  52664. return true;
  52665. }
  52666. if (this._albedoTexture === texture) {
  52667. return true;
  52668. }
  52669. if (this._ambientTexture === texture) {
  52670. return true;
  52671. }
  52672. if (this._opacityTexture === texture) {
  52673. return true;
  52674. }
  52675. if (this._reflectionTexture === texture) {
  52676. return true;
  52677. }
  52678. if (this._reflectivityTexture === texture) {
  52679. return true;
  52680. }
  52681. if (this._metallicTexture === texture) {
  52682. return true;
  52683. }
  52684. if (this._microSurfaceTexture === texture) {
  52685. return true;
  52686. }
  52687. if (this._bumpTexture === texture) {
  52688. return true;
  52689. }
  52690. if (this._lightmapTexture === texture) {
  52691. return true;
  52692. }
  52693. if (this._refractionTexture === texture) {
  52694. return true;
  52695. }
  52696. return false;
  52697. };
  52698. /**
  52699. * Makes a duplicate of the current material.
  52700. * @param name - name to use for the new material.
  52701. */
  52702. PBRMaterial.prototype.clone = function (name) {
  52703. var _this = this;
  52704. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  52705. clone.id = name;
  52706. clone.name = name;
  52707. return clone;
  52708. };
  52709. /**
  52710. * Serializes this PBR Material.
  52711. * @returns - An object with the serialized material.
  52712. */
  52713. PBRMaterial.prototype.serialize = function () {
  52714. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52715. serializationObject.customType = "BABYLON.PBRMaterial";
  52716. return serializationObject;
  52717. };
  52718. // Statics
  52719. /**
  52720. * Parses a PBR Material from a serialized object.
  52721. * @param source - Serialized object.
  52722. * @param scene - BJS scene instance.
  52723. * @param rootUrl - url for the scene object
  52724. * @returns - PBRMaterial
  52725. */
  52726. PBRMaterial.Parse = function (source, scene, rootUrl) {
  52727. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  52728. };
  52729. /**
  52730. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52731. */
  52732. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  52733. /**
  52734. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52735. */
  52736. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  52737. /**
  52738. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52739. */
  52740. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  52741. /**
  52742. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52743. * They are also discarded below the alpha cutoff threshold to improve performances.
  52744. */
  52745. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  52746. /**
  52747. * Defines the default value of how much AO map is occluding the analytical lights
  52748. * (point spot...).
  52749. */
  52750. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52754. ], PBRMaterial.prototype, "directIntensity", void 0);
  52755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52758. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  52759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52762. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  52763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52765. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52766. ], PBRMaterial.prototype, "specularIntensity", void 0);
  52767. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52770. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  52771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52774. ], PBRMaterial.prototype, "albedoTexture", void 0);
  52775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52777. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52778. ], PBRMaterial.prototype, "ambientTexture", void 0);
  52779. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52780. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52782. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  52783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52786. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  52787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52790. ], PBRMaterial.prototype, "opacityTexture", void 0);
  52791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52794. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  52795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52798. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  52799. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52800. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52802. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  52803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52806. ], PBRMaterial.prototype, "metallicTexture", void 0);
  52807. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52808. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52810. ], PBRMaterial.prototype, "metallic", void 0);
  52811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52814. ], PBRMaterial.prototype, "roughness", void 0);
  52815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52818. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  52819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52822. ], PBRMaterial.prototype, "bumpTexture", void 0);
  52823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52826. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  52827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52830. ], PBRMaterial.prototype, "refractionTexture", void 0);
  52831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  52833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52834. ], PBRMaterial.prototype, "ambientColor", void 0);
  52835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  52837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52838. ], PBRMaterial.prototype, "albedoColor", void 0);
  52839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  52841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52842. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  52843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  52845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52846. ], PBRMaterial.prototype, "reflectionColor", void 0);
  52847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52850. ], PBRMaterial.prototype, "emissiveColor", void 0);
  52851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52854. ], PBRMaterial.prototype, "microSurface", void 0);
  52855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52858. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  52859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52862. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  52863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52866. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  52867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52870. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52874. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  52875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52878. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  52879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52882. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  52883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52886. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  52887. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52890. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  52891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52894. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  52895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52898. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  52899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52902. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  52903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52906. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  52907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52910. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  52911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52914. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  52915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52917. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  52918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52920. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  52921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52924. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  52925. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52928. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  52929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52932. ], PBRMaterial.prototype, "useParallax", 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")
  52936. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  52937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52940. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  52941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52944. ], PBRMaterial.prototype, "disableLighting", void 0);
  52945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52948. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  52949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52951. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52952. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  52953. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52954. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52956. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  52957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52960. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  52961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52963. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52964. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  52965. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52968. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  52969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52972. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  52973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52976. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  52977. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52980. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  52981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52984. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  52985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52988. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  52989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52992. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  52993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52996. ], PBRMaterial.prototype, "unlit", void 0);
  52997. return PBRMaterial;
  52998. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  52999. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  53000. /***/ }),
  53001. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  53002. /*!*******************************************************!*\
  53003. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  53004. \*******************************************************/
  53005. /*! exports provided: PBRMetallicRoughnessMaterial */
  53006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53007. "use strict";
  53008. __webpack_require__.r(__webpack_exports__);
  53009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  53010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53011. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53012. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53013. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53014. /**
  53015. * The PBR material of BJS following the metal roughness convention.
  53016. *
  53017. * This fits to the PBR convention in the GLTF definition:
  53018. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53019. */
  53020. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  53021. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  53022. /**
  53023. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53024. *
  53025. * @param name The material name
  53026. * @param scene The scene the material will be use in.
  53027. */
  53028. function PBRMetallicRoughnessMaterial(name, scene) {
  53029. var _this = _super.call(this, name, scene) || this;
  53030. _this._useRoughnessFromMetallicTextureAlpha = false;
  53031. _this._useRoughnessFromMetallicTextureGreen = true;
  53032. _this._useMetallnessFromMetallicTextureBlue = true;
  53033. _this.metallic = 1.0;
  53034. _this.roughness = 1.0;
  53035. return _this;
  53036. }
  53037. /**
  53038. * Return the currrent class name of the material.
  53039. */
  53040. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  53041. return "PBRMetallicRoughnessMaterial";
  53042. };
  53043. /**
  53044. * Return the active textures of the material.
  53045. */
  53046. PBRMetallicRoughnessMaterial.prototype.getActiveTextures = function () {
  53047. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53048. if (this.baseTexture) {
  53049. activeTextures.push(this.baseTexture);
  53050. }
  53051. if (this.metallicRoughnessTexture) {
  53052. activeTextures.push(this.metallicRoughnessTexture);
  53053. }
  53054. return activeTextures;
  53055. };
  53056. /**
  53057. * Checks to see if a texture is used in the material.
  53058. * @param texture - Base texture to use.
  53059. * @returns - Boolean specifying if a texture is used in the material.
  53060. */
  53061. PBRMetallicRoughnessMaterial.prototype.hasTexture = function (texture) {
  53062. if (_super.prototype.hasTexture.call(this, texture)) {
  53063. return true;
  53064. }
  53065. if (this.baseTexture === texture) {
  53066. return true;
  53067. }
  53068. if (this.metallicRoughnessTexture === texture) {
  53069. return true;
  53070. }
  53071. return false;
  53072. };
  53073. /**
  53074. * Makes a duplicate of the current material.
  53075. * @param name - name to use for the new material.
  53076. */
  53077. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  53078. var _this = this;
  53079. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  53080. clone.id = name;
  53081. clone.name = name;
  53082. return clone;
  53083. };
  53084. /**
  53085. * Serialize the material to a parsable JSON object.
  53086. */
  53087. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  53088. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53089. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  53090. return serializationObject;
  53091. };
  53092. /**
  53093. * Parses a JSON object correponding to the serialize function.
  53094. */
  53095. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  53096. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  53097. };
  53098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  53100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53101. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  53102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53105. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  53106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53109. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  53110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53113. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  53114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  53117. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  53118. return PBRMetallicRoughnessMaterial;
  53119. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53120. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  53121. /***/ }),
  53122. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  53123. /*!********************************************************!*\
  53124. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  53125. \********************************************************/
  53126. /*! exports provided: PBRSpecularGlossinessMaterial */
  53127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53128. "use strict";
  53129. __webpack_require__.r(__webpack_exports__);
  53130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  53131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53132. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53133. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53134. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53135. /**
  53136. * The PBR material of BJS following the specular glossiness convention.
  53137. *
  53138. * This fits to the PBR convention in the GLTF definition:
  53139. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53140. */
  53141. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  53142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  53143. /**
  53144. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53145. *
  53146. * @param name The material name
  53147. * @param scene The scene the material will be use in.
  53148. */
  53149. function PBRSpecularGlossinessMaterial(name, scene) {
  53150. var _this = _super.call(this, name, scene) || this;
  53151. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  53152. return _this;
  53153. }
  53154. /**
  53155. * Return the currrent class name of the material.
  53156. */
  53157. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  53158. return "PBRSpecularGlossinessMaterial";
  53159. };
  53160. /**
  53161. * Return the active textures of the material.
  53162. */
  53163. PBRSpecularGlossinessMaterial.prototype.getActiveTextures = function () {
  53164. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53165. if (this.diffuseTexture) {
  53166. activeTextures.push(this.diffuseTexture);
  53167. }
  53168. if (this.specularGlossinessTexture) {
  53169. activeTextures.push(this.specularGlossinessTexture);
  53170. }
  53171. return activeTextures;
  53172. };
  53173. /**
  53174. * Checks to see if a texture is used in the material.
  53175. * @param texture - Base texture to use.
  53176. * @returns - Boolean specifying if a texture is used in the material.
  53177. */
  53178. PBRSpecularGlossinessMaterial.prototype.hasTexture = function (texture) {
  53179. if (_super.prototype.hasTexture.call(this, texture)) {
  53180. return true;
  53181. }
  53182. if (this.diffuseTexture === texture) {
  53183. return true;
  53184. }
  53185. if (this.specularGlossinessTexture === texture) {
  53186. return true;
  53187. }
  53188. return false;
  53189. };
  53190. /**
  53191. * Makes a duplicate of the current material.
  53192. * @param name - name to use for the new material.
  53193. */
  53194. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  53195. var _this = this;
  53196. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  53197. clone.id = name;
  53198. clone.name = name;
  53199. return clone;
  53200. };
  53201. /**
  53202. * Serialize the material to a parsable JSON object.
  53203. */
  53204. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  53205. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53206. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  53207. return serializationObject;
  53208. };
  53209. /**
  53210. * Parses a JSON object correponding to the serialize function.
  53211. */
  53212. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  53213. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  53214. };
  53215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  53217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53218. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  53219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53222. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  53223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  53225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  53226. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  53227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  53230. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  53231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  53234. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  53235. return PBRSpecularGlossinessMaterial;
  53236. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53237. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  53238. /***/ }),
  53239. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  53240. /*!********************************************************!*\
  53241. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  53242. \********************************************************/
  53243. /*! exports provided: _DDSTextureLoader */
  53244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53245. "use strict";
  53246. __webpack_require__.r(__webpack_exports__);
  53247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  53248. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  53249. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53250. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  53251. /**
  53252. * Implementation of the DDS Texture Loader.
  53253. * @hidden
  53254. */
  53255. var _DDSTextureLoader = /** @class */ (function () {
  53256. function _DDSTextureLoader() {
  53257. /**
  53258. * Defines wether the loader supports cascade loading the different faces.
  53259. */
  53260. this.supportCascades = true;
  53261. }
  53262. /**
  53263. * This returns if the loader support the current file information.
  53264. * @param extension defines the file extension of the file being loaded
  53265. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53266. * @param fallback defines the fallback internal texture if any
  53267. * @param isBase64 defines whether the texture is encoded as a base64
  53268. * @param isBuffer defines whether the texture data are stored as a buffer
  53269. * @returns true if the loader can load the specified file
  53270. */
  53271. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53272. return extension.indexOf(".dds") === 0;
  53273. };
  53274. /**
  53275. * Transform the url before loading if required.
  53276. * @param rootUrl the url of the texture
  53277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53278. * @returns the transformed texture
  53279. */
  53280. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53281. return rootUrl;
  53282. };
  53283. /**
  53284. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53285. * @param rootUrl the url of the texture
  53286. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53287. * @returns the fallback texture
  53288. */
  53289. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53290. return null;
  53291. };
  53292. /**
  53293. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53294. * @param data contains the texture data
  53295. * @param texture defines the BabylonJS internal texture
  53296. * @param createPolynomials will be true if polynomials have been requested
  53297. * @param onLoad defines the callback to trigger once the texture is ready
  53298. * @param onError defines the callback to trigger in case of error
  53299. */
  53300. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  53301. var engine = texture.getEngine();
  53302. var info;
  53303. var loadMipmap = false;
  53304. if (Array.isArray(imgs)) {
  53305. for (var index = 0; index < imgs.length; index++) {
  53306. var data_1 = imgs[index];
  53307. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  53308. texture.width = info.width;
  53309. texture.height = info.height;
  53310. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53311. engine._unpackFlipY(info.isCompressed);
  53312. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  53313. if (!info.isFourCC && info.mipmapCount === 1) {
  53314. engine.generateMipMapsForCubemap(texture);
  53315. }
  53316. }
  53317. }
  53318. else {
  53319. var data = imgs;
  53320. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53321. texture.width = info.width;
  53322. texture.height = info.height;
  53323. if (createPolynomials) {
  53324. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  53325. }
  53326. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53327. engine._unpackFlipY(info.isCompressed);
  53328. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  53329. if (!info.isFourCC && info.mipmapCount === 1) {
  53330. engine.generateMipMapsForCubemap(texture);
  53331. }
  53332. }
  53333. engine._setCubeMapTextureParams(loadMipmap);
  53334. texture.isReady = true;
  53335. if (onLoad) {
  53336. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  53337. }
  53338. };
  53339. /**
  53340. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53341. * @param data contains the texture data
  53342. * @param texture defines the BabylonJS internal texture
  53343. * @param callback defines the method to call once ready to upload
  53344. */
  53345. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  53346. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53347. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  53348. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  53349. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  53350. });
  53351. };
  53352. return _DDSTextureLoader;
  53353. }());
  53354. // Register the loader.
  53355. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  53356. /***/ }),
  53357. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  53358. /*!********************************************************!*\
  53359. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  53360. \********************************************************/
  53361. /*! exports provided: _ENVTextureLoader */
  53362. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53363. "use strict";
  53364. __webpack_require__.r(__webpack_exports__);
  53365. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  53366. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  53367. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53368. /**
  53369. * Implementation of the ENV Texture Loader.
  53370. * @hidden
  53371. */
  53372. var _ENVTextureLoader = /** @class */ (function () {
  53373. function _ENVTextureLoader() {
  53374. /**
  53375. * Defines wether the loader supports cascade loading the different faces.
  53376. */
  53377. this.supportCascades = false;
  53378. }
  53379. /**
  53380. * This returns if the loader support the current file information.
  53381. * @param extension defines the file extension of the file being loaded
  53382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53383. * @param fallback defines the fallback internal texture if any
  53384. * @param isBase64 defines whether the texture is encoded as a base64
  53385. * @param isBuffer defines whether the texture data are stored as a buffer
  53386. * @returns true if the loader can load the specified file
  53387. */
  53388. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53389. return extension.indexOf(".env") === 0;
  53390. };
  53391. /**
  53392. * Transform the url before loading if required.
  53393. * @param rootUrl the url of the texture
  53394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53395. * @returns the transformed texture
  53396. */
  53397. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53398. return rootUrl;
  53399. };
  53400. /**
  53401. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53402. * @param rootUrl the url of the texture
  53403. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53404. * @returns the fallback texture
  53405. */
  53406. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53407. return null;
  53408. };
  53409. /**
  53410. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53411. * @param data contains the texture data
  53412. * @param texture defines the BabylonJS internal texture
  53413. * @param createPolynomials will be true if polynomials have been requested
  53414. * @param onLoad defines the callback to trigger once the texture is ready
  53415. * @param onError defines the callback to trigger in case of error
  53416. */
  53417. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53418. if (Array.isArray(data)) {
  53419. return;
  53420. }
  53421. data = data;
  53422. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  53423. if (info) {
  53424. texture.width = info.width;
  53425. texture.height = info.width;
  53426. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  53427. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  53428. texture.isReady = true;
  53429. if (onLoad) {
  53430. onLoad();
  53431. }
  53432. });
  53433. }
  53434. else if (onError) {
  53435. onError("Can not parse the environment file", null);
  53436. }
  53437. };
  53438. /**
  53439. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53440. * @param data contains the texture data
  53441. * @param texture defines the BabylonJS internal texture
  53442. * @param callback defines the method to call once ready to upload
  53443. */
  53444. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  53445. throw ".env not supported in 2d.";
  53446. };
  53447. return _ENVTextureLoader;
  53448. }());
  53449. // Register the loader.
  53450. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  53451. /***/ }),
  53452. /***/ "./Materials/Textures/Loaders/index.ts":
  53453. /*!*********************************************!*\
  53454. !*** ./Materials/Textures/Loaders/index.ts ***!
  53455. \*********************************************/
  53456. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  53457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53458. "use strict";
  53459. __webpack_require__.r(__webpack_exports__);
  53460. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  53461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  53462. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  53463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  53464. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  53465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  53466. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  53467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  53468. /***/ }),
  53469. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  53470. /*!********************************************************!*\
  53471. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  53472. \********************************************************/
  53473. /*! exports provided: _KTXTextureLoader */
  53474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53475. "use strict";
  53476. __webpack_require__.r(__webpack_exports__);
  53477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  53478. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  53479. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53480. /**
  53481. * Implementation of the KTX Texture Loader.
  53482. * @hidden
  53483. */
  53484. var _KTXTextureLoader = /** @class */ (function () {
  53485. function _KTXTextureLoader() {
  53486. /**
  53487. * Defines wether the loader supports cascade loading the different faces.
  53488. */
  53489. this.supportCascades = false;
  53490. }
  53491. /**
  53492. * This returns if the loader support the current file information.
  53493. * @param extension defines the file extension of the file being loaded
  53494. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53495. * @param fallback defines the fallback internal texture if any
  53496. * @param isBase64 defines whether the texture is encoded as a base64
  53497. * @param isBuffer defines whether the texture data are stored as a buffer
  53498. * @returns true if the loader can load the specified file
  53499. */
  53500. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53501. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  53502. return true;
  53503. }
  53504. return false;
  53505. };
  53506. /**
  53507. * Transform the url before loading if required.
  53508. * @param rootUrl the url of the texture
  53509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53510. * @returns the transformed texture
  53511. */
  53512. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53513. var lastDot = rootUrl.lastIndexOf('.');
  53514. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  53515. // Already transformed
  53516. return rootUrl;
  53517. }
  53518. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  53519. };
  53520. /**
  53521. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53522. * @param rootUrl the url of the texture
  53523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53524. * @returns the fallback texture
  53525. */
  53526. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53527. // remove the format appended to the rootUrl in the original createCubeTexture call.
  53528. var exp = new RegExp("" + textureFormatInUse + "$");
  53529. return rootUrl.replace(exp, "");
  53530. };
  53531. /**
  53532. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53533. * @param data contains the texture data
  53534. * @param texture defines the BabylonJS internal texture
  53535. * @param createPolynomials will be true if polynomials have been requested
  53536. * @param onLoad defines the callback to trigger once the texture is ready
  53537. * @param onError defines the callback to trigger in case of error
  53538. */
  53539. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53540. if (Array.isArray(data)) {
  53541. return;
  53542. }
  53543. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53544. texture._invertVScale = !texture.invertY;
  53545. var engine = texture.getEngine();
  53546. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  53547. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  53548. engine._unpackFlipY(true);
  53549. ktx.uploadLevels(texture, texture.generateMipMaps);
  53550. texture.width = ktx.pixelWidth;
  53551. texture.height = ktx.pixelHeight;
  53552. engine._setCubeMapTextureParams(loadMipmap);
  53553. texture.isReady = true;
  53554. };
  53555. /**
  53556. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53557. * @param data contains the texture data
  53558. * @param texture defines the BabylonJS internal texture
  53559. * @param callback defines the method to call once ready to upload
  53560. */
  53561. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  53562. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53563. texture._invertVScale = !texture.invertY;
  53564. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  53565. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  53566. ktx.uploadLevels(texture, texture.generateMipMaps);
  53567. }, ktx.isInvalid);
  53568. };
  53569. return _KTXTextureLoader;
  53570. }());
  53571. // Register the loader.
  53572. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  53573. /***/ }),
  53574. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  53575. /*!********************************************************!*\
  53576. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  53577. \********************************************************/
  53578. /*! exports provided: _TGATextureLoader */
  53579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53580. "use strict";
  53581. __webpack_require__.r(__webpack_exports__);
  53582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  53583. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  53584. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53585. /**
  53586. * Implementation of the TGA Texture Loader.
  53587. * @hidden
  53588. */
  53589. var _TGATextureLoader = /** @class */ (function () {
  53590. function _TGATextureLoader() {
  53591. /**
  53592. * Defines wether the loader supports cascade loading the different faces.
  53593. */
  53594. this.supportCascades = false;
  53595. }
  53596. /**
  53597. * This returns if the loader support the current file information.
  53598. * @param extension defines the file extension of the file being loaded
  53599. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53600. * @param fallback defines the fallback internal texture if any
  53601. * @param isBase64 defines whether the texture is encoded as a base64
  53602. * @param isBuffer defines whether the texture data are stored as a buffer
  53603. * @returns true if the loader can load the specified file
  53604. */
  53605. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53606. return extension.indexOf(".tga") === 0;
  53607. };
  53608. /**
  53609. * Transform the url before loading if required.
  53610. * @param rootUrl the url of the texture
  53611. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53612. * @returns the transformed texture
  53613. */
  53614. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53615. return rootUrl;
  53616. };
  53617. /**
  53618. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53619. * @param rootUrl the url of the texture
  53620. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53621. * @returns the fallback texture
  53622. */
  53623. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53624. return null;
  53625. };
  53626. /**
  53627. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53628. * @param data contains the texture data
  53629. * @param texture defines the BabylonJS internal texture
  53630. * @param createPolynomials will be true if polynomials have been requested
  53631. * @param onLoad defines the callback to trigger once the texture is ready
  53632. * @param onError defines the callback to trigger in case of error
  53633. */
  53634. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53635. throw ".env not supported in Cube.";
  53636. };
  53637. /**
  53638. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53639. * @param data contains the texture data
  53640. * @param texture defines the BabylonJS internal texture
  53641. * @param callback defines the method to call once ready to upload
  53642. */
  53643. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  53644. var uintData = new Uint8Array(data);
  53645. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  53646. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  53647. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  53648. });
  53649. };
  53650. return _TGATextureLoader;
  53651. }());
  53652. // Register the loader.
  53653. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  53654. /***/ }),
  53655. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  53656. /*!*******************************************************************!*\
  53657. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  53658. \*******************************************************************/
  53659. /*! exports provided: CustomProceduralTexture */
  53660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53661. "use strict";
  53662. __webpack_require__.r(__webpack_exports__);
  53663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  53664. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53665. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  53666. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  53667. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  53668. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53669. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53670. /**
  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. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53673. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53674. */
  53675. var CustomProceduralTexture = /** @class */ (function (_super) {
  53676. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  53677. /**
  53678. * Instantiates a new Custom Procedural Texture.
  53679. * 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.
  53680. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53681. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53682. * @param name Define the name of the texture
  53683. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53684. * @param size Define the size of the texture to create
  53685. * @param scene Define the scene the texture belongs to
  53686. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53687. * @param generateMipMaps Define if the texture should creates mip maps or not
  53688. */
  53689. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  53690. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  53691. _this._animate = true;
  53692. _this._time = 0;
  53693. _this._texturePath = texturePath;
  53694. //Try to load json
  53695. _this._loadJson(texturePath);
  53696. _this.refreshRate = 1;
  53697. return _this;
  53698. }
  53699. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  53700. var _this = this;
  53701. var noConfigFile = function () {
  53702. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  53703. try {
  53704. _this.setFragment(_this._texturePath);
  53705. }
  53706. catch (ex) {
  53707. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  53708. }
  53709. };
  53710. var configFileUrl = jsonUrl + "/config.json";
  53711. var xhr = new XMLHttpRequest();
  53712. xhr.open("GET", configFileUrl, true);
  53713. xhr.addEventListener("load", function () {
  53714. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  53715. try {
  53716. _this._config = JSON.parse(xhr.response);
  53717. _this.updateShaderUniforms();
  53718. _this.updateTextures();
  53719. _this.setFragment(_this._texturePath + "/custom");
  53720. _this._animate = _this._config.animate;
  53721. _this.refreshRate = _this._config.refreshrate;
  53722. }
  53723. catch (ex) {
  53724. noConfigFile();
  53725. }
  53726. }
  53727. else {
  53728. noConfigFile();
  53729. }
  53730. }, false);
  53731. xhr.addEventListener("error", function () {
  53732. noConfigFile();
  53733. }, false);
  53734. try {
  53735. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  53736. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  53737. }
  53738. xhr.send();
  53739. }
  53740. catch (ex) {
  53741. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  53742. }
  53743. };
  53744. /**
  53745. * Is the texture ready to be used ? (rendered at least once)
  53746. * @returns true if ready, otherwise, false.
  53747. */
  53748. CustomProceduralTexture.prototype.isReady = function () {
  53749. if (!_super.prototype.isReady.call(this)) {
  53750. return false;
  53751. }
  53752. for (var name in this._textures) {
  53753. var texture = this._textures[name];
  53754. if (!texture.isReady()) {
  53755. return false;
  53756. }
  53757. }
  53758. return true;
  53759. };
  53760. /**
  53761. * Render the texture to its associated render target.
  53762. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53763. */
  53764. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53765. var scene = this.getScene();
  53766. if (this._animate && scene) {
  53767. this._time += scene.getAnimationRatio() * 0.03;
  53768. this.updateShaderUniforms();
  53769. }
  53770. _super.prototype.render.call(this, useCameraPostProcess);
  53771. };
  53772. /**
  53773. * Update the list of dependant textures samplers in the shader.
  53774. */
  53775. CustomProceduralTexture.prototype.updateTextures = function () {
  53776. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  53777. 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()));
  53778. }
  53779. };
  53780. /**
  53781. * Update the uniform values of the procedural texture in the shader.
  53782. */
  53783. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  53784. if (this._config) {
  53785. for (var j = 0; j < this._config.uniforms.length; j++) {
  53786. var uniform = this._config.uniforms[j];
  53787. switch (uniform.type) {
  53788. case "float":
  53789. this.setFloat(uniform.name, uniform.value);
  53790. break;
  53791. case "color3":
  53792. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  53793. break;
  53794. case "color4":
  53795. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  53796. break;
  53797. case "vector2":
  53798. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  53799. break;
  53800. case "vector3":
  53801. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  53802. break;
  53803. }
  53804. }
  53805. }
  53806. this.setFloat("time", this._time);
  53807. };
  53808. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  53809. /**
  53810. * Define if the texture animates or not.
  53811. */
  53812. get: function () {
  53813. return this._animate;
  53814. },
  53815. set: function (value) {
  53816. this._animate = value;
  53817. },
  53818. enumerable: true,
  53819. configurable: true
  53820. });
  53821. return CustomProceduralTexture;
  53822. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  53823. /***/ }),
  53824. /***/ "./Materials/Textures/Procedurals/index.ts":
  53825. /*!*************************************************!*\
  53826. !*** ./Materials/Textures/Procedurals/index.ts ***!
  53827. \*************************************************/
  53828. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  53829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53830. "use strict";
  53831. __webpack_require__.r(__webpack_exports__);
  53832. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  53833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  53834. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  53835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  53836. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  53838. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  53840. /***/ }),
  53841. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  53842. /*!******************************************************************!*\
  53843. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  53844. \******************************************************************/
  53845. /*! exports provided: NoiseProceduralTexture */
  53846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53847. "use strict";
  53848. __webpack_require__.r(__webpack_exports__);
  53849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  53850. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53851. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  53852. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53853. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  53854. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  53855. /**
  53856. * Class used to generate noise procedural textures
  53857. */
  53858. var NoiseProceduralTexture = /** @class */ (function (_super) {
  53859. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  53860. /**
  53861. * Creates a new NoiseProceduralTexture
  53862. * @param name defines the name fo the texture
  53863. * @param size defines the size of the texture (default is 256)
  53864. * @param scene defines the hosting scene
  53865. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53866. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53867. */
  53868. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  53869. if (size === void 0) { size = 256; }
  53870. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  53871. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  53872. _this._time = 0;
  53873. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53874. _this.brightness = 0.2;
  53875. /** Defines the number of octaves to process */
  53876. _this.octaves = 3;
  53877. /** Defines the level of persistence (0.8 by default) */
  53878. _this.persistence = 0.8;
  53879. /** Gets or sets animation speed factor (default is 1) */
  53880. _this.animationSpeedFactor = 1;
  53881. _this.autoClear = false;
  53882. _this._updateShaderUniforms();
  53883. return _this;
  53884. }
  53885. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  53886. var scene = this.getScene();
  53887. if (!scene) {
  53888. return;
  53889. }
  53890. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  53891. this.setFloat("brightness", this.brightness);
  53892. this.setFloat("persistence", this.persistence);
  53893. this.setFloat("timeScale", this._time);
  53894. };
  53895. NoiseProceduralTexture.prototype._getDefines = function () {
  53896. return "#define OCTAVES " + (this.octaves | 0);
  53897. };
  53898. /** Generate the current state of the procedural texture */
  53899. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53900. this._updateShaderUniforms();
  53901. _super.prototype.render.call(this, useCameraPostProcess);
  53902. };
  53903. /**
  53904. * Serializes this noise procedural texture
  53905. * @returns a serialized noise procedural texture object
  53906. */
  53907. NoiseProceduralTexture.prototype.serialize = function () {
  53908. var serializationObject = {};
  53909. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  53910. serializationObject.brightness = this.brightness;
  53911. serializationObject.octaves = this.octaves;
  53912. serializationObject.persistence = this.persistence;
  53913. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  53914. serializationObject.size = this.getSize().width;
  53915. serializationObject.generateMipMaps = this._generateMipMaps;
  53916. return serializationObject;
  53917. };
  53918. /**
  53919. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53920. * @param parsedTexture defines parsed texture data
  53921. * @param scene defines the current scene
  53922. * @param rootUrl defines the root URL containing noise procedural texture information
  53923. * @returns a parsed NoiseProceduralTexture
  53924. */
  53925. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  53926. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  53927. texture.brightness = parsedTexture.brightness;
  53928. texture.octaves = parsedTexture.octaves;
  53929. texture.persistence = parsedTexture.persistence;
  53930. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  53931. return texture;
  53932. };
  53933. return NoiseProceduralTexture;
  53934. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  53935. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  53936. /***/ }),
  53937. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  53938. /*!*************************************************************!*\
  53939. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  53940. \*************************************************************/
  53941. /*! exports provided: ProceduralTexture */
  53942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53943. "use strict";
  53944. __webpack_require__.r(__webpack_exports__);
  53945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  53946. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53947. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  53948. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  53949. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  53950. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53951. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  53952. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53953. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  53954. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53955. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  53956. /**
  53957. * 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.
  53958. * This is the base class of any Procedural texture and contains most of the shareable code.
  53959. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53960. */
  53961. var ProceduralTexture = /** @class */ (function (_super) {
  53962. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  53963. /**
  53964. * Instantiates a new procedural texture.
  53965. * 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.
  53966. * This is the base class of any Procedural texture and contains most of the shareable code.
  53967. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53968. * @param name Define the name of the texture
  53969. * @param size Define the size of the texture to create
  53970. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  53971. * @param scene Define the scene the texture belongs to
  53972. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53973. * @param generateMipMaps Define if the texture should creates mip maps or not
  53974. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  53975. */
  53976. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  53977. if (fallbackTexture === void 0) { fallbackTexture = null; }
  53978. if (generateMipMaps === void 0) { generateMipMaps = true; }
  53979. if (isCube === void 0) { isCube = false; }
  53980. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  53981. _this.isCube = isCube;
  53982. /**
  53983. * Define if the texture is enabled or not (disabled texture will not render)
  53984. */
  53985. _this.isEnabled = true;
  53986. /**
  53987. * Define if the texture must be cleared before rendering (default is true)
  53988. */
  53989. _this.autoClear = true;
  53990. /**
  53991. * Event raised when the texture is generated
  53992. */
  53993. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53994. /** @hidden */
  53995. _this._textures = {};
  53996. _this._currentRefreshId = -1;
  53997. _this._refreshRate = 1;
  53998. _this._vertexBuffers = {};
  53999. _this._uniforms = new Array();
  54000. _this._samplers = new Array();
  54001. _this._floats = {};
  54002. _this._ints = {};
  54003. _this._floatsArrays = {};
  54004. _this._colors3 = {};
  54005. _this._colors4 = {};
  54006. _this._vectors2 = {};
  54007. _this._vectors3 = {};
  54008. _this._matrices = {};
  54009. _this._fallbackTextureUsed = false;
  54010. _this._cachedDefines = "";
  54011. _this._contentUpdateId = -1;
  54012. scene = _this.getScene();
  54013. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  54014. if (!component) {
  54015. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  54016. scene._addComponent(component);
  54017. }
  54018. scene.proceduralTextures.push(_this);
  54019. _this._engine = scene.getEngine();
  54020. _this.name = name;
  54021. _this.isRenderTarget = true;
  54022. _this._size = size;
  54023. _this._generateMipMaps = generateMipMaps;
  54024. _this.setFragment(fragment);
  54025. _this._fallbackTexture = fallbackTexture;
  54026. if (isCube) {
  54027. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  54028. _this.setFloat("face", 0);
  54029. }
  54030. else {
  54031. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  54032. }
  54033. // VBO
  54034. var vertices = [];
  54035. vertices.push(1, 1);
  54036. vertices.push(-1, 1);
  54037. vertices.push(-1, -1);
  54038. vertices.push(1, -1);
  54039. _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);
  54040. _this._createIndexBuffer();
  54041. return _this;
  54042. }
  54043. /**
  54044. * The effect that is created when initializing the post process.
  54045. * @returns The created effect corrisponding the the postprocess.
  54046. */
  54047. ProceduralTexture.prototype.getEffect = function () {
  54048. return this._effect;
  54049. };
  54050. /**
  54051. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  54052. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  54053. */
  54054. ProceduralTexture.prototype.getContent = function () {
  54055. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  54056. return this._contentData;
  54057. }
  54058. this._contentData = this.readPixels(0, 0, this._contentData);
  54059. this._contentUpdateId = this._currentRefreshId;
  54060. return this._contentData;
  54061. };
  54062. ProceduralTexture.prototype._createIndexBuffer = function () {
  54063. var engine = this._engine;
  54064. // Indices
  54065. var indices = [];
  54066. indices.push(0);
  54067. indices.push(1);
  54068. indices.push(2);
  54069. indices.push(0);
  54070. indices.push(2);
  54071. indices.push(3);
  54072. this._indexBuffer = engine.createIndexBuffer(indices);
  54073. };
  54074. /** @hidden */
  54075. ProceduralTexture.prototype._rebuild = function () {
  54076. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54077. if (vb) {
  54078. vb._rebuild();
  54079. }
  54080. this._createIndexBuffer();
  54081. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  54082. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  54083. }
  54084. };
  54085. /**
  54086. * Resets the texture in order to recreate its associated resources.
  54087. * This can be called in case of context loss
  54088. */
  54089. ProceduralTexture.prototype.reset = function () {
  54090. if (this._effect === undefined) {
  54091. return;
  54092. }
  54093. var engine = this._engine;
  54094. engine._releaseEffect(this._effect);
  54095. };
  54096. ProceduralTexture.prototype._getDefines = function () {
  54097. return "";
  54098. };
  54099. /**
  54100. * Is the texture ready to be used ? (rendered at least once)
  54101. * @returns true if ready, otherwise, false.
  54102. */
  54103. ProceduralTexture.prototype.isReady = function () {
  54104. var _this = this;
  54105. var engine = this._engine;
  54106. var shaders;
  54107. if (!this._fragment) {
  54108. return false;
  54109. }
  54110. if (this._fallbackTextureUsed) {
  54111. return true;
  54112. }
  54113. var defines = this._getDefines();
  54114. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  54115. return true;
  54116. }
  54117. if (this._fragment.fragmentElement !== undefined) {
  54118. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  54119. }
  54120. else {
  54121. shaders = { vertex: "procedural", fragment: this._fragment };
  54122. }
  54123. this._cachedDefines = defines;
  54124. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  54125. _this.releaseInternalTexture();
  54126. if (_this._fallbackTexture) {
  54127. _this._texture = _this._fallbackTexture._texture;
  54128. if (_this._texture) {
  54129. _this._texture.incrementReferences();
  54130. }
  54131. }
  54132. _this._fallbackTextureUsed = true;
  54133. });
  54134. return this._effect.isReady();
  54135. };
  54136. /**
  54137. * Resets the refresh counter of the texture and start bak from scratch.
  54138. * Could be useful to regenerate the texture if it is setup to render only once.
  54139. */
  54140. ProceduralTexture.prototype.resetRefreshCounter = function () {
  54141. this._currentRefreshId = -1;
  54142. };
  54143. /**
  54144. * Set the fragment shader to use in order to render the texture.
  54145. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  54146. */
  54147. ProceduralTexture.prototype.setFragment = function (fragment) {
  54148. this._fragment = fragment;
  54149. };
  54150. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  54151. /**
  54152. * Define the refresh rate of the texture or the rendering frequency.
  54153. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  54154. */
  54155. get: function () {
  54156. return this._refreshRate;
  54157. },
  54158. set: function (value) {
  54159. this._refreshRate = value;
  54160. this.resetRefreshCounter();
  54161. },
  54162. enumerable: true,
  54163. configurable: true
  54164. });
  54165. /** @hidden */
  54166. ProceduralTexture.prototype._shouldRender = function () {
  54167. if (!this.isEnabled || !this.isReady() || !this._texture) {
  54168. if (this._texture) {
  54169. this._texture.isReady = false;
  54170. }
  54171. return false;
  54172. }
  54173. if (this._fallbackTextureUsed) {
  54174. return false;
  54175. }
  54176. if (this._currentRefreshId === -1) { // At least render once
  54177. this._currentRefreshId = 1;
  54178. return true;
  54179. }
  54180. if (this.refreshRate === this._currentRefreshId) {
  54181. this._currentRefreshId = 1;
  54182. return true;
  54183. }
  54184. this._currentRefreshId++;
  54185. return false;
  54186. };
  54187. /**
  54188. * Get the size the texture is rendering at.
  54189. * @returns the size (texture is always squared)
  54190. */
  54191. ProceduralTexture.prototype.getRenderSize = function () {
  54192. return this._size;
  54193. };
  54194. /**
  54195. * Resize the texture to new value.
  54196. * @param size Define the new size the texture should have
  54197. * @param generateMipMaps Define whether the new texture should create mip maps
  54198. */
  54199. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  54200. if (this._fallbackTextureUsed) {
  54201. return;
  54202. }
  54203. this.releaseInternalTexture();
  54204. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  54205. // Update properties
  54206. this._size = size;
  54207. this._generateMipMaps = generateMipMaps;
  54208. };
  54209. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  54210. if (this._uniforms.indexOf(uniformName) === -1) {
  54211. this._uniforms.push(uniformName);
  54212. }
  54213. };
  54214. /**
  54215. * Set a texture in the shader program used to render.
  54216. * @param name Define the name of the uniform samplers as defined in the shader
  54217. * @param texture Define the texture to bind to this sampler
  54218. * @return the texture itself allowing "fluent" like uniform updates
  54219. */
  54220. ProceduralTexture.prototype.setTexture = function (name, texture) {
  54221. if (this._samplers.indexOf(name) === -1) {
  54222. this._samplers.push(name);
  54223. }
  54224. this._textures[name] = texture;
  54225. return this;
  54226. };
  54227. /**
  54228. * Set a float in the shader.
  54229. * @param name Define the name of the uniform as defined in the shader
  54230. * @param value Define the value to give to the uniform
  54231. * @return the texture itself allowing "fluent" like uniform updates
  54232. */
  54233. ProceduralTexture.prototype.setFloat = function (name, value) {
  54234. this._checkUniform(name);
  54235. this._floats[name] = value;
  54236. return this;
  54237. };
  54238. /**
  54239. * Set a int in the shader.
  54240. * @param name Define the name of the uniform as defined in the shader
  54241. * @param value Define the value to give to the uniform
  54242. * @return the texture itself allowing "fluent" like uniform updates
  54243. */
  54244. ProceduralTexture.prototype.setInt = function (name, value) {
  54245. this._checkUniform(name);
  54246. this._ints[name] = value;
  54247. return this;
  54248. };
  54249. /**
  54250. * Set an array of floats in the shader.
  54251. * @param name Define the name of the uniform as defined in the shader
  54252. * @param value Define the value to give to the uniform
  54253. * @return the texture itself allowing "fluent" like uniform updates
  54254. */
  54255. ProceduralTexture.prototype.setFloats = function (name, value) {
  54256. this._checkUniform(name);
  54257. this._floatsArrays[name] = value;
  54258. return this;
  54259. };
  54260. /**
  54261. * Set a vec3 in the shader from a Color3.
  54262. * @param name Define the name of the uniform as defined in the shader
  54263. * @param value Define the value to give to the uniform
  54264. * @return the texture itself allowing "fluent" like uniform updates
  54265. */
  54266. ProceduralTexture.prototype.setColor3 = function (name, value) {
  54267. this._checkUniform(name);
  54268. this._colors3[name] = value;
  54269. return this;
  54270. };
  54271. /**
  54272. * Set a vec4 in the shader from a Color4.
  54273. * @param name Define the name of the uniform as defined in the shader
  54274. * @param value Define the value to give to the uniform
  54275. * @return the texture itself allowing "fluent" like uniform updates
  54276. */
  54277. ProceduralTexture.prototype.setColor4 = function (name, value) {
  54278. this._checkUniform(name);
  54279. this._colors4[name] = value;
  54280. return this;
  54281. };
  54282. /**
  54283. * Set a vec2 in the shader from a Vector2.
  54284. * @param name Define the name of the uniform as defined in the shader
  54285. * @param value Define the value to give to the uniform
  54286. * @return the texture itself allowing "fluent" like uniform updates
  54287. */
  54288. ProceduralTexture.prototype.setVector2 = function (name, value) {
  54289. this._checkUniform(name);
  54290. this._vectors2[name] = value;
  54291. return this;
  54292. };
  54293. /**
  54294. * Set a vec3 in the shader from a Vector3.
  54295. * @param name Define the name of the uniform as defined in the shader
  54296. * @param value Define the value to give to the uniform
  54297. * @return the texture itself allowing "fluent" like uniform updates
  54298. */
  54299. ProceduralTexture.prototype.setVector3 = function (name, value) {
  54300. this._checkUniform(name);
  54301. this._vectors3[name] = value;
  54302. return this;
  54303. };
  54304. /**
  54305. * Set a mat4 in the shader from a MAtrix.
  54306. * @param name Define the name of the uniform as defined in the shader
  54307. * @param value Define the value to give to the uniform
  54308. * @return the texture itself allowing "fluent" like uniform updates
  54309. */
  54310. ProceduralTexture.prototype.setMatrix = function (name, value) {
  54311. this._checkUniform(name);
  54312. this._matrices[name] = value;
  54313. return this;
  54314. };
  54315. /**
  54316. * Render the texture to its associated render target.
  54317. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54318. */
  54319. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  54320. var scene = this.getScene();
  54321. if (!scene) {
  54322. return;
  54323. }
  54324. var engine = this._engine;
  54325. // Render
  54326. engine.enableEffect(this._effect);
  54327. engine.setState(false);
  54328. // Texture
  54329. for (var name in this._textures) {
  54330. this._effect.setTexture(name, this._textures[name]);
  54331. }
  54332. // Float
  54333. for (name in this._ints) {
  54334. this._effect.setInt(name, this._ints[name]);
  54335. }
  54336. // Float
  54337. for (name in this._floats) {
  54338. this._effect.setFloat(name, this._floats[name]);
  54339. }
  54340. // Floats
  54341. for (name in this._floatsArrays) {
  54342. this._effect.setArray(name, this._floatsArrays[name]);
  54343. }
  54344. // Color3
  54345. for (name in this._colors3) {
  54346. this._effect.setColor3(name, this._colors3[name]);
  54347. }
  54348. // Color4
  54349. for (name in this._colors4) {
  54350. var color = this._colors4[name];
  54351. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  54352. }
  54353. // Vector2
  54354. for (name in this._vectors2) {
  54355. this._effect.setVector2(name, this._vectors2[name]);
  54356. }
  54357. // Vector3
  54358. for (name in this._vectors3) {
  54359. this._effect.setVector3(name, this._vectors3[name]);
  54360. }
  54361. // Matrix
  54362. for (name in this._matrices) {
  54363. this._effect.setMatrix(name, this._matrices[name]);
  54364. }
  54365. if (!this._texture) {
  54366. return;
  54367. }
  54368. if (this.isCube) {
  54369. for (var face = 0; face < 6; face++) {
  54370. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  54371. // VBOs
  54372. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54373. this._effect.setFloat("face", face);
  54374. // Clear
  54375. if (this.autoClear) {
  54376. engine.clear(scene.clearColor, true, false, false);
  54377. }
  54378. // Draw order
  54379. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54380. // Mipmaps
  54381. if (face === 5) {
  54382. engine.generateMipMapsForCubemap(this._texture);
  54383. }
  54384. }
  54385. }
  54386. else {
  54387. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  54388. // VBOs
  54389. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54390. // Clear
  54391. if (this.autoClear) {
  54392. engine.clear(scene.clearColor, true, false, false);
  54393. }
  54394. // Draw order
  54395. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54396. }
  54397. // Unbind
  54398. engine.unBindFramebuffer(this._texture, this.isCube);
  54399. if (this.onGenerated) {
  54400. this.onGenerated();
  54401. }
  54402. this.onGeneratedObservable.notifyObservers(this);
  54403. };
  54404. /**
  54405. * Clone the texture.
  54406. * @returns the cloned texture
  54407. */
  54408. ProceduralTexture.prototype.clone = function () {
  54409. var textureSize = this.getSize();
  54410. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  54411. // Base texture
  54412. newTexture.hasAlpha = this.hasAlpha;
  54413. newTexture.level = this.level;
  54414. // RenderTarget Texture
  54415. newTexture.coordinatesMode = this.coordinatesMode;
  54416. return newTexture;
  54417. };
  54418. /**
  54419. * Dispose the texture and release its asoociated resources.
  54420. */
  54421. ProceduralTexture.prototype.dispose = function () {
  54422. var scene = this.getScene();
  54423. if (!scene) {
  54424. return;
  54425. }
  54426. var index = scene.proceduralTextures.indexOf(this);
  54427. if (index >= 0) {
  54428. scene.proceduralTextures.splice(index, 1);
  54429. }
  54430. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54431. if (vertexBuffer) {
  54432. vertexBuffer.dispose();
  54433. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  54434. }
  54435. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  54436. this._indexBuffer = null;
  54437. }
  54438. _super.prototype.dispose.call(this);
  54439. };
  54440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54442. ], ProceduralTexture.prototype, "isEnabled", void 0);
  54443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54445. ], ProceduralTexture.prototype, "autoClear", void 0);
  54446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54448. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  54449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54451. ], ProceduralTexture.prototype, "_size", void 0);
  54452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54454. ], ProceduralTexture.prototype, "refreshRate", null);
  54455. return ProceduralTexture;
  54456. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  54457. /***/ }),
  54458. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  54459. /*!***************************************************************************!*\
  54460. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  54461. \***************************************************************************/
  54462. /*! exports provided: ProceduralTextureSceneComponent */
  54463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54464. "use strict";
  54465. __webpack_require__.r(__webpack_exports__);
  54466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  54467. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  54468. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  54469. /**
  54470. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  54471. * in a given scene.
  54472. */
  54473. var ProceduralTextureSceneComponent = /** @class */ (function () {
  54474. /**
  54475. * Creates a new instance of the component for the given scene
  54476. * @param scene Defines the scene to register the component in
  54477. */
  54478. function ProceduralTextureSceneComponent(scene) {
  54479. /**
  54480. * The component name helpfull to identify the component in the list of scene components.
  54481. */
  54482. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  54483. this.scene = scene;
  54484. this.scene.proceduralTextures = new Array();
  54485. scene.layers = new Array();
  54486. }
  54487. /**
  54488. * Registers the component in a given scene
  54489. */
  54490. ProceduralTextureSceneComponent.prototype.register = function () {
  54491. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  54492. };
  54493. /**
  54494. * Rebuilds the elements related to this component in case of
  54495. * context lost for instance.
  54496. */
  54497. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  54498. // Nothing to do here.
  54499. };
  54500. /**
  54501. * Disposes the component and the associated ressources.
  54502. */
  54503. ProceduralTextureSceneComponent.prototype.dispose = function () {
  54504. // Nothing to do here.
  54505. };
  54506. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  54507. if (this.scene.proceduralTexturesEnabled) {
  54508. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54509. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  54510. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  54511. if (proceduralTexture._shouldRender()) {
  54512. proceduralTexture.render();
  54513. }
  54514. }
  54515. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54516. }
  54517. };
  54518. return ProceduralTextureSceneComponent;
  54519. }());
  54520. /***/ }),
  54521. /***/ "./Materials/Textures/baseTexture.ts":
  54522. /*!*******************************************!*\
  54523. !*** ./Materials/Textures/baseTexture.ts ***!
  54524. \*******************************************/
  54525. /*! exports provided: BaseTexture */
  54526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54527. "use strict";
  54528. __webpack_require__.r(__webpack_exports__);
  54529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  54530. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54531. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54532. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  54533. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54534. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  54535. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54536. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  54537. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54538. /**
  54539. * Base class of all the textures in babylon.
  54540. * It groups all the common properties the materials, post process, lights... might need
  54541. * in order to make a correct use of the texture.
  54542. */
  54543. var BaseTexture = /** @class */ (function () {
  54544. /**
  54545. * Instantiates a new BaseTexture.
  54546. * Base class of all the textures in babylon.
  54547. * It groups all the common properties the materials, post process, lights... might need
  54548. * in order to make a correct use of the texture.
  54549. * @param scene Define the scene the texture blongs to
  54550. */
  54551. function BaseTexture(scene) {
  54552. /**
  54553. * Gets or sets an object used to store user defined information.
  54554. */
  54555. this.metadata = null;
  54556. /**
  54557. * For internal use only. Please do not use.
  54558. */
  54559. this.reservedDataStore = null;
  54560. this._hasAlpha = false;
  54561. /**
  54562. * Defines if the alpha value should be determined via the rgb values.
  54563. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  54564. */
  54565. this.getAlphaFromRGB = false;
  54566. /**
  54567. * Intensity or strength of the texture.
  54568. * It is commonly used by materials to fine tune the intensity of the texture
  54569. */
  54570. this.level = 1;
  54571. /**
  54572. * Define the UV chanel to use starting from 0 and defaulting to 0.
  54573. * This is part of the texture as textures usually maps to one uv set.
  54574. */
  54575. this.coordinatesIndex = 0;
  54576. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  54577. /**
  54578. * | Value | Type | Description |
  54579. * | ----- | ------------------ | ----------- |
  54580. * | 0 | CLAMP_ADDRESSMODE | |
  54581. * | 1 | WRAP_ADDRESSMODE | |
  54582. * | 2 | MIRROR_ADDRESSMODE | |
  54583. */
  54584. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54585. /**
  54586. * | Value | Type | Description |
  54587. * | ----- | ------------------ | ----------- |
  54588. * | 0 | CLAMP_ADDRESSMODE | |
  54589. * | 1 | WRAP_ADDRESSMODE | |
  54590. * | 2 | MIRROR_ADDRESSMODE | |
  54591. */
  54592. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54593. /**
  54594. * | Value | Type | Description |
  54595. * | ----- | ------------------ | ----------- |
  54596. * | 0 | CLAMP_ADDRESSMODE | |
  54597. * | 1 | WRAP_ADDRESSMODE | |
  54598. * | 2 | MIRROR_ADDRESSMODE | |
  54599. */
  54600. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54601. /**
  54602. * With compliant hardware and browser (supporting anisotropic filtering)
  54603. * this defines the level of anisotropic filtering in the texture.
  54604. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  54605. */
  54606. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  54607. /**
  54608. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  54609. * HDR texture are usually stored in linear space.
  54610. * This only impacts the PBR and Background materials
  54611. */
  54612. this.gammaSpace = true;
  54613. /**
  54614. * Is Z inverted in the texture (useful in a cube texture).
  54615. */
  54616. this.invertZ = false;
  54617. /**
  54618. * @hidden
  54619. */
  54620. this.lodLevelInAlpha = false;
  54621. /**
  54622. * Define if the texture is a render target.
  54623. */
  54624. this.isRenderTarget = false;
  54625. /**
  54626. * Define the list of animation attached to the texture.
  54627. */
  54628. this.animations = new Array();
  54629. /**
  54630. * An event triggered when the texture is disposed.
  54631. */
  54632. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  54633. /**
  54634. * Define the current state of the loading sequence when in delayed load mode.
  54635. */
  54636. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  54637. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54638. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  54639. if (this._scene) {
  54640. this.uniqueId = this._scene.getUniqueId();
  54641. this._scene.addTexture(this);
  54642. }
  54643. this._uid = null;
  54644. }
  54645. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  54646. get: function () {
  54647. return this._hasAlpha;
  54648. },
  54649. /**
  54650. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  54651. */
  54652. set: function (value) {
  54653. if (this._hasAlpha === value) {
  54654. return;
  54655. }
  54656. this._hasAlpha = value;
  54657. if (this._scene) {
  54658. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  54659. }
  54660. },
  54661. enumerable: true,
  54662. configurable: true
  54663. });
  54664. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  54665. get: function () {
  54666. return this._coordinatesMode;
  54667. },
  54668. /**
  54669. * How a texture is mapped.
  54670. *
  54671. * | Value | Type | Description |
  54672. * | ----- | ----------------------------------- | ----------- |
  54673. * | 0 | EXPLICIT_MODE | |
  54674. * | 1 | SPHERICAL_MODE | |
  54675. * | 2 | PLANAR_MODE | |
  54676. * | 3 | CUBIC_MODE | |
  54677. * | 4 | PROJECTION_MODE | |
  54678. * | 5 | SKYBOX_MODE | |
  54679. * | 6 | INVCUBIC_MODE | |
  54680. * | 7 | EQUIRECTANGULAR_MODE | |
  54681. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  54682. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  54683. */
  54684. set: function (value) {
  54685. if (this._coordinatesMode === value) {
  54686. return;
  54687. }
  54688. this._coordinatesMode = value;
  54689. if (this._scene) {
  54690. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54691. }
  54692. },
  54693. enumerable: true,
  54694. configurable: true
  54695. });
  54696. Object.defineProperty(BaseTexture.prototype, "isCube", {
  54697. /**
  54698. * Define if the texture is a cube texture or if false a 2d texture.
  54699. */
  54700. get: function () {
  54701. if (!this._texture) {
  54702. return false;
  54703. }
  54704. return this._texture.isCube;
  54705. },
  54706. set: function (value) {
  54707. if (!this._texture) {
  54708. return;
  54709. }
  54710. this._texture.isCube = value;
  54711. },
  54712. enumerable: true,
  54713. configurable: true
  54714. });
  54715. Object.defineProperty(BaseTexture.prototype, "is3D", {
  54716. /**
  54717. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  54718. */
  54719. get: function () {
  54720. if (!this._texture) {
  54721. return false;
  54722. }
  54723. return this._texture.is3D;
  54724. },
  54725. set: function (value) {
  54726. if (!this._texture) {
  54727. return;
  54728. }
  54729. this._texture.is3D = value;
  54730. },
  54731. enumerable: true,
  54732. configurable: true
  54733. });
  54734. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  54735. /**
  54736. * Gets whether or not the texture contains RGBD data.
  54737. */
  54738. get: function () {
  54739. return this._texture != null && this._texture._isRGBD;
  54740. },
  54741. enumerable: true,
  54742. configurable: true
  54743. });
  54744. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  54745. /**
  54746. * Are mip maps generated for this texture or not.
  54747. */
  54748. get: function () {
  54749. return false;
  54750. },
  54751. enumerable: true,
  54752. configurable: true
  54753. });
  54754. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  54755. /**
  54756. * With prefiltered texture, defined the offset used during the prefiltering steps.
  54757. */
  54758. get: function () {
  54759. if (this._texture) {
  54760. return this._texture._lodGenerationOffset;
  54761. }
  54762. return 0.0;
  54763. },
  54764. set: function (value) {
  54765. if (this._texture) {
  54766. this._texture._lodGenerationOffset = value;
  54767. }
  54768. },
  54769. enumerable: true,
  54770. configurable: true
  54771. });
  54772. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  54773. /**
  54774. * With prefiltered texture, defined the scale used during the prefiltering steps.
  54775. */
  54776. get: function () {
  54777. if (this._texture) {
  54778. return this._texture._lodGenerationScale;
  54779. }
  54780. return 0.0;
  54781. },
  54782. set: function (value) {
  54783. if (this._texture) {
  54784. this._texture._lodGenerationScale = value;
  54785. }
  54786. },
  54787. enumerable: true,
  54788. configurable: true
  54789. });
  54790. Object.defineProperty(BaseTexture.prototype, "uid", {
  54791. /**
  54792. * Define the unique id of the texture in the scene.
  54793. */
  54794. get: function () {
  54795. if (!this._uid) {
  54796. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  54797. }
  54798. return this._uid;
  54799. },
  54800. enumerable: true,
  54801. configurable: true
  54802. });
  54803. /**
  54804. * Return a string representation of the texture.
  54805. * @returns the texture as a string
  54806. */
  54807. BaseTexture.prototype.toString = function () {
  54808. return this.name;
  54809. };
  54810. /**
  54811. * Get the class name of the texture.
  54812. * @returns "BaseTexture"
  54813. */
  54814. BaseTexture.prototype.getClassName = function () {
  54815. return "BaseTexture";
  54816. };
  54817. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  54818. /**
  54819. * Callback triggered when the texture has been disposed.
  54820. * Kept for back compatibility, you can use the onDisposeObservable instead.
  54821. */
  54822. set: function (callback) {
  54823. if (this._onDisposeObserver) {
  54824. this.onDisposeObservable.remove(this._onDisposeObserver);
  54825. }
  54826. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  54827. },
  54828. enumerable: true,
  54829. configurable: true
  54830. });
  54831. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  54832. /**
  54833. * Define if the texture is preventinga material to render or not.
  54834. * If not and the texture is not ready, the engine will use a default black texture instead.
  54835. */
  54836. get: function () {
  54837. return true;
  54838. },
  54839. enumerable: true,
  54840. configurable: true
  54841. });
  54842. /**
  54843. * Get the scene the texture belongs to.
  54844. * @returns the scene or null if undefined
  54845. */
  54846. BaseTexture.prototype.getScene = function () {
  54847. return this._scene;
  54848. };
  54849. /**
  54850. * Get the texture transform matrix used to offset tile the texture for istance.
  54851. * @returns the transformation matrix
  54852. */
  54853. BaseTexture.prototype.getTextureMatrix = function () {
  54854. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54855. };
  54856. /**
  54857. * Get the texture reflection matrix used to rotate/transform the reflection.
  54858. * @returns the reflection matrix
  54859. */
  54860. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  54861. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54862. };
  54863. /**
  54864. * Get the underlying lower level texture from Babylon.
  54865. * @returns the insternal texture
  54866. */
  54867. BaseTexture.prototype.getInternalTexture = function () {
  54868. return this._texture;
  54869. };
  54870. /**
  54871. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  54872. * @returns true if ready or not blocking
  54873. */
  54874. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  54875. return !this.isBlocking || this.isReady();
  54876. };
  54877. /**
  54878. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  54879. * @returns true if fully ready
  54880. */
  54881. BaseTexture.prototype.isReady = function () {
  54882. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54883. this.delayLoad();
  54884. return false;
  54885. }
  54886. if (this._texture) {
  54887. return this._texture.isReady;
  54888. }
  54889. return false;
  54890. };
  54891. /**
  54892. * Get the size of the texture.
  54893. * @returns the texture size.
  54894. */
  54895. BaseTexture.prototype.getSize = function () {
  54896. if (this._texture) {
  54897. if (this._texture.width) {
  54898. this._cachedSize.width = this._texture.width;
  54899. this._cachedSize.height = this._texture.height;
  54900. return this._cachedSize;
  54901. }
  54902. if (this._texture._size) {
  54903. this._cachedSize.width = this._texture._size;
  54904. this._cachedSize.height = this._texture._size;
  54905. return this._cachedSize;
  54906. }
  54907. }
  54908. return this._cachedSize;
  54909. };
  54910. /**
  54911. * Get the base size of the texture.
  54912. * It can be different from the size if the texture has been resized for POT for instance
  54913. * @returns the base size
  54914. */
  54915. BaseTexture.prototype.getBaseSize = function () {
  54916. if (!this.isReady() || !this._texture) {
  54917. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54918. }
  54919. if (this._texture._size) {
  54920. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  54921. }
  54922. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  54923. };
  54924. /**
  54925. * Update the sampling mode of the texture.
  54926. * Default is Trilinear mode.
  54927. *
  54928. * | Value | Type | Description |
  54929. * | ----- | ------------------ | ----------- |
  54930. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  54931. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  54932. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  54933. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  54934. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  54935. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  54936. * | 7 | NEAREST_LINEAR | |
  54937. * | 8 | NEAREST_NEAREST | |
  54938. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  54939. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  54940. * | 11 | LINEAR_LINEAR | |
  54941. * | 12 | LINEAR_NEAREST | |
  54942. *
  54943. * > _mag_: magnification filter (close to the viewer)
  54944. * > _min_: minification filter (far from the viewer)
  54945. * > _mip_: filter used between mip map levels
  54946. *@param samplingMode Define the new sampling mode of the texture
  54947. */
  54948. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  54949. if (!this._texture) {
  54950. return;
  54951. }
  54952. var scene = this.getScene();
  54953. if (!scene) {
  54954. return;
  54955. }
  54956. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  54957. };
  54958. /**
  54959. * Scales the texture if is `canRescale()`
  54960. * @param ratio the resize factor we want to use to rescale
  54961. */
  54962. BaseTexture.prototype.scale = function (ratio) {
  54963. };
  54964. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  54965. /**
  54966. * Get if the texture can rescale.
  54967. */
  54968. get: function () {
  54969. return false;
  54970. },
  54971. enumerable: true,
  54972. configurable: true
  54973. });
  54974. /** @hidden */
  54975. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  54976. if (!this._scene) {
  54977. return null;
  54978. }
  54979. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  54980. for (var index = 0; index < texturesCache.length; index++) {
  54981. var texturesCacheEntry = texturesCache[index];
  54982. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  54983. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  54984. texturesCacheEntry.incrementReferences();
  54985. return texturesCacheEntry;
  54986. }
  54987. }
  54988. }
  54989. return null;
  54990. };
  54991. /** @hidden */
  54992. BaseTexture.prototype._rebuild = function () {
  54993. };
  54994. /**
  54995. * Triggers the load sequence in delayed load mode.
  54996. */
  54997. BaseTexture.prototype.delayLoad = function () {
  54998. };
  54999. /**
  55000. * Clones the texture.
  55001. * @returns the cloned texture
  55002. */
  55003. BaseTexture.prototype.clone = function () {
  55004. return null;
  55005. };
  55006. Object.defineProperty(BaseTexture.prototype, "textureType", {
  55007. /**
  55008. * Get the texture underlying type (INT, FLOAT...)
  55009. */
  55010. get: function () {
  55011. if (!this._texture) {
  55012. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  55013. }
  55014. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  55015. },
  55016. enumerable: true,
  55017. configurable: true
  55018. });
  55019. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  55020. /**
  55021. * Get the texture underlying format (RGB, RGBA...)
  55022. */
  55023. get: function () {
  55024. if (!this._texture) {
  55025. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  55026. }
  55027. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  55028. },
  55029. enumerable: true,
  55030. configurable: true
  55031. });
  55032. /**
  55033. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  55034. * This will returns an RGBA array buffer containing either in values (0-255) or
  55035. * float values (0-1) depending of the underlying buffer type.
  55036. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  55037. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  55038. * @param buffer defines a user defined buffer to fill with data (can be null)
  55039. * @returns The Array buffer containing the pixels data.
  55040. */
  55041. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  55042. if (faceIndex === void 0) { faceIndex = 0; }
  55043. if (level === void 0) { level = 0; }
  55044. if (buffer === void 0) { buffer = null; }
  55045. if (!this._texture) {
  55046. return null;
  55047. }
  55048. var size = this.getSize();
  55049. var width = size.width;
  55050. var height = size.height;
  55051. var scene = this.getScene();
  55052. if (!scene) {
  55053. return null;
  55054. }
  55055. var engine = scene.getEngine();
  55056. if (level != 0) {
  55057. width = width / Math.pow(2, level);
  55058. height = height / Math.pow(2, level);
  55059. width = Math.round(width);
  55060. height = Math.round(height);
  55061. }
  55062. if (this._texture.isCube) {
  55063. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  55064. }
  55065. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  55066. };
  55067. /**
  55068. * Release and destroy the underlying lower level texture aka internalTexture.
  55069. */
  55070. BaseTexture.prototype.releaseInternalTexture = function () {
  55071. if (this._texture) {
  55072. this._texture.dispose();
  55073. this._texture = null;
  55074. }
  55075. };
  55076. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  55077. /**
  55078. * Get the polynomial representation of the texture data.
  55079. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  55080. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  55081. */
  55082. get: function () {
  55083. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  55084. return null;
  55085. }
  55086. if (!this._texture._sphericalPolynomial) {
  55087. this._texture._sphericalPolynomial =
  55088. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  55089. }
  55090. return this._texture._sphericalPolynomial;
  55091. },
  55092. set: function (value) {
  55093. if (this._texture) {
  55094. this._texture._sphericalPolynomial = value;
  55095. }
  55096. },
  55097. enumerable: true,
  55098. configurable: true
  55099. });
  55100. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  55101. /** @hidden */
  55102. get: function () {
  55103. if (this._texture) {
  55104. return this._texture._lodTextureHigh;
  55105. }
  55106. return null;
  55107. },
  55108. enumerable: true,
  55109. configurable: true
  55110. });
  55111. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  55112. /** @hidden */
  55113. get: function () {
  55114. if (this._texture) {
  55115. return this._texture._lodTextureMid;
  55116. }
  55117. return null;
  55118. },
  55119. enumerable: true,
  55120. configurable: true
  55121. });
  55122. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  55123. /** @hidden */
  55124. get: function () {
  55125. if (this._texture) {
  55126. return this._texture._lodTextureLow;
  55127. }
  55128. return null;
  55129. },
  55130. enumerable: true,
  55131. configurable: true
  55132. });
  55133. /**
  55134. * Dispose the texture and release its associated resources.
  55135. */
  55136. BaseTexture.prototype.dispose = function () {
  55137. if (!this._scene) {
  55138. return;
  55139. }
  55140. // Animations
  55141. this._scene.stopAnimation(this);
  55142. // Remove from scene
  55143. this._scene._removePendingData(this);
  55144. var index = this._scene.textures.indexOf(this);
  55145. if (index >= 0) {
  55146. this._scene.textures.splice(index, 1);
  55147. }
  55148. this._scene.onTextureRemovedObservable.notifyObservers(this);
  55149. if (this._texture === undefined) {
  55150. return;
  55151. }
  55152. // Release
  55153. this.releaseInternalTexture();
  55154. // Callback
  55155. this.onDisposeObservable.notifyObservers(this);
  55156. this.onDisposeObservable.clear();
  55157. };
  55158. /**
  55159. * Serialize the texture into a JSON representation that can be parsed later on.
  55160. * @returns the JSON representation of the texture
  55161. */
  55162. BaseTexture.prototype.serialize = function () {
  55163. if (!this.name) {
  55164. return null;
  55165. }
  55166. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55167. // Animations
  55168. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  55169. return serializationObject;
  55170. };
  55171. /**
  55172. * Helper function to be called back once a list of texture contains only ready textures.
  55173. * @param textures Define the list of textures to wait for
  55174. * @param callback Define the callback triggered once the entire list will be ready
  55175. */
  55176. BaseTexture.WhenAllReady = function (textures, callback) {
  55177. var numRemaining = textures.length;
  55178. if (numRemaining === 0) {
  55179. callback();
  55180. return;
  55181. }
  55182. var _loop_1 = function () {
  55183. texture = textures[i];
  55184. if (texture.isReady()) {
  55185. if (--numRemaining === 0) {
  55186. callback();
  55187. }
  55188. }
  55189. else {
  55190. onLoadObservable = texture.onLoadObservable;
  55191. var onLoadCallback_1 = function () {
  55192. onLoadObservable.removeCallback(onLoadCallback_1);
  55193. if (--numRemaining === 0) {
  55194. callback();
  55195. }
  55196. };
  55197. onLoadObservable.add(onLoadCallback_1);
  55198. }
  55199. };
  55200. var texture, onLoadObservable;
  55201. for (var i = 0; i < textures.length; i++) {
  55202. _loop_1();
  55203. }
  55204. };
  55205. /**
  55206. * Default anisotropic filtering level for the application.
  55207. * It is set to 4 as a good tradeoff between perf and quality.
  55208. */
  55209. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  55210. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55211. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55212. ], BaseTexture.prototype, "uniqueId", void 0);
  55213. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55214. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55215. ], BaseTexture.prototype, "name", void 0);
  55216. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55218. ], BaseTexture.prototype, "metadata", void 0);
  55219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  55221. ], BaseTexture.prototype, "_hasAlpha", void 0);
  55222. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55223. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55224. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  55225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55227. ], BaseTexture.prototype, "level", void 0);
  55228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55230. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  55231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  55233. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  55234. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55236. ], BaseTexture.prototype, "wrapU", void 0);
  55237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55239. ], BaseTexture.prototype, "wrapV", void 0);
  55240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55242. ], BaseTexture.prototype, "wrapR", void 0);
  55243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55245. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  55246. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55248. ], BaseTexture.prototype, "isCube", null);
  55249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55251. ], BaseTexture.prototype, "is3D", null);
  55252. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55254. ], BaseTexture.prototype, "gammaSpace", void 0);
  55255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55257. ], BaseTexture.prototype, "invertZ", void 0);
  55258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55260. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  55261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55263. ], BaseTexture.prototype, "lodGenerationOffset", null);
  55264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55266. ], BaseTexture.prototype, "lodGenerationScale", null);
  55267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55269. ], BaseTexture.prototype, "isRenderTarget", void 0);
  55270. return BaseTexture;
  55271. }());
  55272. /***/ }),
  55273. /***/ "./Materials/Textures/colorGradingTexture.ts":
  55274. /*!***************************************************!*\
  55275. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  55276. \***************************************************/
  55277. /*! exports provided: ColorGradingTexture */
  55278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55279. "use strict";
  55280. __webpack_require__.r(__webpack_exports__);
  55281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  55282. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55283. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55284. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55285. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55286. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55287. /**
  55288. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55289. * It can help converting any input color in a desired output one. This can then be used to create effects
  55290. * from sepia, black and white to sixties or futuristic rendering...
  55291. *
  55292. * The only supported format is currently 3dl.
  55293. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55294. */
  55295. var ColorGradingTexture = /** @class */ (function (_super) {
  55296. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  55297. /**
  55298. * Instantiates a ColorGradingTexture from the following parameters.
  55299. *
  55300. * @param url The location of the color gradind data (currently only supporting 3dl)
  55301. * @param scene The scene the texture will be used in
  55302. */
  55303. function ColorGradingTexture(url, scene) {
  55304. var _this = _super.call(this, scene) || this;
  55305. if (!url) {
  55306. return _this;
  55307. }
  55308. _this._engine = scene.getEngine();
  55309. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55310. _this.name = url;
  55311. _this.url = url;
  55312. _this.hasAlpha = false;
  55313. _this.isCube = false;
  55314. _this.is3D = _this._engine.webGLVersion > 1;
  55315. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55316. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55317. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55318. _this.anisotropicFilteringLevel = 1;
  55319. _this._texture = _this._getFromCache(url, true);
  55320. if (!_this._texture) {
  55321. if (!scene.useDelayedTextureLoading) {
  55322. _this.loadTexture();
  55323. }
  55324. else {
  55325. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55326. }
  55327. }
  55328. return _this;
  55329. }
  55330. /**
  55331. * Returns the texture matrix used in most of the material.
  55332. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55333. */
  55334. ColorGradingTexture.prototype.getTextureMatrix = function () {
  55335. return this._textureMatrix;
  55336. };
  55337. /**
  55338. * Occurs when the file being loaded is a .3dl LUT file.
  55339. */
  55340. ColorGradingTexture.prototype.load3dlTexture = function () {
  55341. var engine = this._engine;
  55342. var texture;
  55343. if (engine.webGLVersion === 1) {
  55344. 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);
  55345. }
  55346. else {
  55347. 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);
  55348. }
  55349. this._texture = texture;
  55350. var callback = function (text) {
  55351. if (typeof text !== "string") {
  55352. return;
  55353. }
  55354. var data = null;
  55355. var tempData = null;
  55356. var line;
  55357. var lines = text.split('\n');
  55358. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  55359. var maxColor = 0;
  55360. for (var i = 0; i < lines.length; i++) {
  55361. line = lines[i];
  55362. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  55363. continue;
  55364. }
  55365. if (line.indexOf('#') === 0) {
  55366. continue;
  55367. }
  55368. var words = line.split(" ");
  55369. if (size === 0) {
  55370. // Number of space + one
  55371. size = words.length;
  55372. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  55373. tempData = new Float32Array(size * size * size * 4);
  55374. continue;
  55375. }
  55376. if (size != 0) {
  55377. var r = Math.max(parseInt(words[0]), 0);
  55378. var g = Math.max(parseInt(words[1]), 0);
  55379. var b = Math.max(parseInt(words[2]), 0);
  55380. maxColor = Math.max(r, maxColor);
  55381. maxColor = Math.max(g, maxColor);
  55382. maxColor = Math.max(b, maxColor);
  55383. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  55384. if (tempData) {
  55385. tempData[pixelStorageIndex + 0] = r;
  55386. tempData[pixelStorageIndex + 1] = g;
  55387. tempData[pixelStorageIndex + 2] = b;
  55388. }
  55389. // Keep for reference in case of back compat problems.
  55390. // pixelIndexSlice++;
  55391. // if (pixelIndexSlice % size == 0) {
  55392. // pixelIndexH++;
  55393. // pixelIndexSlice = 0;
  55394. // if (pixelIndexH % size == 0) {
  55395. // pixelIndexW++;
  55396. // pixelIndexH = 0;
  55397. // }
  55398. // }
  55399. pixelIndexH++;
  55400. if (pixelIndexH % size == 0) {
  55401. pixelIndexSlice++;
  55402. pixelIndexH = 0;
  55403. if (pixelIndexSlice % size == 0) {
  55404. pixelIndexW++;
  55405. pixelIndexSlice = 0;
  55406. }
  55407. }
  55408. }
  55409. }
  55410. if (tempData && data) {
  55411. for (var i = 0; i < tempData.length; i++) {
  55412. if (i > 0 && (i + 1) % 4 === 0) {
  55413. data[i] = 255;
  55414. }
  55415. else {
  55416. var value = tempData[i];
  55417. data[i] = (value / maxColor * 255);
  55418. }
  55419. }
  55420. }
  55421. if (texture.is3D) {
  55422. texture.updateSize(size, size, size);
  55423. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55424. }
  55425. else {
  55426. texture.updateSize(size * size, size);
  55427. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55428. }
  55429. };
  55430. var scene = this.getScene();
  55431. if (scene) {
  55432. scene._loadFile(this.url, callback);
  55433. }
  55434. else {
  55435. this._engine._loadFile(this.url, callback);
  55436. }
  55437. return this._texture;
  55438. };
  55439. /**
  55440. * Starts the loading process of the texture.
  55441. */
  55442. ColorGradingTexture.prototype.loadTexture = function () {
  55443. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  55444. this.load3dlTexture();
  55445. }
  55446. };
  55447. /**
  55448. * Clones the color gradind texture.
  55449. */
  55450. ColorGradingTexture.prototype.clone = function () {
  55451. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  55452. // Base texture
  55453. newTexture.level = this.level;
  55454. return newTexture;
  55455. };
  55456. /**
  55457. * Called during delayed load for textures.
  55458. */
  55459. ColorGradingTexture.prototype.delayLoad = function () {
  55460. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55461. return;
  55462. }
  55463. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  55464. this._texture = this._getFromCache(this.url, true);
  55465. if (!this._texture) {
  55466. this.loadTexture();
  55467. }
  55468. };
  55469. /**
  55470. * Parses a color grading texture serialized by Babylon.
  55471. * @param parsedTexture The texture information being parsedTexture
  55472. * @param scene The scene to load the texture in
  55473. * @param rootUrl The root url of the data assets to load
  55474. * @return A color gradind texture
  55475. */
  55476. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  55477. var texture = null;
  55478. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55479. texture = new ColorGradingTexture(parsedTexture.name, scene);
  55480. texture.name = parsedTexture.name;
  55481. texture.level = parsedTexture.level;
  55482. }
  55483. return texture;
  55484. };
  55485. /**
  55486. * Serializes the LUT texture to json format.
  55487. */
  55488. ColorGradingTexture.prototype.serialize = function () {
  55489. if (!this.name) {
  55490. return null;
  55491. }
  55492. var serializationObject = {};
  55493. serializationObject.name = this.name;
  55494. serializationObject.level = this.level;
  55495. serializationObject.customType = "BABYLON.ColorGradingTexture";
  55496. return serializationObject;
  55497. };
  55498. /**
  55499. * Empty line regex stored for GC.
  55500. */
  55501. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  55502. return ColorGradingTexture;
  55503. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  55504. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  55505. /***/ }),
  55506. /***/ "./Materials/Textures/cubeTexture.ts":
  55507. /*!*******************************************!*\
  55508. !*** ./Materials/Textures/cubeTexture.ts ***!
  55509. \*******************************************/
  55510. /*! exports provided: CubeTexture */
  55511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55512. "use strict";
  55513. __webpack_require__.r(__webpack_exports__);
  55514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  55515. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55516. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55517. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  55518. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55519. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55520. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55521. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55522. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55523. /**
  55524. * Class for creating a cube texture
  55525. */
  55526. var CubeTexture = /** @class */ (function (_super) {
  55527. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  55528. /**
  55529. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  55530. * as prefiltered data.
  55531. * @param rootUrl defines the url of the texture or the root name of the six images
  55532. * @param scene defines the scene the texture is attached to
  55533. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  55534. * @param noMipmap defines if mipmaps should be created or not
  55535. * @param files defines the six files to load for the different faces
  55536. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  55537. * @param onError defines a callback triggered in case of error during load
  55538. * @param format defines the internal format to use for the texture once loaded
  55539. * @param prefiltered defines whether or not the texture is created from prefiltered data
  55540. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  55541. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55542. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55543. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55544. * @return the cube texture
  55545. */
  55546. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  55547. if (extensions === void 0) { extensions = null; }
  55548. if (noMipmap === void 0) { noMipmap = false; }
  55549. if (files === void 0) { files = null; }
  55550. if (onLoad === void 0) { onLoad = null; }
  55551. if (onError === void 0) { onError = null; }
  55552. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  55553. if (prefiltered === void 0) { prefiltered = false; }
  55554. if (forcedExtension === void 0) { forcedExtension = null; }
  55555. if (createPolynomials === void 0) { createPolynomials = false; }
  55556. if (lodScale === void 0) { lodScale = 0.8; }
  55557. if (lodOffset === void 0) { lodOffset = 0; }
  55558. var _this = _super.call(this, scene) || this;
  55559. /**
  55560. * Gets or sets the center of the bounding box associated with the cube texture.
  55561. * It must define where the camera used to render the texture was set
  55562. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55563. */
  55564. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  55565. _this._rotationY = 0;
  55566. /** @hidden */
  55567. _this._prefiltered = false;
  55568. _this.name = rootUrl;
  55569. _this.url = rootUrl;
  55570. _this._noMipmap = noMipmap;
  55571. _this.hasAlpha = false;
  55572. _this._format = format;
  55573. _this.isCube = true;
  55574. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  55575. _this._createPolynomials = createPolynomials;
  55576. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  55577. if (!rootUrl && !files) {
  55578. return _this;
  55579. }
  55580. var lastDot = rootUrl.lastIndexOf(".");
  55581. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  55582. var isDDS = (extension === ".dds");
  55583. var isEnv = (extension === ".env");
  55584. if (isEnv) {
  55585. _this.gammaSpace = false;
  55586. _this._prefiltered = false;
  55587. }
  55588. else {
  55589. _this._prefiltered = prefiltered;
  55590. if (prefiltered) {
  55591. _this.gammaSpace = false;
  55592. }
  55593. }
  55594. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  55595. if (!files) {
  55596. if (!isEnv && !isDDS && !extensions) {
  55597. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  55598. }
  55599. files = [];
  55600. if (extensions) {
  55601. for (var index = 0; index < extensions.length; index++) {
  55602. files.push(rootUrl + extensions[index]);
  55603. }
  55604. }
  55605. }
  55606. _this._files = files;
  55607. if (!_this._texture) {
  55608. if (!scene.useDelayedTextureLoading) {
  55609. if (prefiltered) {
  55610. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  55611. }
  55612. else {
  55613. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  55614. }
  55615. }
  55616. else {
  55617. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55618. }
  55619. }
  55620. else if (onLoad) {
  55621. if (_this._texture.isReady) {
  55622. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  55623. }
  55624. else {
  55625. _this._texture.onLoadedObservable.add(onLoad);
  55626. }
  55627. }
  55628. return _this;
  55629. }
  55630. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  55631. /**
  55632. * Returns the bounding box size
  55633. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55634. */
  55635. get: function () {
  55636. return this._boundingBoxSize;
  55637. },
  55638. /**
  55639. * Gets or sets the size of the bounding box associated with the cube texture
  55640. * When defined, the cubemap will switch to local mode
  55641. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55642. * @example https://www.babylonjs-playground.com/#RNASML
  55643. */
  55644. set: function (value) {
  55645. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55646. return;
  55647. }
  55648. this._boundingBoxSize = value;
  55649. var scene = this.getScene();
  55650. if (scene) {
  55651. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55652. }
  55653. },
  55654. enumerable: true,
  55655. configurable: true
  55656. });
  55657. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  55658. /**
  55659. * Gets texture matrix rotation angle around Y axis radians.
  55660. */
  55661. get: function () {
  55662. return this._rotationY;
  55663. },
  55664. /**
  55665. * Sets texture matrix rotation angle around Y axis in radians.
  55666. */
  55667. set: function (value) {
  55668. this._rotationY = value;
  55669. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  55670. },
  55671. enumerable: true,
  55672. configurable: true
  55673. });
  55674. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  55675. /**
  55676. * Are mip maps generated for this texture or not.
  55677. */
  55678. get: function () {
  55679. return this._noMipmap;
  55680. },
  55681. enumerable: true,
  55682. configurable: true
  55683. });
  55684. /**
  55685. * Creates a cube texture from an array of image urls
  55686. * @param files defines an array of image urls
  55687. * @param scene defines the hosting scene
  55688. * @param noMipmap specifies if mip maps are not used
  55689. * @returns a cube texture
  55690. */
  55691. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  55692. var rootUrlKey = "";
  55693. files.forEach(function (url) { return rootUrlKey += url; });
  55694. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  55695. };
  55696. /**
  55697. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  55698. * @param url defines the url of the prefiltered texture
  55699. * @param scene defines the scene the texture is attached to
  55700. * @param forcedExtension defines the extension of the file if different from the url
  55701. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55702. * @return the prefiltered texture
  55703. */
  55704. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  55705. if (forcedExtension === void 0) { forcedExtension = null; }
  55706. if (createPolynomials === void 0) { createPolynomials = true; }
  55707. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  55708. };
  55709. /**
  55710. * Get the current class name of the texture useful for serialization or dynamic coding.
  55711. * @returns "CubeTexture"
  55712. */
  55713. CubeTexture.prototype.getClassName = function () {
  55714. return "CubeTexture";
  55715. };
  55716. /**
  55717. * Update the url (and optional buffer) of this texture if url was null during construction.
  55718. * @param url the url of the texture
  55719. * @param forcedExtension defines the extension to use
  55720. * @param onLoad callback called when the texture is loaded (defaults to null)
  55721. */
  55722. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  55723. if (this.url) {
  55724. this.releaseInternalTexture();
  55725. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55726. }
  55727. this.url = url;
  55728. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55729. this._prefiltered = false;
  55730. if (onLoad) {
  55731. this._delayedOnLoad = onLoad;
  55732. }
  55733. this.delayLoad(forcedExtension);
  55734. };
  55735. /**
  55736. * Delays loading of the cube texture
  55737. * @param forcedExtension defines the extension to use
  55738. */
  55739. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  55740. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55741. return;
  55742. }
  55743. var scene = this.getScene();
  55744. if (!scene) {
  55745. return;
  55746. }
  55747. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  55748. this._texture = this._getFromCache(this.url, this._noMipmap);
  55749. if (!this._texture) {
  55750. if (this._prefiltered) {
  55751. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  55752. }
  55753. else {
  55754. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  55755. }
  55756. }
  55757. };
  55758. /**
  55759. * Returns the reflection texture matrix
  55760. * @returns the reflection texture matrix
  55761. */
  55762. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  55763. return this._textureMatrix;
  55764. };
  55765. /**
  55766. * Sets the reflection texture matrix
  55767. * @param value Reflection texture matrix
  55768. */
  55769. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55770. var _this = this;
  55771. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55772. return;
  55773. }
  55774. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55775. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55776. }
  55777. this._textureMatrix = value;
  55778. };
  55779. /**
  55780. * Parses text to create a cube texture
  55781. * @param parsedTexture define the serialized text to read from
  55782. * @param scene defines the hosting scene
  55783. * @param rootUrl defines the root url of the cube texture
  55784. * @returns a cube texture
  55785. */
  55786. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55787. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  55788. var prefiltered = false;
  55789. if (parsedTexture.prefiltered) {
  55790. prefiltered = parsedTexture.prefiltered;
  55791. }
  55792. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  55793. }, parsedTexture, scene);
  55794. // Local Cubemaps
  55795. if (parsedTexture.boundingBoxPosition) {
  55796. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55797. }
  55798. if (parsedTexture.boundingBoxSize) {
  55799. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55800. }
  55801. // Animations
  55802. if (parsedTexture.animations) {
  55803. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  55804. var parsedAnimation = parsedTexture.animations[animationIndex];
  55805. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  55806. if (internalClass) {
  55807. texture.animations.push(internalClass.Parse(parsedAnimation));
  55808. }
  55809. }
  55810. }
  55811. return texture;
  55812. };
  55813. /**
  55814. * Makes a clone, or deep copy, of the cube texture
  55815. * @returns a new cube texture
  55816. */
  55817. CubeTexture.prototype.clone = function () {
  55818. var _this = this;
  55819. var scene = this.getScene();
  55820. var uniqueId = 0;
  55821. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  55822. if (!scene) {
  55823. return _this;
  55824. }
  55825. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  55826. uniqueId = cubeTexture.uniqueId;
  55827. return cubeTexture;
  55828. }, this);
  55829. newCubeTexture.uniqueId = uniqueId;
  55830. return newCubeTexture;
  55831. };
  55832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  55834. ], CubeTexture.prototype, "rotationY", null);
  55835. return CubeTexture;
  55836. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  55837. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  55838. /***/ }),
  55839. /***/ "./Materials/Textures/dynamicTexture.ts":
  55840. /*!**********************************************!*\
  55841. !*** ./Materials/Textures/dynamicTexture.ts ***!
  55842. \**********************************************/
  55843. /*! exports provided: DynamicTexture */
  55844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55845. "use strict";
  55846. __webpack_require__.r(__webpack_exports__);
  55847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  55848. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55849. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  55850. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55851. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55852. /**
  55853. * A class extending Texture allowing drawing on a texture
  55854. * @see http://doc.babylonjs.com/how_to/dynamictexture
  55855. */
  55856. var DynamicTexture = /** @class */ (function (_super) {
  55857. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  55858. /**
  55859. * Creates a DynamicTexture
  55860. * @param name defines the name of the texture
  55861. * @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
  55862. * @param scene defines the scene where you want the texture
  55863. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55864. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55865. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55866. */
  55867. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  55868. if (scene === void 0) { scene = null; }
  55869. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  55870. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  55871. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  55872. _this.name = name;
  55873. _this._engine = _this.getScene().getEngine();
  55874. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55875. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55876. _this._generateMipMaps = generateMipMaps;
  55877. if (options.getContext) {
  55878. _this._canvas = options;
  55879. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55880. }
  55881. else {
  55882. _this._canvas = document.createElement("canvas");
  55883. if (options.width || options.width === 0) {
  55884. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55885. }
  55886. else {
  55887. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  55888. }
  55889. }
  55890. var textureSize = _this.getSize();
  55891. _this._canvas.width = textureSize.width;
  55892. _this._canvas.height = textureSize.height;
  55893. _this._context = _this._canvas.getContext("2d");
  55894. return _this;
  55895. }
  55896. /**
  55897. * Get the current class name of the texture useful for serialization or dynamic coding.
  55898. * @returns "DynamicTexture"
  55899. */
  55900. DynamicTexture.prototype.getClassName = function () {
  55901. return "DynamicTexture";
  55902. };
  55903. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  55904. /**
  55905. * Gets the current state of canRescale
  55906. */
  55907. get: function () {
  55908. return true;
  55909. },
  55910. enumerable: true,
  55911. configurable: true
  55912. });
  55913. DynamicTexture.prototype._recreate = function (textureSize) {
  55914. this._canvas.width = textureSize.width;
  55915. this._canvas.height = textureSize.height;
  55916. this.releaseInternalTexture();
  55917. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  55918. };
  55919. /**
  55920. * Scales the texture
  55921. * @param ratio the scale factor to apply to both width and height
  55922. */
  55923. DynamicTexture.prototype.scale = function (ratio) {
  55924. var textureSize = this.getSize();
  55925. textureSize.width *= ratio;
  55926. textureSize.height *= ratio;
  55927. this._recreate(textureSize);
  55928. };
  55929. /**
  55930. * Resizes the texture
  55931. * @param width the new width
  55932. * @param height the new height
  55933. */
  55934. DynamicTexture.prototype.scaleTo = function (width, height) {
  55935. var textureSize = this.getSize();
  55936. textureSize.width = width;
  55937. textureSize.height = height;
  55938. this._recreate(textureSize);
  55939. };
  55940. /**
  55941. * Gets the context of the canvas used by the texture
  55942. * @returns the canvas context of the dynamic texture
  55943. */
  55944. DynamicTexture.prototype.getContext = function () {
  55945. return this._context;
  55946. };
  55947. /**
  55948. * Clears the texture
  55949. */
  55950. DynamicTexture.prototype.clear = function () {
  55951. var size = this.getSize();
  55952. this._context.fillRect(0, 0, size.width, size.height);
  55953. };
  55954. /**
  55955. * Updates the texture
  55956. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55957. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55958. */
  55959. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  55960. if (premulAlpha === void 0) { premulAlpha = false; }
  55961. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  55962. };
  55963. /**
  55964. * Draws text onto the texture
  55965. * @param text defines the text to be drawn
  55966. * @param x defines the placement of the text from the left
  55967. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55968. * @param font defines the font to be used with font-style, font-size, font-name
  55969. * @param color defines the color used for the text
  55970. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55971. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55972. * @param update defines whether texture is immediately update (default is true)
  55973. */
  55974. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  55975. if (update === void 0) { update = true; }
  55976. var size = this.getSize();
  55977. if (clearColor) {
  55978. this._context.fillStyle = clearColor;
  55979. this._context.fillRect(0, 0, size.width, size.height);
  55980. }
  55981. this._context.font = font;
  55982. if (x === null || x === undefined) {
  55983. var textSize = this._context.measureText(text);
  55984. x = (size.width - textSize.width) / 2;
  55985. }
  55986. if (y === null || y === undefined) {
  55987. var fontSize = parseInt((font.replace(/\D/g, '')));
  55988. y = (size.height / 2) + (fontSize / 3.65);
  55989. }
  55990. this._context.fillStyle = color;
  55991. this._context.fillText(text, x, y);
  55992. if (update) {
  55993. this.update(invertY);
  55994. }
  55995. };
  55996. /**
  55997. * Clones the texture
  55998. * @returns the clone of the texture.
  55999. */
  56000. DynamicTexture.prototype.clone = function () {
  56001. var scene = this.getScene();
  56002. if (!scene) {
  56003. return this;
  56004. }
  56005. var textureSize = this.getSize();
  56006. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  56007. // Base texture
  56008. newTexture.hasAlpha = this.hasAlpha;
  56009. newTexture.level = this.level;
  56010. // Dynamic Texture
  56011. newTexture.wrapU = this.wrapU;
  56012. newTexture.wrapV = this.wrapV;
  56013. return newTexture;
  56014. };
  56015. /**
  56016. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  56017. * @returns a serialized dynamic texture object
  56018. */
  56019. DynamicTexture.prototype.serialize = function () {
  56020. var scene = this.getScene();
  56021. if (scene && !scene.isReady()) {
  56022. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  56023. }
  56024. var serializationObject = _super.prototype.serialize.call(this);
  56025. serializationObject.base64String = this._canvas.toDataURL();
  56026. serializationObject.invertY = this._invertY;
  56027. serializationObject.samplingMode = this.samplingMode;
  56028. return serializationObject;
  56029. };
  56030. /** @hidden */
  56031. DynamicTexture.prototype._rebuild = function () {
  56032. this.update();
  56033. };
  56034. return DynamicTexture;
  56035. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  56036. /***/ }),
  56037. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  56038. /*!**********************************************!*\
  56039. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  56040. \**********************************************/
  56041. /*! exports provided: HDRCubeTexture */
  56042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56043. "use strict";
  56044. __webpack_require__.r(__webpack_exports__);
  56045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  56046. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56047. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56048. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  56049. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  56050. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56051. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56052. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  56053. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  56054. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56055. /**
  56056. * This represents a texture coming from an HDR input.
  56057. *
  56058. * The only supported format is currently panorama picture stored in RGBE format.
  56059. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56060. */
  56061. var HDRCubeTexture = /** @class */ (function (_super) {
  56062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  56063. /**
  56064. * Instantiates an HDRTexture from the following parameters.
  56065. *
  56066. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56067. * @param scene The scene the texture will be used in
  56068. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56069. * @param noMipmap Forces to not generate the mipmap if true
  56070. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56071. * @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)
  56072. * @param reserved Reserved flag for internal use.
  56073. */
  56074. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  56075. if (noMipmap === void 0) { noMipmap = false; }
  56076. if (generateHarmonics === void 0) { generateHarmonics = true; }
  56077. if (gammaSpace === void 0) { gammaSpace = false; }
  56078. if (reserved === void 0) { reserved = false; }
  56079. if (onLoad === void 0) { onLoad = null; }
  56080. if (onError === void 0) { onError = null; }
  56081. var _this = _super.call(this, scene) || this;
  56082. _this._generateHarmonics = true;
  56083. _this._onLoad = null;
  56084. _this._onError = null;
  56085. /**
  56086. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56087. */
  56088. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  56089. _this._isBlocking = true;
  56090. _this._rotationY = 0;
  56091. /**
  56092. * Gets or sets the center of the bounding box associated with the cube texture
  56093. * It must define where the camera used to render the texture was set
  56094. */
  56095. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  56096. if (!url) {
  56097. return _this;
  56098. }
  56099. _this.name = url;
  56100. _this.url = url;
  56101. _this.hasAlpha = false;
  56102. _this.isCube = true;
  56103. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  56104. _this._onLoad = onLoad;
  56105. _this._onError = onError;
  56106. _this.gammaSpace = gammaSpace;
  56107. _this._noMipmap = noMipmap;
  56108. _this._size = size;
  56109. _this._texture = _this._getFromCache(url, _this._noMipmap);
  56110. if (!_this._texture) {
  56111. if (!scene.useDelayedTextureLoading) {
  56112. _this.loadTexture();
  56113. }
  56114. else {
  56115. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  56116. }
  56117. }
  56118. return _this;
  56119. }
  56120. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  56121. /**
  56122. * Gets wether or not the texture is blocking during loading.
  56123. */
  56124. get: function () {
  56125. return this._isBlocking;
  56126. },
  56127. /**
  56128. * Sets wether or not the texture is blocking during loading.
  56129. */
  56130. set: function (value) {
  56131. this._isBlocking = value;
  56132. },
  56133. enumerable: true,
  56134. configurable: true
  56135. });
  56136. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  56137. /**
  56138. * Gets texture matrix rotation angle around Y axis radians.
  56139. */
  56140. get: function () {
  56141. return this._rotationY;
  56142. },
  56143. /**
  56144. * Sets texture matrix rotation angle around Y axis in radians.
  56145. */
  56146. set: function (value) {
  56147. this._rotationY = value;
  56148. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  56149. },
  56150. enumerable: true,
  56151. configurable: true
  56152. });
  56153. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  56154. get: function () {
  56155. return this._boundingBoxSize;
  56156. },
  56157. /**
  56158. * Gets or sets the size of the bounding box associated with the cube texture
  56159. * When defined, the cubemap will switch to local mode
  56160. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56161. * @example https://www.babylonjs-playground.com/#RNASML
  56162. */
  56163. set: function (value) {
  56164. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  56165. return;
  56166. }
  56167. this._boundingBoxSize = value;
  56168. var scene = this.getScene();
  56169. if (scene) {
  56170. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  56171. }
  56172. },
  56173. enumerable: true,
  56174. configurable: true
  56175. });
  56176. /**
  56177. * Get the current class name of the texture useful for serialization or dynamic coding.
  56178. * @returns "HDRCubeTexture"
  56179. */
  56180. HDRCubeTexture.prototype.getClassName = function () {
  56181. return "HDRCubeTexture";
  56182. };
  56183. /**
  56184. * Occurs when the file is raw .hdr file.
  56185. */
  56186. HDRCubeTexture.prototype.loadTexture = function () {
  56187. var _this = this;
  56188. var callback = function (buffer) {
  56189. _this.lodGenerationOffset = 0.0;
  56190. _this.lodGenerationScale = 0.8;
  56191. var scene = _this.getScene();
  56192. if (!scene) {
  56193. return null;
  56194. }
  56195. // Extract the raw linear data.
  56196. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  56197. // Generate harmonics if needed.
  56198. if (_this._generateHarmonics) {
  56199. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  56200. _this.sphericalPolynomial = sphericalPolynomial;
  56201. }
  56202. var results = [];
  56203. var byteArray = null;
  56204. // Push each faces.
  56205. for (var j = 0; j < 6; j++) {
  56206. // Create uintarray fallback.
  56207. if (!scene.getEngine().getCaps().textureFloat) {
  56208. // 3 channels of 1 bytes per pixel in bytes.
  56209. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  56210. byteArray = new Uint8Array(byteBuffer);
  56211. }
  56212. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  56213. // If special cases.
  56214. if (_this.gammaSpace || byteArray) {
  56215. for (var i = 0; i < _this._size * _this._size; i++) {
  56216. // Put in gamma space if requested.
  56217. if (_this.gammaSpace) {
  56218. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56219. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56220. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56221. }
  56222. // Convert to int texture for fallback.
  56223. if (byteArray) {
  56224. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  56225. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  56226. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  56227. // May use luminance instead if the result is not accurate.
  56228. var max = Math.max(Math.max(r, g), b);
  56229. if (max > 255) {
  56230. var scale = 255 / max;
  56231. r *= scale;
  56232. g *= scale;
  56233. b *= scale;
  56234. }
  56235. byteArray[(i * 3) + 0] = r;
  56236. byteArray[(i * 3) + 1] = g;
  56237. byteArray[(i * 3) + 2] = b;
  56238. }
  56239. }
  56240. }
  56241. if (byteArray) {
  56242. results.push(byteArray);
  56243. }
  56244. else {
  56245. results.push(dataFace);
  56246. }
  56247. }
  56248. return results;
  56249. };
  56250. var scene = this.getScene();
  56251. if (scene) {
  56252. 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);
  56253. }
  56254. };
  56255. HDRCubeTexture.prototype.clone = function () {
  56256. var scene = this.getScene();
  56257. if (!scene) {
  56258. return this;
  56259. }
  56260. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  56261. // Base texture
  56262. newTexture.level = this.level;
  56263. newTexture.wrapU = this.wrapU;
  56264. newTexture.wrapV = this.wrapV;
  56265. newTexture.coordinatesIndex = this.coordinatesIndex;
  56266. newTexture.coordinatesMode = this.coordinatesMode;
  56267. return newTexture;
  56268. };
  56269. // Methods
  56270. HDRCubeTexture.prototype.delayLoad = function () {
  56271. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  56272. return;
  56273. }
  56274. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  56275. this._texture = this._getFromCache(this.url, this._noMipmap);
  56276. if (!this._texture) {
  56277. this.loadTexture();
  56278. }
  56279. };
  56280. /**
  56281. * Get the texture reflection matrix used to rotate/transform the reflection.
  56282. * @returns the reflection matrix
  56283. */
  56284. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  56285. return this._textureMatrix;
  56286. };
  56287. /**
  56288. * Set the texture reflection matrix used to rotate/transform the reflection.
  56289. * @param value Define the reflection matrix to set
  56290. */
  56291. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  56292. var _this = this;
  56293. this._textureMatrix = value;
  56294. if (value.updateFlag === this._textureMatrix.updateFlag) {
  56295. return;
  56296. }
  56297. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  56298. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  56299. }
  56300. };
  56301. /**
  56302. * Parses a JSON representation of an HDR Texture in order to create the texture
  56303. * @param parsedTexture Define the JSON representation
  56304. * @param scene Define the scene the texture should be created in
  56305. * @param rootUrl Define the root url in case we need to load relative dependencies
  56306. * @returns the newly created texture after parsing
  56307. */
  56308. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  56309. var texture = null;
  56310. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  56311. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  56312. texture.name = parsedTexture.name;
  56313. texture.hasAlpha = parsedTexture.hasAlpha;
  56314. texture.level = parsedTexture.level;
  56315. texture.coordinatesMode = parsedTexture.coordinatesMode;
  56316. texture.isBlocking = parsedTexture.isBlocking;
  56317. }
  56318. if (texture) {
  56319. if (parsedTexture.boundingBoxPosition) {
  56320. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  56321. }
  56322. if (parsedTexture.boundingBoxSize) {
  56323. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  56324. }
  56325. if (parsedTexture.rotationY) {
  56326. texture.rotationY = parsedTexture.rotationY;
  56327. }
  56328. }
  56329. return texture;
  56330. };
  56331. HDRCubeTexture.prototype.serialize = function () {
  56332. if (!this.name) {
  56333. return null;
  56334. }
  56335. var serializationObject = {};
  56336. serializationObject.name = this.name;
  56337. serializationObject.hasAlpha = this.hasAlpha;
  56338. serializationObject.isCube = true;
  56339. serializationObject.level = this.level;
  56340. serializationObject.size = this._size;
  56341. serializationObject.coordinatesMode = this.coordinatesMode;
  56342. serializationObject.useInGammaSpace = this.gammaSpace;
  56343. serializationObject.generateHarmonics = this._generateHarmonics;
  56344. serializationObject.customType = "BABYLON.HDRCubeTexture";
  56345. serializationObject.noMipmap = this._noMipmap;
  56346. serializationObject.isBlocking = this._isBlocking;
  56347. serializationObject.rotationY = this._rotationY;
  56348. return serializationObject;
  56349. };
  56350. HDRCubeTexture._facesMapping = [
  56351. "right",
  56352. "left",
  56353. "up",
  56354. "down",
  56355. "front",
  56356. "back"
  56357. ];
  56358. return HDRCubeTexture;
  56359. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  56360. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  56361. /***/ }),
  56362. /***/ "./Materials/Textures/index.ts":
  56363. /*!*************************************!*\
  56364. !*** ./Materials/Textures/index.ts ***!
  56365. \*************************************/
  56366. /*! exports provided: BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  56367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56368. "use strict";
  56369. __webpack_require__.r(__webpack_exports__);
  56370. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  56371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  56372. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  56373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  56374. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  56376. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  56377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  56378. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  56379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  56380. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  56381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  56382. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  56383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  56384. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  56385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  56386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  56387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  56388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  56389. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  56390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  56391. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  56392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  56393. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  56394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  56395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  56396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  56397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  56398. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  56399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  56400. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  56401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  56402. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  56403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  56404. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  56405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  56406. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  56408. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  56409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  56410. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  56411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  56412. /***/ }),
  56413. /***/ "./Materials/Textures/internalTexture.ts":
  56414. /*!***********************************************!*\
  56415. !*** ./Materials/Textures/internalTexture.ts ***!
  56416. \***********************************************/
  56417. /*! exports provided: InternalTexture */
  56418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56419. "use strict";
  56420. __webpack_require__.r(__webpack_exports__);
  56421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  56422. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56423. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  56424. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56425. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  56426. /**
  56427. * Class used to store data associated with WebGL texture data for the engine
  56428. * This class should not be used directly
  56429. */
  56430. var InternalTexture = /** @class */ (function () {
  56431. /**
  56432. * Creates a new InternalTexture
  56433. * @param engine defines the engine to use
  56434. * @param dataSource defines the type of data that will be used
  56435. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56436. */
  56437. function InternalTexture(engine, dataSource, delayAllocation) {
  56438. if (delayAllocation === void 0) { delayAllocation = false; }
  56439. /**
  56440. * Observable called when the texture is loaded
  56441. */
  56442. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  56443. /**
  56444. * Gets or set the previous tracker in the list
  56445. */
  56446. this.previous = null;
  56447. /**
  56448. * Gets or set the next tracker in the list
  56449. */
  56450. this.next = null;
  56451. // Private
  56452. /** @hidden */
  56453. this._invertVScale = false;
  56454. /** @hidden */
  56455. this._initialSlot = -1;
  56456. /** @hidden */
  56457. this._designatedSlot = -1;
  56458. /** @hidden */
  56459. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  56460. /** @hidden */
  56461. this._comparisonFunction = 0;
  56462. /** @hidden */
  56463. this._sphericalPolynomial = null;
  56464. /** @hidden */
  56465. this._lodGenerationScale = 0;
  56466. /** @hidden */
  56467. this._lodGenerationOffset = 0;
  56468. /** @hidden */
  56469. this._isRGBD = false;
  56470. /** @hidden */
  56471. this._references = 1;
  56472. this._engine = engine;
  56473. this._dataSource = dataSource;
  56474. if (!delayAllocation) {
  56475. this._webGLTexture = engine._createTexture();
  56476. }
  56477. }
  56478. /**
  56479. * Gets the Engine the texture belongs to.
  56480. * @returns The babylon engine
  56481. */
  56482. InternalTexture.prototype.getEngine = function () {
  56483. return this._engine;
  56484. };
  56485. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  56486. /**
  56487. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  56488. */
  56489. get: function () {
  56490. return this._dataSource;
  56491. },
  56492. enumerable: true,
  56493. configurable: true
  56494. });
  56495. /**
  56496. * Increments the number of references (ie. the number of Texture that point to it)
  56497. */
  56498. InternalTexture.prototype.incrementReferences = function () {
  56499. this._references++;
  56500. };
  56501. /**
  56502. * Change the size of the texture (not the size of the content)
  56503. * @param width defines the new width
  56504. * @param height defines the new height
  56505. * @param depth defines the new depth (1 by default)
  56506. */
  56507. InternalTexture.prototype.updateSize = function (width, height, depth) {
  56508. if (depth === void 0) { depth = 1; }
  56509. this.width = width;
  56510. this.height = height;
  56511. this.depth = depth;
  56512. this.baseWidth = width;
  56513. this.baseHeight = height;
  56514. this.baseDepth = depth;
  56515. this._size = width * height * depth;
  56516. };
  56517. /** @hidden */
  56518. InternalTexture.prototype._rebuild = function () {
  56519. var _this = this;
  56520. var proxy;
  56521. this.isReady = false;
  56522. this._cachedCoordinatesMode = null;
  56523. this._cachedWrapU = null;
  56524. this._cachedWrapV = null;
  56525. this._cachedAnisotropicFilteringLevel = null;
  56526. switch (this._dataSource) {
  56527. case InternalTexture.DATASOURCE_TEMP:
  56528. return;
  56529. case InternalTexture.DATASOURCE_URL:
  56530. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  56531. proxy._swapAndDie(_this);
  56532. _this.isReady = true;
  56533. }, null, this._buffer, undefined, this.format);
  56534. return;
  56535. case InternalTexture.DATASOURCE_RAW:
  56536. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56537. proxy._swapAndDie(this);
  56538. this.isReady = true;
  56539. return;
  56540. case InternalTexture.DATASOURCE_RAW3D:
  56541. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56542. proxy._swapAndDie(this);
  56543. this.isReady = true;
  56544. return;
  56545. case InternalTexture.DATASOURCE_DYNAMIC:
  56546. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  56547. proxy._swapAndDie(this);
  56548. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  56549. // The engine will make sure to update content so no need to flag it as isReady = true
  56550. return;
  56551. case InternalTexture.DATASOURCE_RENDERTARGET:
  56552. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  56553. options.generateDepthBuffer = this._generateDepthBuffer;
  56554. options.generateMipMaps = this.generateMipMaps;
  56555. options.generateStencilBuffer = this._generateStencilBuffer;
  56556. options.samplingMode = this.samplingMode;
  56557. options.type = this.type;
  56558. if (this.isCube) {
  56559. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  56560. }
  56561. else {
  56562. var size = {
  56563. width: this.width,
  56564. height: this.height
  56565. };
  56566. proxy = this._engine.createRenderTargetTexture(size, options);
  56567. }
  56568. proxy._swapAndDie(this);
  56569. this.isReady = true;
  56570. return;
  56571. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  56572. var depthTextureOptions = {
  56573. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  56574. comparisonFunction: this._comparisonFunction,
  56575. generateStencil: this._generateStencilBuffer,
  56576. isCube: this.isCube
  56577. };
  56578. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  56579. proxy._swapAndDie(this);
  56580. this.isReady = true;
  56581. return;
  56582. case InternalTexture.DATASOURCE_CUBE:
  56583. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  56584. proxy._swapAndDie(_this);
  56585. _this.isReady = true;
  56586. }, null, this.format, this._extension);
  56587. return;
  56588. case InternalTexture.DATASOURCE_CUBERAW:
  56589. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56590. proxy._swapAndDie(this);
  56591. this.isReady = true;
  56592. return;
  56593. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  56594. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56595. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  56596. proxy._swapAndDie(_this);
  56597. _this.isReady = true;
  56598. });
  56599. return;
  56600. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  56601. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  56602. if (proxy) {
  56603. proxy._swapAndDie(_this);
  56604. }
  56605. _this.isReady = true;
  56606. }, null, this.format, this._extension);
  56607. proxy._sphericalPolynomial = this._sphericalPolynomial;
  56608. return;
  56609. }
  56610. };
  56611. /** @hidden */
  56612. InternalTexture.prototype._swapAndDie = function (target) {
  56613. target._webGLTexture = this._webGLTexture;
  56614. if (this._framebuffer) {
  56615. target._framebuffer = this._framebuffer;
  56616. }
  56617. if (this._depthStencilBuffer) {
  56618. target._depthStencilBuffer = this._depthStencilBuffer;
  56619. }
  56620. if (this._lodTextureHigh) {
  56621. if (target._lodTextureHigh) {
  56622. target._lodTextureHigh.dispose();
  56623. }
  56624. target._lodTextureHigh = this._lodTextureHigh;
  56625. }
  56626. if (this._lodTextureMid) {
  56627. if (target._lodTextureMid) {
  56628. target._lodTextureMid.dispose();
  56629. }
  56630. target._lodTextureMid = this._lodTextureMid;
  56631. }
  56632. if (this._lodTextureLow) {
  56633. if (target._lodTextureLow) {
  56634. target._lodTextureLow.dispose();
  56635. }
  56636. target._lodTextureLow = this._lodTextureLow;
  56637. }
  56638. var cache = this._engine.getLoadedTexturesCache();
  56639. var index = cache.indexOf(this);
  56640. if (index !== -1) {
  56641. cache.splice(index, 1);
  56642. }
  56643. };
  56644. /**
  56645. * Dispose the current allocated resources
  56646. */
  56647. InternalTexture.prototype.dispose = function () {
  56648. if (!this._webGLTexture) {
  56649. return;
  56650. }
  56651. this._references--;
  56652. if (this._references === 0) {
  56653. this._engine._releaseTexture(this);
  56654. this._webGLTexture = null;
  56655. this.previous = null;
  56656. this.next = null;
  56657. }
  56658. };
  56659. /** hidden */
  56660. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  56661. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  56662. };
  56663. /**
  56664. * The source of the texture data is unknown
  56665. */
  56666. InternalTexture.DATASOURCE_UNKNOWN = 0;
  56667. /**
  56668. * Texture data comes from an URL
  56669. */
  56670. InternalTexture.DATASOURCE_URL = 1;
  56671. /**
  56672. * Texture data is only used for temporary storage
  56673. */
  56674. InternalTexture.DATASOURCE_TEMP = 2;
  56675. /**
  56676. * Texture data comes from raw data (ArrayBuffer)
  56677. */
  56678. InternalTexture.DATASOURCE_RAW = 3;
  56679. /**
  56680. * Texture content is dynamic (video or dynamic texture)
  56681. */
  56682. InternalTexture.DATASOURCE_DYNAMIC = 4;
  56683. /**
  56684. * Texture content is generated by rendering to it
  56685. */
  56686. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  56687. /**
  56688. * Texture content is part of a multi render target process
  56689. */
  56690. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  56691. /**
  56692. * Texture data comes from a cube data file
  56693. */
  56694. InternalTexture.DATASOURCE_CUBE = 7;
  56695. /**
  56696. * Texture data comes from a raw cube data
  56697. */
  56698. InternalTexture.DATASOURCE_CUBERAW = 8;
  56699. /**
  56700. * Texture data come from a prefiltered cube data file
  56701. */
  56702. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  56703. /**
  56704. * Texture content is raw 3D data
  56705. */
  56706. InternalTexture.DATASOURCE_RAW3D = 10;
  56707. /**
  56708. * Texture content is a depth texture
  56709. */
  56710. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  56711. /**
  56712. * Texture data comes from a raw cube data encoded with RGBD
  56713. */
  56714. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  56715. return InternalTexture;
  56716. }());
  56717. /***/ }),
  56718. /***/ "./Materials/Textures/internalTextureTracker.ts":
  56719. /*!******************************************************!*\
  56720. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  56721. \******************************************************/
  56722. /*! exports provided: DummyInternalTextureTracker */
  56723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56724. "use strict";
  56725. __webpack_require__.r(__webpack_exports__);
  56726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  56727. /**
  56728. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  56729. */
  56730. var DummyInternalTextureTracker = /** @class */ (function () {
  56731. function DummyInternalTextureTracker() {
  56732. /**
  56733. * Gets or set the previous tracker in the list
  56734. */
  56735. this.previous = null;
  56736. /**
  56737. * Gets or set the next tracker in the list
  56738. */
  56739. this.next = null;
  56740. }
  56741. return DummyInternalTextureTracker;
  56742. }());
  56743. /***/ }),
  56744. /***/ "./Materials/Textures/mirrorTexture.ts":
  56745. /*!*********************************************!*\
  56746. !*** ./Materials/Textures/mirrorTexture.ts ***!
  56747. \*********************************************/
  56748. /*! exports provided: MirrorTexture */
  56749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56750. "use strict";
  56751. __webpack_require__.r(__webpack_exports__);
  56752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  56753. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56754. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56755. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56756. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56757. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  56758. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56759. /**
  56760. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56761. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56762. * You can then easily use it as a reflectionTexture on a flat surface.
  56763. * In case the surface is not a plane, please consider relying on reflection probes.
  56764. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56765. */
  56766. var MirrorTexture = /** @class */ (function (_super) {
  56767. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  56768. /**
  56769. * Instantiates a Mirror Texture.
  56770. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56771. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56772. * You can then easily use it as a reflectionTexture on a flat surface.
  56773. * In case the surface is not a plane, please consider relying on reflection probes.
  56774. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56775. * @param name
  56776. * @param size
  56777. * @param scene
  56778. * @param generateMipMaps
  56779. * @param type
  56780. * @param samplingMode
  56781. * @param generateDepthBuffer
  56782. */
  56783. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  56784. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56785. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  56786. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56787. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  56788. _this.scene = scene;
  56789. /**
  56790. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  56791. * 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.
  56792. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56793. */
  56794. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56795. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56796. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56797. _this._adaptiveBlurKernel = 0;
  56798. _this._blurKernelX = 0;
  56799. _this._blurKernelY = 0;
  56800. _this._blurRatio = 1.0;
  56801. _this.ignoreCameraViewport = true;
  56802. _this._updateGammaSpace();
  56803. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  56804. _this._updateGammaSpace;
  56805. });
  56806. _this.onBeforeRenderObservable.add(function () {
  56807. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  56808. _this._savedViewMatrix = scene.getViewMatrix();
  56809. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  56810. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  56811. scene.clipPlane = _this.mirrorPlane;
  56812. scene.getEngine().cullBackFaces = false;
  56813. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  56814. });
  56815. _this.onAfterRenderObservable.add(function () {
  56816. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  56817. scene.getEngine().cullBackFaces = true;
  56818. scene._mirroredCameraPosition = null;
  56819. delete scene.clipPlane;
  56820. });
  56821. return _this;
  56822. }
  56823. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  56824. get: function () {
  56825. return this._blurRatio;
  56826. },
  56827. /**
  56828. * Define the blur ratio used to blur the reflection if needed.
  56829. */
  56830. set: function (value) {
  56831. if (this._blurRatio === value) {
  56832. return;
  56833. }
  56834. this._blurRatio = value;
  56835. this._preparePostProcesses();
  56836. },
  56837. enumerable: true,
  56838. configurable: true
  56839. });
  56840. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  56841. /**
  56842. * Define the adaptive blur kernel used to blur the reflection if needed.
  56843. * This will autocompute the closest best match for the `blurKernel`
  56844. */
  56845. set: function (value) {
  56846. this._adaptiveBlurKernel = value;
  56847. this._autoComputeBlurKernel();
  56848. },
  56849. enumerable: true,
  56850. configurable: true
  56851. });
  56852. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  56853. /**
  56854. * Define the blur kernel used to blur the reflection if needed.
  56855. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56856. */
  56857. set: function (value) {
  56858. this.blurKernelX = value;
  56859. this.blurKernelY = value;
  56860. },
  56861. enumerable: true,
  56862. configurable: true
  56863. });
  56864. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  56865. get: function () {
  56866. return this._blurKernelX;
  56867. },
  56868. /**
  56869. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  56870. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56871. */
  56872. set: function (value) {
  56873. if (this._blurKernelX === value) {
  56874. return;
  56875. }
  56876. this._blurKernelX = value;
  56877. this._preparePostProcesses();
  56878. },
  56879. enumerable: true,
  56880. configurable: true
  56881. });
  56882. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  56883. get: function () {
  56884. return this._blurKernelY;
  56885. },
  56886. /**
  56887. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  56888. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56889. */
  56890. set: function (value) {
  56891. if (this._blurKernelY === value) {
  56892. return;
  56893. }
  56894. this._blurKernelY = value;
  56895. this._preparePostProcesses();
  56896. },
  56897. enumerable: true,
  56898. configurable: true
  56899. });
  56900. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  56901. var engine = this.getScene().getEngine();
  56902. var dw = this.getRenderWidth() / engine.getRenderWidth();
  56903. var dh = this.getRenderHeight() / engine.getRenderHeight();
  56904. this.blurKernelX = this._adaptiveBlurKernel * dw;
  56905. this.blurKernelY = this._adaptiveBlurKernel * dh;
  56906. };
  56907. MirrorTexture.prototype._onRatioRescale = function () {
  56908. if (this._sizeRatio) {
  56909. this.resize(this._initialSizeParameter);
  56910. if (!this._adaptiveBlurKernel) {
  56911. this._preparePostProcesses();
  56912. }
  56913. }
  56914. if (this._adaptiveBlurKernel) {
  56915. this._autoComputeBlurKernel();
  56916. }
  56917. };
  56918. MirrorTexture.prototype._updateGammaSpace = function () {
  56919. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  56920. };
  56921. MirrorTexture.prototype._preparePostProcesses = function () {
  56922. this.clearPostProcesses(true);
  56923. if (this._blurKernelX && this._blurKernelY) {
  56924. var engine = this.getScene().getEngine();
  56925. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  56926. 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);
  56927. this._blurX.autoClear = false;
  56928. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  56929. this._blurX.inputTexture = this._texture;
  56930. }
  56931. else {
  56932. this._blurX.alwaysForcePOT = true;
  56933. }
  56934. 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);
  56935. this._blurY.autoClear = false;
  56936. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  56937. this.addPostProcess(this._blurX);
  56938. this.addPostProcess(this._blurY);
  56939. }
  56940. else {
  56941. if (this._blurY) {
  56942. this.removePostProcess(this._blurY);
  56943. this._blurY.dispose();
  56944. this._blurY = null;
  56945. }
  56946. if (this._blurX) {
  56947. this.removePostProcess(this._blurX);
  56948. this._blurX.dispose();
  56949. this._blurX = null;
  56950. }
  56951. }
  56952. };
  56953. /**
  56954. * Clone the mirror texture.
  56955. * @returns the cloned texture
  56956. */
  56957. MirrorTexture.prototype.clone = function () {
  56958. var scene = this.getScene();
  56959. if (!scene) {
  56960. return this;
  56961. }
  56962. var textureSize = this.getSize();
  56963. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  56964. // Base texture
  56965. newTexture.hasAlpha = this.hasAlpha;
  56966. newTexture.level = this.level;
  56967. // Mirror Texture
  56968. newTexture.mirrorPlane = this.mirrorPlane.clone();
  56969. if (this.renderList) {
  56970. newTexture.renderList = this.renderList.slice(0);
  56971. }
  56972. return newTexture;
  56973. };
  56974. /**
  56975. * Serialize the texture to a JSON representation you could use in Parse later on
  56976. * @returns the serialized JSON representation
  56977. */
  56978. MirrorTexture.prototype.serialize = function () {
  56979. if (!this.name) {
  56980. return null;
  56981. }
  56982. var serializationObject = _super.prototype.serialize.call(this);
  56983. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  56984. return serializationObject;
  56985. };
  56986. /**
  56987. * Dispose the texture and release its associated resources.
  56988. */
  56989. MirrorTexture.prototype.dispose = function () {
  56990. _super.prototype.dispose.call(this);
  56991. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  56992. };
  56993. return MirrorTexture;
  56994. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  56995. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  56996. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  56997. };
  56998. /***/ }),
  56999. /***/ "./Materials/Textures/multiRenderTarget.ts":
  57000. /*!*************************************************!*\
  57001. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  57002. \*************************************************/
  57003. /*! exports provided: MultiRenderTarget */
  57004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57005. "use strict";
  57006. __webpack_require__.r(__webpack_exports__);
  57007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  57008. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57009. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57010. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57011. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57012. /**
  57013. * A multi render target, like a render target provides the ability to render to a texture.
  57014. * Unlike the render target, it can render to several draw buffers in one draw.
  57015. * This is specially interesting in deferred rendering or for any effects requiring more than
  57016. * just one color from a single pass.
  57017. */
  57018. var MultiRenderTarget = /** @class */ (function (_super) {
  57019. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  57020. /**
  57021. * Instantiate a new multi render target texture.
  57022. * A multi render target, like a render target provides the ability to render to a texture.
  57023. * Unlike the render target, it can render to several draw buffers in one draw.
  57024. * This is specially interesting in deferred rendering or for any effects requiring more than
  57025. * just one color from a single pass.
  57026. * @param name Define the name of the texture
  57027. * @param size Define the size of the buffers to render to
  57028. * @param count Define the number of target we are rendering into
  57029. * @param scene Define the scene the texture belongs to
  57030. * @param options Define the options used to create the multi render target
  57031. */
  57032. function MultiRenderTarget(name, size, count, scene, options) {
  57033. var _this = this;
  57034. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  57035. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  57036. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  57037. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  57038. _this._engine = scene.getEngine();
  57039. if (!_this.isSupported) {
  57040. _this.dispose();
  57041. return;
  57042. }
  57043. var types = [];
  57044. var samplingModes = [];
  57045. for (var i = 0; i < count; i++) {
  57046. if (options && options.types && options.types[i] !== undefined) {
  57047. types.push(options.types[i]);
  57048. }
  57049. else {
  57050. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  57051. }
  57052. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  57053. samplingModes.push(options.samplingModes[i]);
  57054. }
  57055. else {
  57056. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  57057. }
  57058. }
  57059. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  57060. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  57061. _this._size = size;
  57062. _this._multiRenderTargetOptions = {
  57063. samplingModes: samplingModes,
  57064. generateMipMaps: generateMipMaps,
  57065. generateDepthBuffer: generateDepthBuffer,
  57066. generateStencilBuffer: generateStencilBuffer,
  57067. generateDepthTexture: generateDepthTexture,
  57068. types: types,
  57069. textureCount: count
  57070. };
  57071. _this._createInternalTextures();
  57072. _this._createTextures();
  57073. return _this;
  57074. }
  57075. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  57076. /**
  57077. * Get if draw buffers are currently supported by the used hardware and browser.
  57078. */
  57079. get: function () {
  57080. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  57081. },
  57082. enumerable: true,
  57083. configurable: true
  57084. });
  57085. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  57086. /**
  57087. * Get the list of textures generated by the multi render target.
  57088. */
  57089. get: function () {
  57090. return this._textures;
  57091. },
  57092. enumerable: true,
  57093. configurable: true
  57094. });
  57095. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  57096. /**
  57097. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  57098. */
  57099. get: function () {
  57100. return this._textures[this._textures.length - 1];
  57101. },
  57102. enumerable: true,
  57103. configurable: true
  57104. });
  57105. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  57106. /**
  57107. * Set the wrapping mode on U of all the textures we are rendering to.
  57108. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57109. */
  57110. set: function (wrap) {
  57111. if (this._textures) {
  57112. for (var i = 0; i < this._textures.length; i++) {
  57113. this._textures[i].wrapU = wrap;
  57114. }
  57115. }
  57116. },
  57117. enumerable: true,
  57118. configurable: true
  57119. });
  57120. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  57121. /**
  57122. * Set the wrapping mode on V of all the textures we are rendering to.
  57123. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57124. */
  57125. set: function (wrap) {
  57126. if (this._textures) {
  57127. for (var i = 0; i < this._textures.length; i++) {
  57128. this._textures[i].wrapV = wrap;
  57129. }
  57130. }
  57131. },
  57132. enumerable: true,
  57133. configurable: true
  57134. });
  57135. /** @hidden */
  57136. MultiRenderTarget.prototype._rebuild = function () {
  57137. this.releaseInternalTextures();
  57138. this._createInternalTextures();
  57139. for (var i = 0; i < this._internalTextures.length; i++) {
  57140. var texture = this._textures[i];
  57141. texture._texture = this._internalTextures[i];
  57142. }
  57143. // Keeps references to frame buffer and stencil/depth buffer
  57144. this._texture = this._internalTextures[0];
  57145. };
  57146. MultiRenderTarget.prototype._createInternalTextures = function () {
  57147. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  57148. };
  57149. MultiRenderTarget.prototype._createTextures = function () {
  57150. this._textures = [];
  57151. for (var i = 0; i < this._internalTextures.length; i++) {
  57152. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  57153. texture._texture = this._internalTextures[i];
  57154. this._textures.push(texture);
  57155. }
  57156. // Keeps references to frame buffer and stencil/depth buffer
  57157. this._texture = this._internalTextures[0];
  57158. };
  57159. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  57160. /**
  57161. * Define the number of samples used if MSAA is enabled.
  57162. */
  57163. get: function () {
  57164. return this._samples;
  57165. },
  57166. set: function (value) {
  57167. if (this._samples === value) {
  57168. return;
  57169. }
  57170. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  57171. },
  57172. enumerable: true,
  57173. configurable: true
  57174. });
  57175. /**
  57176. * Resize all the textures in the multi render target.
  57177. * Be carrefull as it will recreate all the data in the new texture.
  57178. * @param size Define the new size
  57179. */
  57180. MultiRenderTarget.prototype.resize = function (size) {
  57181. this.releaseInternalTextures();
  57182. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  57183. this._createInternalTextures();
  57184. };
  57185. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57186. var _this = this;
  57187. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  57188. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57189. });
  57190. };
  57191. /**
  57192. * Dispose the render targets and their associated resources
  57193. */
  57194. MultiRenderTarget.prototype.dispose = function () {
  57195. this.releaseInternalTextures();
  57196. _super.prototype.dispose.call(this);
  57197. };
  57198. /**
  57199. * Release all the underlying texture used as draw buffers.
  57200. */
  57201. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  57202. if (!this._internalTextures) {
  57203. return;
  57204. }
  57205. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  57206. if (this._internalTextures[i] !== undefined) {
  57207. this._internalTextures[i].dispose();
  57208. this._internalTextures.splice(i, 1);
  57209. }
  57210. }
  57211. };
  57212. return MultiRenderTarget;
  57213. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57214. /***/ }),
  57215. /***/ "./Materials/Textures/rawCubeTexture.ts":
  57216. /*!**********************************************!*\
  57217. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  57218. \**********************************************/
  57219. /*! exports provided: RawCubeTexture */
  57220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57221. "use strict";
  57222. __webpack_require__.r(__webpack_exports__);
  57223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  57224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57225. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57226. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  57227. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  57228. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  57229. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57230. /**
  57231. * Raw cube texture where the raw buffers are passed in
  57232. */
  57233. var RawCubeTexture = /** @class */ (function (_super) {
  57234. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  57235. /**
  57236. * Creates a cube texture where the raw buffers are passed in.
  57237. * @param scene defines the scene the texture is attached to
  57238. * @param data defines the array of data to use to create each face
  57239. * @param size defines the size of the textures
  57240. * @param format defines the format of the data
  57241. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57242. * @param generateMipMaps defines if the engine should generate the mip levels
  57243. * @param invertY defines if data must be stored with Y axis inverted
  57244. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57245. * @param compression defines the compression used (null by default)
  57246. */
  57247. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  57248. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  57249. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57250. if (generateMipMaps === void 0) { generateMipMaps = false; }
  57251. if (invertY === void 0) { invertY = false; }
  57252. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57253. if (compression === void 0) { compression = null; }
  57254. var _this = _super.call(this, "", scene) || this;
  57255. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  57256. return _this;
  57257. }
  57258. /**
  57259. * Updates the raw cube texture.
  57260. * @param data defines the data to store
  57261. * @param format defines the data format
  57262. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57263. * @param invertY defines if data must be stored with Y axis inverted
  57264. * @param compression defines the compression used (null by default)
  57265. * @param level defines which level of the texture to update
  57266. */
  57267. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  57268. if (compression === void 0) { compression = null; }
  57269. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  57270. };
  57271. /**
  57272. * Updates a raw cube texture with RGBD encoded data.
  57273. * @param data defines the array of data [mipmap][face] to use to create each face
  57274. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57275. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57276. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57277. * @returns a promsie that resolves when the operation is complete
  57278. */
  57279. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  57280. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  57281. if (lodScale === void 0) { lodScale = 0.8; }
  57282. if (lodOffset === void 0) { lodOffset = 0; }
  57283. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  57284. };
  57285. /**
  57286. * Clones the raw cube texture.
  57287. * @return a new cube texture
  57288. */
  57289. RawCubeTexture.prototype.clone = function () {
  57290. var _this = this;
  57291. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57292. var scene = _this.getScene();
  57293. var internalTexture = _this._texture;
  57294. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  57295. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  57296. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  57297. }
  57298. return texture;
  57299. }, this);
  57300. };
  57301. /** @hidden */
  57302. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  57303. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  57304. internalTexture._bufferViewArrayArray = data;
  57305. internalTexture._lodGenerationScale = lodScale;
  57306. internalTexture._lodGenerationOffset = lodOffset;
  57307. internalTexture._sphericalPolynomial = sphericalPolynomial;
  57308. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  57309. internalTexture.isReady = true;
  57310. });
  57311. };
  57312. return RawCubeTexture;
  57313. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  57314. /***/ }),
  57315. /***/ "./Materials/Textures/rawTexture.ts":
  57316. /*!******************************************!*\
  57317. !*** ./Materials/Textures/rawTexture.ts ***!
  57318. \******************************************/
  57319. /*! exports provided: RawTexture */
  57320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57321. "use strict";
  57322. __webpack_require__.r(__webpack_exports__);
  57323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  57324. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57325. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57326. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57327. /**
  57328. * Raw texture can help creating a texture directly from an array of data.
  57329. * This can be super useful if you either get the data from an uncompressed source or
  57330. * if you wish to create your texture pixel by pixel.
  57331. */
  57332. var RawTexture = /** @class */ (function (_super) {
  57333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  57334. /**
  57335. * Instantiates a new RawTexture.
  57336. * Raw texture can help creating a texture directly from an array of data.
  57337. * This can be super useful if you either get the data from an uncompressed source or
  57338. * if you wish to create your texture pixel by pixel.
  57339. * @param data define the array of data to use to create the texture
  57340. * @param width define the width of the texture
  57341. * @param height define the height of the texture
  57342. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57343. * @param scene define the scene the texture belongs to
  57344. * @param generateMipMaps define whether mip maps should be generated or not
  57345. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57346. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57347. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57348. */
  57349. function RawTexture(data, width, height,
  57350. /**
  57351. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57352. */
  57353. format, scene, generateMipMaps, invertY, samplingMode, type) {
  57354. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57355. if (invertY === void 0) { invertY = false; }
  57356. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57357. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57358. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57359. _this.format = format;
  57360. _this._engine = scene.getEngine();
  57361. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  57362. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57363. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57364. return _this;
  57365. }
  57366. /**
  57367. * Updates the texture underlying data.
  57368. * @param data Define the new data of the texture
  57369. */
  57370. RawTexture.prototype.update = function (data) {
  57371. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57372. };
  57373. /**
  57374. * Creates a luminance texture from some data.
  57375. * @param data Define the texture data
  57376. * @param width Define the width of the texture
  57377. * @param height Define the height of the texture
  57378. * @param scene Define the scene the texture belongs to
  57379. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57380. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57381. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57382. * @returns the luminance texture
  57383. */
  57384. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57385. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57386. if (invertY === void 0) { invertY = false; }
  57387. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57388. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  57389. };
  57390. /**
  57391. * Creates a luminance alpha texture from some data.
  57392. * @param data Define the texture data
  57393. * @param width Define the width of the texture
  57394. * @param height Define the height of the texture
  57395. * @param scene Define the scene the texture belongs to
  57396. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57397. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57398. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57399. * @returns the luminance alpha texture
  57400. */
  57401. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57402. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57403. if (invertY === void 0) { invertY = false; }
  57404. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57405. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57406. };
  57407. /**
  57408. * Creates an alpha texture from some data.
  57409. * @param data Define the texture data
  57410. * @param width Define the width of the texture
  57411. * @param height Define the height of the texture
  57412. * @param scene Define the scene the texture belongs to
  57413. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57414. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57415. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57416. * @returns the alpha texture
  57417. */
  57418. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57419. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57420. if (invertY === void 0) { invertY = false; }
  57421. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57422. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57423. };
  57424. /**
  57425. * Creates a RGB texture from some data.
  57426. * @param data Define the texture data
  57427. * @param width Define the width of the texture
  57428. * @param height Define the height of the texture
  57429. * @param scene Define the scene the texture belongs to
  57430. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57431. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57432. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57433. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57434. * @returns the RGB alpha texture
  57435. */
  57436. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57437. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57438. if (invertY === void 0) { invertY = false; }
  57439. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57440. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57441. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  57442. };
  57443. /**
  57444. * Creates a RGBA texture from some data.
  57445. * @param data Define the texture data
  57446. * @param width Define the width of the texture
  57447. * @param height Define the height of the texture
  57448. * @param scene Define the scene the texture belongs to
  57449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57452. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57453. * @returns the RGBA texture
  57454. */
  57455. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57456. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57457. if (invertY === void 0) { invertY = false; }
  57458. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57459. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57460. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  57461. };
  57462. /**
  57463. * Creates a R texture from some data.
  57464. * @param data Define the texture data
  57465. * @param width Define the width of the texture
  57466. * @param height Define the height of the texture
  57467. * @param scene Define the scene the texture belongs to
  57468. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57471. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57472. * @returns the R texture
  57473. */
  57474. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57475. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57476. if (invertY === void 0) { invertY = false; }
  57477. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57478. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  57479. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  57480. };
  57481. return RawTexture;
  57482. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57483. /***/ }),
  57484. /***/ "./Materials/Textures/rawTexture3D.ts":
  57485. /*!********************************************!*\
  57486. !*** ./Materials/Textures/rawTexture3D.ts ***!
  57487. \********************************************/
  57488. /*! exports provided: RawTexture3D */
  57489. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57490. "use strict";
  57491. __webpack_require__.r(__webpack_exports__);
  57492. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  57493. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57494. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57495. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57496. /**
  57497. * Class used to store 3D textures containing user data
  57498. */
  57499. var RawTexture3D = /** @class */ (function (_super) {
  57500. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  57501. /**
  57502. * Create a new RawTexture3D
  57503. * @param data defines the data of the texture
  57504. * @param width defines the width of the texture
  57505. * @param height defines the height of the texture
  57506. * @param depth defines the depth of the texture
  57507. * @param format defines the texture format to use
  57508. * @param scene defines the hosting scene
  57509. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57510. * @param invertY defines if texture must be stored with Y axis inverted
  57511. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57512. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57513. */
  57514. function RawTexture3D(data, width, height, depth,
  57515. /** Gets or sets the texture format to use */
  57516. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  57517. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57518. if (invertY === void 0) { invertY = false; }
  57519. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57520. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57521. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57522. _this.format = format;
  57523. _this._engine = scene.getEngine();
  57524. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  57525. _this.is3D = true;
  57526. return _this;
  57527. }
  57528. /**
  57529. * Update the texture with new data
  57530. * @param data defines the data to store in the texture
  57531. */
  57532. RawTexture3D.prototype.update = function (data) {
  57533. if (!this._texture) {
  57534. return;
  57535. }
  57536. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57537. };
  57538. return RawTexture3D;
  57539. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57540. /***/ }),
  57541. /***/ "./Materials/Textures/refractionTexture.ts":
  57542. /*!*************************************************!*\
  57543. !*** ./Materials/Textures/refractionTexture.ts ***!
  57544. \*************************************************/
  57545. /*! exports provided: RefractionTexture */
  57546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57547. "use strict";
  57548. __webpack_require__.r(__webpack_exports__);
  57549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  57550. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57551. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57552. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57553. /**
  57554. * Creates a refraction texture used by refraction channel of the standard material.
  57555. * It is like a mirror but to see through a material.
  57556. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57557. */
  57558. var RefractionTexture = /** @class */ (function (_super) {
  57559. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  57560. /**
  57561. * Creates a refraction texture used by refraction channel of the standard material.
  57562. * It is like a mirror but to see through a material.
  57563. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57564. * @param name Define the texture name
  57565. * @param size Define the size of the underlying texture
  57566. * @param scene Define the scene the refraction belongs to
  57567. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57568. */
  57569. function RefractionTexture(name, size, scene, generateMipMaps) {
  57570. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  57571. /**
  57572. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57573. * 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.
  57574. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57575. */
  57576. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  57577. /**
  57578. * Define how deep under the surface we should see.
  57579. */
  57580. _this.depth = 2.0;
  57581. _this.onBeforeRenderObservable.add(function () {
  57582. scene.clipPlane = _this.refractionPlane;
  57583. });
  57584. _this.onAfterRenderObservable.add(function () {
  57585. delete scene.clipPlane;
  57586. });
  57587. return _this;
  57588. }
  57589. /**
  57590. * Clone the refraction texture.
  57591. * @returns the cloned texture
  57592. */
  57593. RefractionTexture.prototype.clone = function () {
  57594. var scene = this.getScene();
  57595. if (!scene) {
  57596. return this;
  57597. }
  57598. var textureSize = this.getSize();
  57599. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  57600. // Base texture
  57601. newTexture.hasAlpha = this.hasAlpha;
  57602. newTexture.level = this.level;
  57603. // Refraction Texture
  57604. newTexture.refractionPlane = this.refractionPlane.clone();
  57605. if (this.renderList) {
  57606. newTexture.renderList = this.renderList.slice(0);
  57607. }
  57608. newTexture.depth = this.depth;
  57609. return newTexture;
  57610. };
  57611. /**
  57612. * Serialize the texture to a JSON representation you could use in Parse later on
  57613. * @returns the serialized JSON representation
  57614. */
  57615. RefractionTexture.prototype.serialize = function () {
  57616. if (!this.name) {
  57617. return null;
  57618. }
  57619. var serializationObject = _super.prototype.serialize.call(this);
  57620. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  57621. serializationObject.depth = this.depth;
  57622. return serializationObject;
  57623. };
  57624. return RefractionTexture;
  57625. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57626. /***/ }),
  57627. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  57628. /*!***********************************************************!*\
  57629. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  57630. \***********************************************************/
  57631. /*! exports provided: RenderTargetCreationOptions */
  57632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57633. "use strict";
  57634. __webpack_require__.r(__webpack_exports__);
  57635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  57636. /**
  57637. * Define options used to create a render target texture
  57638. */
  57639. var RenderTargetCreationOptions = /** @class */ (function () {
  57640. function RenderTargetCreationOptions() {
  57641. }
  57642. return RenderTargetCreationOptions;
  57643. }());
  57644. /***/ }),
  57645. /***/ "./Materials/Textures/renderTargetTexture.ts":
  57646. /*!***************************************************!*\
  57647. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  57648. \***************************************************/
  57649. /*! exports provided: RenderTargetTexture */
  57650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57651. "use strict";
  57652. __webpack_require__.r(__webpack_exports__);
  57653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  57654. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57655. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57656. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57657. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57658. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57659. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  57660. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  57661. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57662. /**
  57663. * This Helps creating a texture that will be created from a camera in your scene.
  57664. * It is basically a dynamic texture that could be used to create special effects for instance.
  57665. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  57666. */
  57667. var RenderTargetTexture = /** @class */ (function (_super) {
  57668. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  57669. /**
  57670. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  57671. * or used a shadow, depth texture...
  57672. * @param name The friendly name of the texture
  57673. * @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)
  57674. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  57675. * @param generateMipMaps True if mip maps need to be generated after render.
  57676. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  57677. * @param type The type of the buffer in the RTT (int, half float, float...)
  57678. * @param isCube True if a cube texture needs to be created
  57679. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  57680. * @param generateDepthBuffer True to generate a depth buffer
  57681. * @param generateStencilBuffer True to generate a stencil buffer
  57682. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  57683. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  57684. * @param delayAllocation if the texture allocation should be delayed (default: false)
  57685. */
  57686. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  57687. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  57688. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57689. if (isCube === void 0) { isCube = false; }
  57690. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57691. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  57692. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  57693. if (isMulti === void 0) { isMulti = false; }
  57694. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  57695. if (delayAllocation === void 0) { delayAllocation = false; }
  57696. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  57697. _this.isCube = isCube;
  57698. /**
  57699. * Define if particles should be rendered in your texture.
  57700. */
  57701. _this.renderParticles = true;
  57702. /**
  57703. * Define if sprites should be rendered in your texture.
  57704. */
  57705. _this.renderSprites = false;
  57706. /**
  57707. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  57708. */
  57709. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  57710. /**
  57711. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  57712. */
  57713. _this.ignoreCameraViewport = false;
  57714. /**
  57715. * An event triggered when the texture is unbind.
  57716. */
  57717. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57718. /**
  57719. * An event triggered when the texture is unbind.
  57720. */
  57721. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57722. /**
  57723. * An event triggered before rendering the texture
  57724. */
  57725. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57726. /**
  57727. * An event triggered after rendering the texture
  57728. */
  57729. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57730. /**
  57731. * An event triggered after the texture clear
  57732. */
  57733. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57734. _this._currentRefreshId = -1;
  57735. _this._refreshRate = 1;
  57736. _this._samples = 1;
  57737. /**
  57738. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  57739. * It must define where the camera used to render the texture is set
  57740. */
  57741. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57742. scene = _this.getScene();
  57743. if (!scene) {
  57744. return _this;
  57745. }
  57746. _this.renderList = new Array();
  57747. _this._engine = scene.getEngine();
  57748. _this.name = name;
  57749. _this.isRenderTarget = true;
  57750. _this._initialSizeParameter = size;
  57751. _this._processSizeParameter(size);
  57752. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  57753. });
  57754. _this._generateMipMaps = generateMipMaps ? true : false;
  57755. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  57756. // Rendering groups
  57757. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  57758. _this._renderingManager._useSceneAutoClearSetup = true;
  57759. if (isMulti) {
  57760. return _this;
  57761. }
  57762. _this._renderTargetOptions = {
  57763. generateMipMaps: generateMipMaps,
  57764. type: type,
  57765. format: format,
  57766. samplingMode: samplingMode,
  57767. generateDepthBuffer: generateDepthBuffer,
  57768. generateStencilBuffer: generateStencilBuffer
  57769. };
  57770. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  57771. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57772. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57773. }
  57774. if (!delayAllocation) {
  57775. if (isCube) {
  57776. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  57777. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  57778. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57779. }
  57780. else {
  57781. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  57782. }
  57783. }
  57784. return _this;
  57785. }
  57786. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  57787. /**
  57788. * Use this list to define the list of mesh you want to render.
  57789. */
  57790. get: function () {
  57791. return this._renderList;
  57792. },
  57793. set: function (value) {
  57794. this._renderList = value;
  57795. if (this._renderList) {
  57796. this._hookArray(this._renderList);
  57797. }
  57798. },
  57799. enumerable: true,
  57800. configurable: true
  57801. });
  57802. RenderTargetTexture.prototype._hookArray = function (array) {
  57803. var _this = this;
  57804. var oldPush = array.push;
  57805. array.push = function () {
  57806. var items = [];
  57807. for (var _i = 0; _i < arguments.length; _i++) {
  57808. items[_i] = arguments[_i];
  57809. }
  57810. var wasEmpty = array.length === 0;
  57811. var result = oldPush.apply(array, items);
  57812. if (wasEmpty) {
  57813. _this.getScene().meshes.forEach(function (mesh) {
  57814. mesh._markSubMeshesAsLightDirty();
  57815. });
  57816. }
  57817. return result;
  57818. };
  57819. var oldSplice = array.splice;
  57820. array.splice = function (index, deleteCount) {
  57821. var deleted = oldSplice.apply(array, [index, deleteCount]);
  57822. if (array.length === 0) {
  57823. _this.getScene().meshes.forEach(function (mesh) {
  57824. mesh._markSubMeshesAsLightDirty();
  57825. });
  57826. }
  57827. return deleted;
  57828. };
  57829. };
  57830. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  57831. /**
  57832. * Set a after unbind callback in the texture.
  57833. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  57834. */
  57835. set: function (callback) {
  57836. if (this._onAfterUnbindObserver) {
  57837. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  57838. }
  57839. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  57840. },
  57841. enumerable: true,
  57842. configurable: true
  57843. });
  57844. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  57845. /**
  57846. * Set a before render callback in the texture.
  57847. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  57848. */
  57849. set: function (callback) {
  57850. if (this._onBeforeRenderObserver) {
  57851. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  57852. }
  57853. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  57854. },
  57855. enumerable: true,
  57856. configurable: true
  57857. });
  57858. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  57859. /**
  57860. * Set a after render callback in the texture.
  57861. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  57862. */
  57863. set: function (callback) {
  57864. if (this._onAfterRenderObserver) {
  57865. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  57866. }
  57867. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  57868. },
  57869. enumerable: true,
  57870. configurable: true
  57871. });
  57872. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  57873. /**
  57874. * Set a clear callback in the texture.
  57875. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  57876. */
  57877. set: function (callback) {
  57878. if (this._onClearObserver) {
  57879. this.onClearObservable.remove(this._onClearObserver);
  57880. }
  57881. this._onClearObserver = this.onClearObservable.add(callback);
  57882. },
  57883. enumerable: true,
  57884. configurable: true
  57885. });
  57886. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  57887. /**
  57888. * Gets render target creation options that were used.
  57889. */
  57890. get: function () {
  57891. return this._renderTargetOptions;
  57892. },
  57893. enumerable: true,
  57894. configurable: true
  57895. });
  57896. RenderTargetTexture.prototype._onRatioRescale = function () {
  57897. if (this._sizeRatio) {
  57898. this.resize(this._initialSizeParameter);
  57899. }
  57900. };
  57901. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  57902. get: function () {
  57903. return this._boundingBoxSize;
  57904. },
  57905. /**
  57906. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  57907. * When defined, the cubemap will switch to local mode
  57908. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57909. * @example https://www.babylonjs-playground.com/#RNASML
  57910. */
  57911. set: function (value) {
  57912. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57913. return;
  57914. }
  57915. this._boundingBoxSize = value;
  57916. var scene = this.getScene();
  57917. if (scene) {
  57918. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57919. }
  57920. },
  57921. enumerable: true,
  57922. configurable: true
  57923. });
  57924. /**
  57925. * Creates a depth stencil texture.
  57926. * This is only available in WebGL 2 or with the depth texture extension available.
  57927. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  57928. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  57929. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  57930. */
  57931. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  57932. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  57933. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  57934. if (generateStencil === void 0) { generateStencil = false; }
  57935. if (!this.getScene()) {
  57936. return;
  57937. }
  57938. var engine = this.getScene().getEngine();
  57939. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  57940. bilinearFiltering: bilinearFiltering,
  57941. comparisonFunction: comparisonFunction,
  57942. generateStencil: generateStencil,
  57943. isCube: this.isCube
  57944. });
  57945. engine.setFrameBufferDepthStencilTexture(this);
  57946. };
  57947. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  57948. if (size.ratio) {
  57949. this._sizeRatio = size.ratio;
  57950. this._size = {
  57951. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  57952. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  57953. };
  57954. }
  57955. else {
  57956. this._size = size;
  57957. }
  57958. };
  57959. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  57960. /**
  57961. * Define the number of samples to use in case of MSAA.
  57962. * It defaults to one meaning no MSAA has been enabled.
  57963. */
  57964. get: function () {
  57965. return this._samples;
  57966. },
  57967. set: function (value) {
  57968. if (this._samples === value) {
  57969. return;
  57970. }
  57971. var scene = this.getScene();
  57972. if (!scene) {
  57973. return;
  57974. }
  57975. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  57976. },
  57977. enumerable: true,
  57978. configurable: true
  57979. });
  57980. /**
  57981. * Resets the refresh counter of the texture and start bak from scratch.
  57982. * Could be useful to regenerate the texture if it is setup to render only once.
  57983. */
  57984. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  57985. this._currentRefreshId = -1;
  57986. };
  57987. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  57988. /**
  57989. * Define the refresh rate of the texture or the rendering frequency.
  57990. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57991. */
  57992. get: function () {
  57993. return this._refreshRate;
  57994. },
  57995. set: function (value) {
  57996. this._refreshRate = value;
  57997. this.resetRefreshCounter();
  57998. },
  57999. enumerable: true,
  58000. configurable: true
  58001. });
  58002. /**
  58003. * Adds a post process to the render target rendering passes.
  58004. * @param postProcess define the post process to add
  58005. */
  58006. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  58007. if (!this._postProcessManager) {
  58008. var scene = this.getScene();
  58009. if (!scene) {
  58010. return;
  58011. }
  58012. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  58013. this._postProcesses = new Array();
  58014. }
  58015. this._postProcesses.push(postProcess);
  58016. this._postProcesses[0].autoClear = false;
  58017. };
  58018. /**
  58019. * Clear all the post processes attached to the render target
  58020. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  58021. */
  58022. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  58023. if (dispose === void 0) { dispose = false; }
  58024. if (!this._postProcesses) {
  58025. return;
  58026. }
  58027. if (dispose) {
  58028. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  58029. var postProcess = _a[_i];
  58030. postProcess.dispose();
  58031. }
  58032. }
  58033. this._postProcesses = [];
  58034. };
  58035. /**
  58036. * Remove one of the post process from the list of attached post processes to the texture
  58037. * @param postProcess define the post process to remove from the list
  58038. */
  58039. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  58040. if (!this._postProcesses) {
  58041. return;
  58042. }
  58043. var index = this._postProcesses.indexOf(postProcess);
  58044. if (index === -1) {
  58045. return;
  58046. }
  58047. this._postProcesses.splice(index, 1);
  58048. if (this._postProcesses.length > 0) {
  58049. this._postProcesses[0].autoClear = false;
  58050. }
  58051. };
  58052. /** @hidden */
  58053. RenderTargetTexture.prototype._shouldRender = function () {
  58054. if (this._currentRefreshId === -1) { // At least render once
  58055. this._currentRefreshId = 1;
  58056. return true;
  58057. }
  58058. if (this.refreshRate === this._currentRefreshId) {
  58059. this._currentRefreshId = 1;
  58060. return true;
  58061. }
  58062. this._currentRefreshId++;
  58063. return false;
  58064. };
  58065. /**
  58066. * Gets the actual render size of the texture.
  58067. * @returns the width of the render size
  58068. */
  58069. RenderTargetTexture.prototype.getRenderSize = function () {
  58070. return this.getRenderWidth();
  58071. };
  58072. /**
  58073. * Gets the actual render width of the texture.
  58074. * @returns the width of the render size
  58075. */
  58076. RenderTargetTexture.prototype.getRenderWidth = function () {
  58077. if (this._size.width) {
  58078. return this._size.width;
  58079. }
  58080. return this._size;
  58081. };
  58082. /**
  58083. * Gets the actual render height of the texture.
  58084. * @returns the height of the render size
  58085. */
  58086. RenderTargetTexture.prototype.getRenderHeight = function () {
  58087. if (this._size.width) {
  58088. return this._size.height;
  58089. }
  58090. return this._size;
  58091. };
  58092. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  58093. /**
  58094. * Get if the texture can be rescaled or not.
  58095. */
  58096. get: function () {
  58097. return true;
  58098. },
  58099. enumerable: true,
  58100. configurable: true
  58101. });
  58102. /**
  58103. * Resize the texture using a ratio.
  58104. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  58105. */
  58106. RenderTargetTexture.prototype.scale = function (ratio) {
  58107. var newSize = this.getRenderSize() * ratio;
  58108. this.resize(newSize);
  58109. };
  58110. /**
  58111. * Get the texture reflection matrix used to rotate/transform the reflection.
  58112. * @returns the reflection matrix
  58113. */
  58114. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  58115. if (this.isCube) {
  58116. return this._textureMatrix;
  58117. }
  58118. return _super.prototype.getReflectionTextureMatrix.call(this);
  58119. };
  58120. /**
  58121. * Resize the texture to a new desired size.
  58122. * Be carrefull as it will recreate all the data in the new texture.
  58123. * @param size Define the new size. It can be:
  58124. * - a number for squared texture,
  58125. * - an object containing { width: number, height: number }
  58126. * - or an object containing a ratio { ratio: number }
  58127. */
  58128. RenderTargetTexture.prototype.resize = function (size) {
  58129. this.releaseInternalTexture();
  58130. var scene = this.getScene();
  58131. if (!scene) {
  58132. return;
  58133. }
  58134. this._processSizeParameter(size);
  58135. if (this.isCube) {
  58136. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  58137. }
  58138. else {
  58139. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  58140. }
  58141. };
  58142. /**
  58143. * Renders all the objects from the render list into the texture.
  58144. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  58145. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  58146. */
  58147. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  58148. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  58149. if (dumpForDebug === void 0) { dumpForDebug = false; }
  58150. var scene = this.getScene();
  58151. if (!scene) {
  58152. return;
  58153. }
  58154. var engine = scene.getEngine();
  58155. if (this.useCameraPostProcesses !== undefined) {
  58156. useCameraPostProcess = this.useCameraPostProcesses;
  58157. }
  58158. if (this._waitingRenderList) {
  58159. this.renderList = [];
  58160. for (var index = 0; index < this._waitingRenderList.length; index++) {
  58161. var id = this._waitingRenderList[index];
  58162. var mesh_1 = scene.getMeshByID(id);
  58163. if (mesh_1) {
  58164. this.renderList.push(mesh_1);
  58165. }
  58166. }
  58167. delete this._waitingRenderList;
  58168. }
  58169. // Is predicate defined?
  58170. if (this.renderListPredicate) {
  58171. if (this.renderList) {
  58172. this.renderList.length = 0; // Clear previous renderList
  58173. }
  58174. else {
  58175. this.renderList = [];
  58176. }
  58177. var scene = this.getScene();
  58178. if (!scene) {
  58179. return;
  58180. }
  58181. var sceneMeshes = scene.meshes;
  58182. for (var index = 0; index < sceneMeshes.length; index++) {
  58183. var mesh = sceneMeshes[index];
  58184. if (this.renderListPredicate(mesh)) {
  58185. this.renderList.push(mesh);
  58186. }
  58187. }
  58188. }
  58189. this.onBeforeBindObservable.notifyObservers(this);
  58190. // Set custom projection.
  58191. // Needs to be before binding to prevent changing the aspect ratio.
  58192. var camera;
  58193. if (this.activeCamera) {
  58194. camera = this.activeCamera;
  58195. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58196. if (this.activeCamera !== scene.activeCamera) {
  58197. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  58198. }
  58199. }
  58200. else {
  58201. camera = scene.activeCamera;
  58202. if (camera) {
  58203. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58204. }
  58205. }
  58206. // Prepare renderingManager
  58207. this._renderingManager.reset();
  58208. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  58209. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  58210. var sceneRenderId = scene.getRenderId();
  58211. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  58212. var mesh = currentRenderList[meshIndex];
  58213. if (mesh) {
  58214. if (!mesh.isReady(this.refreshRate === 0)) {
  58215. this.resetRefreshCounter();
  58216. continue;
  58217. }
  58218. mesh._preActivateForIntermediateRendering(sceneRenderId);
  58219. var isMasked = void 0;
  58220. if (!this.renderList && camera) {
  58221. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  58222. }
  58223. else {
  58224. isMasked = false;
  58225. }
  58226. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  58227. mesh._activate(sceneRenderId);
  58228. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  58229. var subMesh = mesh.subMeshes[subIndex];
  58230. scene._activeIndices.addCount(subMesh.indexCount, false);
  58231. this._renderingManager.dispatch(subMesh, mesh);
  58232. }
  58233. }
  58234. }
  58235. }
  58236. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  58237. var particleSystem = scene.particleSystems[particleIndex];
  58238. var emitter = particleSystem.emitter;
  58239. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  58240. continue;
  58241. }
  58242. if (currentRenderList.indexOf(emitter) >= 0) {
  58243. this._renderingManager.dispatchParticles(particleSystem);
  58244. }
  58245. }
  58246. if (this.isCube) {
  58247. for (var face = 0; face < 6; face++) {
  58248. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  58249. scene.incrementRenderId();
  58250. scene.resetCachedMaterial();
  58251. }
  58252. }
  58253. else {
  58254. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  58255. }
  58256. this.onAfterUnbindObservable.notifyObservers(this);
  58257. if (scene.activeCamera) {
  58258. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  58259. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  58260. }
  58261. engine.setViewport(scene.activeCamera.viewport);
  58262. }
  58263. scene.resetCachedMaterial();
  58264. };
  58265. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  58266. var minimum = 128;
  58267. var x = renderDimension * scale;
  58268. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  58269. // Ensure we don't exceed the render dimension (while staying POT)
  58270. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  58271. };
  58272. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  58273. var _this = this;
  58274. if (!this._texture) {
  58275. return;
  58276. }
  58277. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  58278. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  58279. });
  58280. };
  58281. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  58282. var scene = this.getScene();
  58283. if (!scene) {
  58284. return;
  58285. }
  58286. var engine = scene.getEngine();
  58287. if (!this._texture) {
  58288. return;
  58289. }
  58290. // Bind
  58291. if (this._postProcessManager) {
  58292. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  58293. }
  58294. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  58295. if (this._texture) {
  58296. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  58297. }
  58298. }
  58299. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  58300. // Clear
  58301. if (this.onClearObservable.hasObservers()) {
  58302. this.onClearObservable.notifyObservers(engine);
  58303. }
  58304. else {
  58305. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  58306. }
  58307. if (!this._doNotChangeAspectRatio) {
  58308. scene.updateTransformMatrix(true);
  58309. }
  58310. // Before Camera Draw
  58311. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  58312. var step = _a[_i];
  58313. step.action(this);
  58314. }
  58315. // Render
  58316. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  58317. // After Camera Draw
  58318. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  58319. var step = _c[_b];
  58320. step.action(this);
  58321. }
  58322. if (this._postProcessManager) {
  58323. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  58324. }
  58325. else if (useCameraPostProcess) {
  58326. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  58327. }
  58328. if (!this._doNotChangeAspectRatio) {
  58329. scene.updateTransformMatrix(true);
  58330. }
  58331. // Dump ?
  58332. if (dumpForDebug) {
  58333. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  58334. }
  58335. // Unbind
  58336. if (!this.isCube || faceIndex === 5) {
  58337. if (this.isCube) {
  58338. if (faceIndex === 5) {
  58339. engine.generateMipMapsForCubemap(this._texture);
  58340. }
  58341. }
  58342. this.unbindFrameBuffer(engine, faceIndex);
  58343. }
  58344. else {
  58345. this.onAfterRenderObservable.notifyObservers(faceIndex);
  58346. }
  58347. };
  58348. /**
  58349. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  58350. * This allowed control for front to back rendering or reversly depending of the special needs.
  58351. *
  58352. * @param renderingGroupId The rendering group id corresponding to its index
  58353. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  58354. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  58355. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  58356. */
  58357. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  58358. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  58359. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  58360. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  58361. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  58362. };
  58363. /**
  58364. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  58365. *
  58366. * @param renderingGroupId The rendering group id corresponding to its index
  58367. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58368. */
  58369. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  58370. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  58371. this._renderingManager._useSceneAutoClearSetup = false;
  58372. };
  58373. /**
  58374. * Clones the texture.
  58375. * @returns the cloned texture
  58376. */
  58377. RenderTargetTexture.prototype.clone = function () {
  58378. var textureSize = this.getSize();
  58379. 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);
  58380. // Base texture
  58381. newTexture.hasAlpha = this.hasAlpha;
  58382. newTexture.level = this.level;
  58383. // RenderTarget Texture
  58384. newTexture.coordinatesMode = this.coordinatesMode;
  58385. if (this.renderList) {
  58386. newTexture.renderList = this.renderList.slice(0);
  58387. }
  58388. return newTexture;
  58389. };
  58390. /**
  58391. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58392. * @returns The JSON representation of the texture
  58393. */
  58394. RenderTargetTexture.prototype.serialize = function () {
  58395. if (!this.name) {
  58396. return null;
  58397. }
  58398. var serializationObject = _super.prototype.serialize.call(this);
  58399. serializationObject.renderTargetSize = this.getRenderSize();
  58400. serializationObject.renderList = [];
  58401. if (this.renderList) {
  58402. for (var index = 0; index < this.renderList.length; index++) {
  58403. serializationObject.renderList.push(this.renderList[index].id);
  58404. }
  58405. }
  58406. return serializationObject;
  58407. };
  58408. /**
  58409. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  58410. */
  58411. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  58412. var objBuffer = this.getInternalTexture();
  58413. var scene = this.getScene();
  58414. if (objBuffer && scene) {
  58415. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  58416. }
  58417. };
  58418. /**
  58419. * Dispose the texture and release its associated resources.
  58420. */
  58421. RenderTargetTexture.prototype.dispose = function () {
  58422. if (this._postProcessManager) {
  58423. this._postProcessManager.dispose();
  58424. this._postProcessManager = null;
  58425. }
  58426. this.clearPostProcesses(true);
  58427. if (this._resizeObserver) {
  58428. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  58429. this._resizeObserver = null;
  58430. }
  58431. this.renderList = null;
  58432. // Remove from custom render targets
  58433. var scene = this.getScene();
  58434. if (!scene) {
  58435. return;
  58436. }
  58437. var index = scene.customRenderTargets.indexOf(this);
  58438. if (index >= 0) {
  58439. scene.customRenderTargets.splice(index, 1);
  58440. }
  58441. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  58442. var camera = _a[_i];
  58443. index = camera.customRenderTargets.indexOf(this);
  58444. if (index >= 0) {
  58445. camera.customRenderTargets.splice(index, 1);
  58446. }
  58447. }
  58448. _super.prototype.dispose.call(this);
  58449. };
  58450. /** @hidden */
  58451. RenderTargetTexture.prototype._rebuild = function () {
  58452. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  58453. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  58454. }
  58455. if (this._postProcessManager) {
  58456. this._postProcessManager._rebuild();
  58457. }
  58458. };
  58459. /**
  58460. * Clear the info related to rendering groups preventing retention point in material dispose.
  58461. */
  58462. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  58463. if (this._renderingManager) {
  58464. this._renderingManager.freeRenderingGroups();
  58465. }
  58466. };
  58467. /**
  58468. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  58469. */
  58470. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  58471. /**
  58472. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  58473. */
  58474. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  58475. /**
  58476. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  58477. * the central point of your effect and can save a lot of performances.
  58478. */
  58479. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  58480. return RenderTargetTexture;
  58481. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58482. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58483. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  58484. };
  58485. /***/ }),
  58486. /***/ "./Materials/Textures/texture.ts":
  58487. /*!***************************************!*\
  58488. !*** ./Materials/Textures/texture.ts ***!
  58489. \***************************************/
  58490. /*! exports provided: Texture */
  58491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58492. "use strict";
  58493. __webpack_require__.r(__webpack_exports__);
  58494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  58495. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58496. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58497. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58498. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58499. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58500. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58501. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58502. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58503. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58504. /**
  58505. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58506. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58507. */
  58508. var Texture = /** @class */ (function (_super) {
  58509. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  58510. /**
  58511. * Instantiates a new texture.
  58512. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58513. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58514. * @param url define the url of the picture to load as a texture
  58515. * @param scene define the scene the texture will belong to
  58516. * @param noMipmap define if the texture will require mip maps or not
  58517. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58518. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58519. * @param onLoad define a callback triggered when the texture has been loaded
  58520. * @param onError define a callback triggered when an error occurred during the loading session
  58521. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58522. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58523. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58524. */
  58525. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  58526. if (noMipmap === void 0) { noMipmap = false; }
  58527. if (invertY === void 0) { invertY = true; }
  58528. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58529. if (onLoad === void 0) { onLoad = null; }
  58530. if (onError === void 0) { onError = null; }
  58531. if (buffer === void 0) { buffer = null; }
  58532. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58533. var _this = _super.call(this, scene) || this;
  58534. /**
  58535. * Define an offset on the texture to offset the u coordinates of the UVs
  58536. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58537. */
  58538. _this.uOffset = 0;
  58539. /**
  58540. * Define an offset on the texture to offset the v coordinates of the UVs
  58541. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58542. */
  58543. _this.vOffset = 0;
  58544. /**
  58545. * Define an offset on the texture to scale the u coordinates of the UVs
  58546. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58547. */
  58548. _this.uScale = 1.0;
  58549. /**
  58550. * Define an offset on the texture to scale the v coordinates of the UVs
  58551. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58552. */
  58553. _this.vScale = 1.0;
  58554. /**
  58555. * Define an offset on the texture to rotate around the u coordinates of the UVs
  58556. * @see http://doc.babylonjs.com/how_to/more_materials
  58557. */
  58558. _this.uAng = 0;
  58559. /**
  58560. * Define an offset on the texture to rotate around the v coordinates of the UVs
  58561. * @see http://doc.babylonjs.com/how_to/more_materials
  58562. */
  58563. _this.vAng = 0;
  58564. /**
  58565. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  58566. * @see http://doc.babylonjs.com/how_to/more_materials
  58567. */
  58568. _this.wAng = 0;
  58569. /**
  58570. * Defines the center of rotation (U)
  58571. */
  58572. _this.uRotationCenter = 0.5;
  58573. /**
  58574. * Defines the center of rotation (V)
  58575. */
  58576. _this.vRotationCenter = 0.5;
  58577. /**
  58578. * Defines the center of rotation (W)
  58579. */
  58580. _this.wRotationCenter = 0.5;
  58581. /** @hidden */
  58582. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  58583. /**
  58584. * Observable triggered once the texture has been loaded.
  58585. */
  58586. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  58587. _this._isBlocking = true;
  58588. _this.name = url || "";
  58589. _this.url = url;
  58590. _this._noMipmap = noMipmap;
  58591. _this._invertY = invertY;
  58592. _this._initialSamplingMode = samplingMode;
  58593. _this._buffer = buffer;
  58594. _this._deleteBuffer = deleteBuffer;
  58595. if (format) {
  58596. _this._format = format;
  58597. }
  58598. scene = _this.getScene();
  58599. if (!scene) {
  58600. return _this;
  58601. }
  58602. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  58603. var load = function () {
  58604. if (_this._texture && _this._texture._invertVScale) {
  58605. _this.vScale = -1;
  58606. }
  58607. if (_this.onLoadObservable.hasObservers()) {
  58608. _this.onLoadObservable.notifyObservers(_this);
  58609. }
  58610. if (onLoad) {
  58611. onLoad();
  58612. }
  58613. if (!_this.isBlocking && scene) {
  58614. scene.resetCachedMaterial();
  58615. }
  58616. };
  58617. if (!_this.url) {
  58618. _this._delayedOnLoad = load;
  58619. _this._delayedOnError = onError;
  58620. return _this;
  58621. }
  58622. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  58623. if (!_this._texture) {
  58624. if (!scene.useDelayedTextureLoading) {
  58625. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  58626. if (deleteBuffer) {
  58627. delete _this._buffer;
  58628. }
  58629. }
  58630. else {
  58631. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58632. _this._delayedOnLoad = load;
  58633. _this._delayedOnError = onError;
  58634. }
  58635. }
  58636. else {
  58637. if (_this._texture.isReady) {
  58638. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  58639. }
  58640. else {
  58641. _this._texture.onLoadedObservable.add(load);
  58642. }
  58643. }
  58644. return _this;
  58645. }
  58646. Object.defineProperty(Texture.prototype, "noMipmap", {
  58647. /**
  58648. * Are mip maps generated for this texture or not.
  58649. */
  58650. get: function () {
  58651. return this._noMipmap;
  58652. },
  58653. enumerable: true,
  58654. configurable: true
  58655. });
  58656. Object.defineProperty(Texture.prototype, "isBlocking", {
  58657. get: function () {
  58658. return this._isBlocking;
  58659. },
  58660. /**
  58661. * Is the texture preventing material to render while loading.
  58662. * If false, a default texture will be used instead of the loading one during the preparation step.
  58663. */
  58664. set: function (value) {
  58665. this._isBlocking = value;
  58666. },
  58667. enumerable: true,
  58668. configurable: true
  58669. });
  58670. Object.defineProperty(Texture.prototype, "samplingMode", {
  58671. /**
  58672. * Get the current sampling mode associated with the texture.
  58673. */
  58674. get: function () {
  58675. if (!this._texture) {
  58676. return this._initialSamplingMode;
  58677. }
  58678. return this._texture.samplingMode;
  58679. },
  58680. enumerable: true,
  58681. configurable: true
  58682. });
  58683. Object.defineProperty(Texture.prototype, "invertY", {
  58684. /**
  58685. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  58686. */
  58687. get: function () {
  58688. return this._invertY;
  58689. },
  58690. enumerable: true,
  58691. configurable: true
  58692. });
  58693. /**
  58694. * Update the url (and optional buffer) of this texture if url was null during construction.
  58695. * @param url the url of the texture
  58696. * @param buffer the buffer of the texture (defaults to null)
  58697. * @param onLoad callback called when the texture is loaded (defaults to null)
  58698. */
  58699. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  58700. if (buffer === void 0) { buffer = null; }
  58701. if (this.url) {
  58702. this.releaseInternalTexture();
  58703. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58704. }
  58705. this.url = url;
  58706. this._buffer = buffer;
  58707. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58708. if (onLoad) {
  58709. this._delayedOnLoad = onLoad;
  58710. }
  58711. this.delayLoad();
  58712. };
  58713. /**
  58714. * Finish the loading sequence of a texture flagged as delayed load.
  58715. * @hidden
  58716. */
  58717. Texture.prototype.delayLoad = function () {
  58718. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58719. return;
  58720. }
  58721. var scene = this.getScene();
  58722. if (!scene) {
  58723. return;
  58724. }
  58725. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58726. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  58727. if (!this._texture) {
  58728. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  58729. if (this._deleteBuffer) {
  58730. delete this._buffer;
  58731. }
  58732. }
  58733. else {
  58734. if (this._delayedOnLoad) {
  58735. if (this._texture.isReady) {
  58736. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  58737. }
  58738. else {
  58739. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  58740. }
  58741. }
  58742. }
  58743. this._delayedOnLoad = null;
  58744. this._delayedOnError = null;
  58745. };
  58746. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  58747. x *= this.uScale;
  58748. y *= this.vScale;
  58749. x -= this.uRotationCenter * this.uScale;
  58750. y -= this.vRotationCenter * this.vScale;
  58751. z -= this.wRotationCenter;
  58752. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  58753. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  58754. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  58755. t.z += this.wRotationCenter;
  58756. };
  58757. /**
  58758. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  58759. * @returns the transform matrix of the texture.
  58760. */
  58761. Texture.prototype.getTextureMatrix = function () {
  58762. var _this = this;
  58763. if (this.uOffset === this._cachedUOffset &&
  58764. this.vOffset === this._cachedVOffset &&
  58765. this.uScale === this._cachedUScale &&
  58766. this.vScale === this._cachedVScale &&
  58767. this.uAng === this._cachedUAng &&
  58768. this.vAng === this._cachedVAng &&
  58769. this.wAng === this._cachedWAng) {
  58770. return this._cachedTextureMatrix;
  58771. }
  58772. this._cachedUOffset = this.uOffset;
  58773. this._cachedVOffset = this.vOffset;
  58774. this._cachedUScale = this.uScale;
  58775. this._cachedVScale = this.vScale;
  58776. this._cachedUAng = this.uAng;
  58777. this._cachedVAng = this.vAng;
  58778. this._cachedWAng = this.wAng;
  58779. if (!this._cachedTextureMatrix) {
  58780. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58781. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  58782. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58783. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58784. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58785. }
  58786. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  58787. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  58788. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  58789. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  58790. this._t1.subtractInPlace(this._t0);
  58791. this._t2.subtractInPlace(this._t0);
  58792. _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);
  58793. var scene = this.getScene();
  58794. if (!scene) {
  58795. return this._cachedTextureMatrix;
  58796. }
  58797. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58798. return mat.hasTexture(_this);
  58799. });
  58800. return this._cachedTextureMatrix;
  58801. };
  58802. /**
  58803. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  58804. * @returns The reflection texture transform
  58805. */
  58806. Texture.prototype.getReflectionTextureMatrix = function () {
  58807. var _this = this;
  58808. var scene = this.getScene();
  58809. if (!scene) {
  58810. return this._cachedTextureMatrix;
  58811. }
  58812. if (this.uOffset === this._cachedUOffset &&
  58813. this.vOffset === this._cachedVOffset &&
  58814. this.uScale === this._cachedUScale &&
  58815. this.vScale === this._cachedVScale &&
  58816. this.coordinatesMode === this._cachedCoordinatesMode) {
  58817. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  58818. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  58819. return this._cachedTextureMatrix;
  58820. }
  58821. }
  58822. else {
  58823. return this._cachedTextureMatrix;
  58824. }
  58825. }
  58826. if (!this._cachedTextureMatrix) {
  58827. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58828. }
  58829. if (!this._projectionModeMatrix) {
  58830. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58831. }
  58832. this._cachedUOffset = this.uOffset;
  58833. this._cachedVOffset = this.vOffset;
  58834. this._cachedUScale = this.uScale;
  58835. this._cachedVScale = this.vScale;
  58836. this._cachedCoordinatesMode = this.coordinatesMode;
  58837. switch (this.coordinatesMode) {
  58838. case Texture.PLANAR_MODE:
  58839. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58840. this._cachedTextureMatrix[0] = this.uScale;
  58841. this._cachedTextureMatrix[5] = this.vScale;
  58842. this._cachedTextureMatrix[12] = this.uOffset;
  58843. this._cachedTextureMatrix[13] = this.vOffset;
  58844. break;
  58845. case Texture.PROJECTION_MODE:
  58846. _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);
  58847. var projectionMatrix = scene.getProjectionMatrix();
  58848. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  58849. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  58850. break;
  58851. default:
  58852. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58853. break;
  58854. }
  58855. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58856. return (mat.getActiveTextures().indexOf(_this) !== -1);
  58857. });
  58858. return this._cachedTextureMatrix;
  58859. };
  58860. /**
  58861. * Clones the texture.
  58862. * @returns the cloned texture
  58863. */
  58864. Texture.prototype.clone = function () {
  58865. var _this = this;
  58866. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58867. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  58868. }, this);
  58869. };
  58870. /**
  58871. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58872. * @returns The JSON representation of the texture
  58873. */
  58874. Texture.prototype.serialize = function () {
  58875. var serializationObject = _super.prototype.serialize.call(this);
  58876. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  58877. serializationObject.base64String = this._buffer;
  58878. serializationObject.name = serializationObject.name.replace("data:", "");
  58879. }
  58880. serializationObject.invertY = this._invertY;
  58881. serializationObject.samplingMode = this.samplingMode;
  58882. return serializationObject;
  58883. };
  58884. /**
  58885. * Get the current class name of the texture useful for serialization or dynamic coding.
  58886. * @returns "Texture"
  58887. */
  58888. Texture.prototype.getClassName = function () {
  58889. return "Texture";
  58890. };
  58891. /**
  58892. * Dispose the texture and release its associated resources.
  58893. */
  58894. Texture.prototype.dispose = function () {
  58895. _super.prototype.dispose.call(this);
  58896. this.onLoadObservable.clear();
  58897. this._delayedOnLoad = null;
  58898. this._delayedOnError = null;
  58899. };
  58900. /**
  58901. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  58902. * @param parsedTexture Define the JSON representation of the texture
  58903. * @param scene Define the scene the parsed texture should be instantiated in
  58904. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58905. * @returns The parsed texture if successful
  58906. */
  58907. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  58908. if (parsedTexture.customType) {
  58909. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  58910. // Update Sampling Mode
  58911. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  58912. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  58913. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  58914. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  58915. }
  58916. }
  58917. return parsedCustomTexture;
  58918. }
  58919. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  58920. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  58921. }
  58922. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  58923. return null;
  58924. }
  58925. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58926. var generateMipMaps = true;
  58927. if (parsedTexture.noMipmap) {
  58928. generateMipMaps = false;
  58929. }
  58930. if (parsedTexture.mirrorPlane) {
  58931. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58932. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  58933. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  58934. return mirrorTexture;
  58935. }
  58936. else if (parsedTexture.isRenderTarget) {
  58937. var renderTargetTexture = null;
  58938. if (parsedTexture.isCube) {
  58939. // Search for an existing reflection probe (which contains a cube render target texture)
  58940. if (scene.reflectionProbes) {
  58941. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  58942. var probe = scene.reflectionProbes[index];
  58943. if (probe.name === parsedTexture.name) {
  58944. return probe.cubeTexture;
  58945. }
  58946. }
  58947. }
  58948. }
  58949. else {
  58950. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58951. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  58952. }
  58953. return renderTargetTexture;
  58954. }
  58955. else {
  58956. var texture;
  58957. if (parsedTexture.base64String) {
  58958. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  58959. }
  58960. else {
  58961. var url = rootUrl + parsedTexture.name;
  58962. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  58963. url = parsedTexture.url;
  58964. }
  58965. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  58966. }
  58967. return texture;
  58968. }
  58969. }, parsedTexture, scene);
  58970. // Update Sampling Mode
  58971. if (parsedTexture.samplingMode) {
  58972. var sampling = parsedTexture.samplingMode;
  58973. if (texture && texture.samplingMode !== sampling) {
  58974. texture.updateSamplingMode(sampling);
  58975. }
  58976. }
  58977. // Animations
  58978. if (texture && parsedTexture.animations) {
  58979. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58980. var parsedAnimation = parsedTexture.animations[animationIndex];
  58981. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58982. if (internalClass) {
  58983. texture.animations.push(internalClass.Parse(parsedAnimation));
  58984. }
  58985. }
  58986. }
  58987. return texture;
  58988. };
  58989. /**
  58990. * Creates a texture from its base 64 representation.
  58991. * @param data Define the base64 payload without the data: prefix
  58992. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58993. * @param scene Define the scene the texture should belong to
  58994. * @param noMipmap Forces the texture to not create mip map information if true
  58995. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58996. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58997. * @param onLoad define a callback triggered when the texture has been loaded
  58998. * @param onError define a callback triggered when an error occurred during the loading session
  58999. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  59000. * @returns the created texture
  59001. */
  59002. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  59003. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59004. if (onLoad === void 0) { onLoad = null; }
  59005. if (onError === void 0) { onError = null; }
  59006. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59007. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  59008. };
  59009. /**
  59010. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  59011. * @param data Define the base64 payload without the data: prefix
  59012. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  59013. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  59014. * @param scene Define the scene the texture should belong to
  59015. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  59016. * @param noMipmap Forces the texture to not create mip map information if true
  59017. * @param invertY define if the texture needs to be inverted on the y axis during loading
  59018. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  59019. * @param onLoad define a callback triggered when the texture has been loaded
  59020. * @param onError define a callback triggered when an error occurred during the loading session
  59021. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  59022. * @returns the created texture
  59023. */
  59024. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  59025. if (deleteBuffer === void 0) { deleteBuffer = false; }
  59026. if (noMipmap === void 0) { noMipmap = false; }
  59027. if (invertY === void 0) { invertY = true; }
  59028. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59029. if (onLoad === void 0) { onLoad = null; }
  59030. if (onError === void 0) { onError = null; }
  59031. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59032. if (name.substr(0, 5) !== "data:") {
  59033. name = "data:" + name;
  59034. }
  59035. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  59036. };
  59037. /** @hidden */
  59038. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  59039. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  59040. };
  59041. /** @hidden */
  59042. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  59043. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  59044. };
  59045. /** @hidden */
  59046. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  59047. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  59048. };
  59049. /** nearest is mag = nearest and min = nearest and mip = linear */
  59050. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  59051. /** nearest is mag = nearest and min = nearest and mip = linear */
  59052. 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
  59053. /** Bilinear is mag = linear and min = linear and mip = nearest */
  59054. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  59055. /** Bilinear is mag = linear and min = linear and mip = nearest */
  59056. 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
  59057. /** Trilinear is mag = linear and min = linear and mip = linear */
  59058. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  59059. /** Trilinear is mag = linear and min = linear and mip = linear */
  59060. 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
  59061. /** mag = nearest and min = nearest and mip = nearest */
  59062. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  59063. /** mag = nearest and min = linear and mip = nearest */
  59064. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  59065. /** mag = nearest and min = linear and mip = linear */
  59066. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  59067. /** mag = nearest and min = linear and mip = none */
  59068. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  59069. /** mag = nearest and min = nearest and mip = none */
  59070. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  59071. /** mag = linear and min = nearest and mip = nearest */
  59072. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  59073. /** mag = linear and min = nearest and mip = linear */
  59074. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  59075. /** mag = linear and min = linear and mip = none */
  59076. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  59077. /** mag = linear and min = nearest and mip = none */
  59078. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  59079. /** Explicit coordinates mode */
  59080. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  59081. /** Spherical coordinates mode */
  59082. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  59083. /** Planar coordinates mode */
  59084. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  59085. /** Cubic coordinates mode */
  59086. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  59087. /** Projection coordinates mode */
  59088. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  59089. /** Inverse Cubic coordinates mode */
  59090. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  59091. /** Inverse Cubic coordinates mode */
  59092. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  59093. /** Equirectangular coordinates mode */
  59094. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  59095. /** Equirectangular Fixed coordinates mode */
  59096. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  59097. /** Equirectangular Fixed Mirrored coordinates mode */
  59098. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  59099. /** Texture is not repeating outside of 0..1 UVs */
  59100. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  59101. /** Texture is repeating outside of 0..1 UVs */
  59102. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  59103. /** Texture is repeating and mirrored */
  59104. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  59105. /**
  59106. * 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
  59107. */
  59108. Texture.UseSerializedUrlIfAny = false;
  59109. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59110. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59111. ], Texture.prototype, "url", void 0);
  59112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59114. ], Texture.prototype, "uOffset", void 0);
  59115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59117. ], Texture.prototype, "vOffset", void 0);
  59118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59120. ], Texture.prototype, "uScale", void 0);
  59121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59123. ], Texture.prototype, "vScale", void 0);
  59124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59126. ], Texture.prototype, "uAng", void 0);
  59127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59129. ], Texture.prototype, "vAng", void 0);
  59130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59132. ], Texture.prototype, "wAng", void 0);
  59133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59135. ], Texture.prototype, "uRotationCenter", void 0);
  59136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59138. ], Texture.prototype, "vRotationCenter", void 0);
  59139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59141. ], Texture.prototype, "wRotationCenter", void 0);
  59142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59144. ], Texture.prototype, "isBlocking", null);
  59145. return Texture;
  59146. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  59147. // References the dependencies.
  59148. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  59149. /***/ }),
  59150. /***/ "./Materials/Textures/videoTexture.ts":
  59151. /*!********************************************!*\
  59152. !*** ./Materials/Textures/videoTexture.ts ***!
  59153. \********************************************/
  59154. /*! exports provided: VideoTexture */
  59155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59156. "use strict";
  59157. __webpack_require__.r(__webpack_exports__);
  59158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  59159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59160. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59161. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59162. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  59163. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59164. /**
  59165. * If you want to display a video in your scene, this is the special texture for that.
  59166. * This special texture works similar to other textures, with the exception of a few parameters.
  59167. * @see https://doc.babylonjs.com/how_to/video_texture
  59168. */
  59169. var VideoTexture = /** @class */ (function (_super) {
  59170. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  59171. /**
  59172. * Creates a video texture.
  59173. * If you want to display a video in your scene, this is the special texture for that.
  59174. * This special texture works similar to other textures, with the exception of a few parameters.
  59175. * @see https://doc.babylonjs.com/how_to/video_texture
  59176. * @param name optional name, will detect from video source, if not defined
  59177. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  59178. * @param scene is obviously the current scene.
  59179. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  59180. * @param invertY is false by default but can be used to invert video on Y axis
  59181. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  59182. * @param settings allows finer control over video usage
  59183. */
  59184. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  59185. if (generateMipMaps === void 0) { generateMipMaps = false; }
  59186. if (invertY === void 0) { invertY = false; }
  59187. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59188. if (settings === void 0) { settings = {
  59189. autoPlay: true,
  59190. loop: true,
  59191. autoUpdateTexture: true,
  59192. }; }
  59193. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59194. _this._onUserActionRequestedObservable = null;
  59195. _this._stillImageCaptured = false;
  59196. _this._displayingPosterTexture = false;
  59197. _this._createInternalTexture = function () {
  59198. if (_this._texture != null) {
  59199. if (_this._displayingPosterTexture) {
  59200. _this._texture.dispose();
  59201. _this._displayingPosterTexture = false;
  59202. }
  59203. else {
  59204. return;
  59205. }
  59206. }
  59207. if (!_this._engine.needPOTTextures ||
  59208. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  59209. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59210. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59211. }
  59212. else {
  59213. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59214. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59215. _this._generateMipMaps = false;
  59216. }
  59217. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  59218. if (!_this.video.autoplay && !_this._settings.poster) {
  59219. var oldHandler_1 = _this.video.onplaying;
  59220. var error_1 = false;
  59221. _this.video.onplaying = function () {
  59222. _this.video.onplaying = oldHandler_1;
  59223. _this._texture.isReady = true;
  59224. _this._updateInternalTexture();
  59225. if (!error_1) {
  59226. _this.video.pause();
  59227. }
  59228. if (_this.onLoadObservable.hasObservers()) {
  59229. _this.onLoadObservable.notifyObservers(_this);
  59230. }
  59231. };
  59232. var playing = _this.video.play();
  59233. if (playing) {
  59234. playing.then(function () {
  59235. // Everything is good.
  59236. })
  59237. .catch(function () {
  59238. error_1 = true;
  59239. // On Chrome for instance, new policies might prevent playing without user interaction.
  59240. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  59241. _this._onUserActionRequestedObservable.notifyObservers(_this);
  59242. }
  59243. });
  59244. }
  59245. else {
  59246. _this.video.onplaying = oldHandler_1;
  59247. _this._texture.isReady = true;
  59248. _this._updateInternalTexture();
  59249. if (_this.onLoadObservable.hasObservers()) {
  59250. _this.onLoadObservable.notifyObservers(_this);
  59251. }
  59252. }
  59253. }
  59254. else {
  59255. _this._texture.isReady = true;
  59256. _this._updateInternalTexture();
  59257. if (_this.onLoadObservable.hasObservers()) {
  59258. _this.onLoadObservable.notifyObservers(_this);
  59259. }
  59260. }
  59261. };
  59262. _this.reset = function () {
  59263. if (_this._texture == null) {
  59264. return;
  59265. }
  59266. if (!_this._displayingPosterTexture) {
  59267. _this._texture.dispose();
  59268. _this._texture = null;
  59269. }
  59270. };
  59271. _this._updateInternalTexture = function () {
  59272. if (_this._texture == null || !_this._texture.isReady) {
  59273. return;
  59274. }
  59275. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  59276. return;
  59277. }
  59278. if (_this._displayingPosterTexture) {
  59279. return;
  59280. }
  59281. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  59282. };
  59283. _this._engine = _this.getScene().getEngine();
  59284. _this._generateMipMaps = generateMipMaps;
  59285. _this._initialSamplingMode = samplingMode;
  59286. _this.autoUpdateTexture = settings.autoUpdateTexture;
  59287. _this.name = name || _this._getName(src);
  59288. _this.video = _this._getVideo(src);
  59289. _this._settings = settings;
  59290. if (settings.poster) {
  59291. _this.video.poster = settings.poster;
  59292. }
  59293. if (settings.autoPlay !== undefined) {
  59294. _this.video.autoplay = settings.autoPlay;
  59295. }
  59296. if (settings.loop !== undefined) {
  59297. _this.video.loop = settings.loop;
  59298. }
  59299. _this.video.setAttribute("playsinline", "");
  59300. _this.video.addEventListener("paused", _this._updateInternalTexture);
  59301. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  59302. _this.video.addEventListener("emptied", _this.reset);
  59303. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  59304. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  59305. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  59306. if (settings.poster &&
  59307. (!settings.autoPlay || !videoHasEnoughData)) {
  59308. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  59309. _this._displayingPosterTexture = true;
  59310. }
  59311. else if (videoHasEnoughData) {
  59312. _this._createInternalTexture();
  59313. }
  59314. return _this;
  59315. }
  59316. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  59317. /**
  59318. * Event triggerd when a dom action is required by the user to play the video.
  59319. * This happens due to recent changes in browser policies preventing video to auto start.
  59320. */
  59321. get: function () {
  59322. if (!this._onUserActionRequestedObservable) {
  59323. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59324. }
  59325. return this._onUserActionRequestedObservable;
  59326. },
  59327. enumerable: true,
  59328. configurable: true
  59329. });
  59330. VideoTexture.prototype._getName = function (src) {
  59331. if (src instanceof HTMLVideoElement) {
  59332. return src.currentSrc;
  59333. }
  59334. if (typeof src === "object") {
  59335. return src.toString();
  59336. }
  59337. return src;
  59338. };
  59339. VideoTexture.prototype._getVideo = function (src) {
  59340. if (src instanceof HTMLVideoElement) {
  59341. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  59342. return src;
  59343. }
  59344. var video = document.createElement("video");
  59345. if (typeof src === "string") {
  59346. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  59347. video.src = src;
  59348. }
  59349. else {
  59350. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  59351. src.forEach(function (url) {
  59352. var source = document.createElement("source");
  59353. source.src = url;
  59354. video.appendChild(source);
  59355. });
  59356. }
  59357. return video;
  59358. };
  59359. /**
  59360. * @hidden Internal method to initiate `update`.
  59361. */
  59362. VideoTexture.prototype._rebuild = function () {
  59363. this.update();
  59364. };
  59365. /**
  59366. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  59367. */
  59368. VideoTexture.prototype.update = function () {
  59369. if (!this.autoUpdateTexture) {
  59370. // Expecting user to call `updateTexture` manually
  59371. return;
  59372. }
  59373. this.updateTexture(true);
  59374. };
  59375. /**
  59376. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  59377. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  59378. */
  59379. VideoTexture.prototype.updateTexture = function (isVisible) {
  59380. if (!isVisible) {
  59381. return;
  59382. }
  59383. if (this.video.paused && this._stillImageCaptured) {
  59384. return;
  59385. }
  59386. this._stillImageCaptured = true;
  59387. this._updateInternalTexture();
  59388. };
  59389. /**
  59390. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  59391. * @param url New url.
  59392. */
  59393. VideoTexture.prototype.updateURL = function (url) {
  59394. this.video.src = url;
  59395. };
  59396. /**
  59397. * Dispose the texture and release its associated resources.
  59398. */
  59399. VideoTexture.prototype.dispose = function () {
  59400. _super.prototype.dispose.call(this);
  59401. if (this._onUserActionRequestedObservable) {
  59402. this._onUserActionRequestedObservable.clear();
  59403. this._onUserActionRequestedObservable = null;
  59404. }
  59405. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  59406. this.video.removeEventListener("paused", this._updateInternalTexture);
  59407. this.video.removeEventListener("seeked", this._updateInternalTexture);
  59408. this.video.removeEventListener("emptied", this.reset);
  59409. this.video.pause();
  59410. };
  59411. /**
  59412. * Creates a video texture straight from your WebCam video feed.
  59413. * @param scene Define the scene the texture should be created in
  59414. * @param onReady Define a callback to triggered once the texture will be ready
  59415. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  59416. */
  59417. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  59418. var video = document.createElement("video");
  59419. video.setAttribute('autoplay', '');
  59420. video.setAttribute('muted', '');
  59421. video.setAttribute('playsinline', '');
  59422. var constraintsDeviceId;
  59423. if (constraints && constraints.deviceId) {
  59424. constraintsDeviceId = {
  59425. exact: constraints.deviceId,
  59426. };
  59427. }
  59428. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  59429. if (navigator.mediaDevices) {
  59430. navigator.mediaDevices.getUserMedia({ video: constraints })
  59431. .then(function (stream) {
  59432. if (video.mozSrcObject !== undefined) {
  59433. // hack for Firefox < 19
  59434. video.mozSrcObject = stream;
  59435. }
  59436. else {
  59437. video.srcObject = stream;
  59438. }
  59439. var onPlaying = function () {
  59440. if (onReady) {
  59441. onReady(new VideoTexture("video", video, scene, true, true));
  59442. }
  59443. video.removeEventListener("playing", onPlaying);
  59444. };
  59445. video.addEventListener("playing", onPlaying);
  59446. video.play();
  59447. })
  59448. .catch(function (err) {
  59449. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  59450. });
  59451. }
  59452. else {
  59453. navigator.getUserMedia =
  59454. navigator.getUserMedia ||
  59455. navigator.webkitGetUserMedia ||
  59456. navigator.mozGetUserMedia ||
  59457. navigator.msGetUserMedia;
  59458. if (navigator.getUserMedia) {
  59459. navigator.getUserMedia({
  59460. video: {
  59461. deviceId: constraintsDeviceId,
  59462. width: {
  59463. min: (constraints && constraints.minWidth) || 256,
  59464. max: (constraints && constraints.maxWidth) || 640,
  59465. },
  59466. height: {
  59467. min: (constraints && constraints.minHeight) || 256,
  59468. max: (constraints && constraints.maxHeight) || 480,
  59469. },
  59470. },
  59471. }, function (stream) {
  59472. if (video.mozSrcObject !== undefined) {
  59473. // hack for Firefox < 19
  59474. video.mozSrcObject = stream;
  59475. }
  59476. else {
  59477. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  59478. }
  59479. video.play();
  59480. if (onReady) {
  59481. onReady(new VideoTexture("video", video, scene, true, true));
  59482. }
  59483. }, function (e) {
  59484. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  59485. });
  59486. }
  59487. }
  59488. };
  59489. return VideoTexture;
  59490. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  59491. /***/ }),
  59492. /***/ "./Materials/colorCurves.ts":
  59493. /*!**********************************!*\
  59494. !*** ./Materials/colorCurves.ts ***!
  59495. \**********************************/
  59496. /*! exports provided: ColorCurves */
  59497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59498. "use strict";
  59499. __webpack_require__.r(__webpack_exports__);
  59500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  59501. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59502. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  59503. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  59504. /**
  59505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59507. * 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;
  59508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59509. */
  59510. var ColorCurves = /** @class */ (function () {
  59511. function ColorCurves() {
  59512. this._dirty = true;
  59513. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59514. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59515. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59516. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59517. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59518. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59519. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59520. this._globalHue = 30;
  59521. this._globalDensity = 0;
  59522. this._globalSaturation = 0;
  59523. this._globalExposure = 0;
  59524. this._highlightsHue = 30;
  59525. this._highlightsDensity = 0;
  59526. this._highlightsSaturation = 0;
  59527. this._highlightsExposure = 0;
  59528. this._midtonesHue = 30;
  59529. this._midtonesDensity = 0;
  59530. this._midtonesSaturation = 0;
  59531. this._midtonesExposure = 0;
  59532. this._shadowsHue = 30;
  59533. this._shadowsDensity = 0;
  59534. this._shadowsSaturation = 0;
  59535. this._shadowsExposure = 0;
  59536. }
  59537. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  59538. /**
  59539. * Gets the global Hue value.
  59540. * 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).
  59541. */
  59542. get: function () {
  59543. return this._globalHue;
  59544. },
  59545. /**
  59546. * Sets the global Hue value.
  59547. * 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).
  59548. */
  59549. set: function (value) {
  59550. this._globalHue = value;
  59551. this._dirty = true;
  59552. },
  59553. enumerable: true,
  59554. configurable: true
  59555. });
  59556. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  59557. /**
  59558. * Gets the global Density value.
  59559. * 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.
  59560. * Values less than zero provide a filter of opposite hue.
  59561. */
  59562. get: function () {
  59563. return this._globalDensity;
  59564. },
  59565. /**
  59566. * Sets the global Density value.
  59567. * 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.
  59568. * Values less than zero provide a filter of opposite hue.
  59569. */
  59570. set: function (value) {
  59571. this._globalDensity = value;
  59572. this._dirty = true;
  59573. },
  59574. enumerable: true,
  59575. configurable: true
  59576. });
  59577. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  59578. /**
  59579. * Gets the global Saturation value.
  59580. * 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.
  59581. */
  59582. get: function () {
  59583. return this._globalSaturation;
  59584. },
  59585. /**
  59586. * Sets the global Saturation value.
  59587. * 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.
  59588. */
  59589. set: function (value) {
  59590. this._globalSaturation = value;
  59591. this._dirty = true;
  59592. },
  59593. enumerable: true,
  59594. configurable: true
  59595. });
  59596. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  59597. /**
  59598. * Gets the global Exposure value.
  59599. * 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.
  59600. */
  59601. get: function () {
  59602. return this._globalExposure;
  59603. },
  59604. /**
  59605. * Sets the global Exposure value.
  59606. * 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.
  59607. */
  59608. set: function (value) {
  59609. this._globalExposure = value;
  59610. this._dirty = true;
  59611. },
  59612. enumerable: true,
  59613. configurable: true
  59614. });
  59615. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  59616. /**
  59617. * Gets the highlights Hue value.
  59618. * 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).
  59619. */
  59620. get: function () {
  59621. return this._highlightsHue;
  59622. },
  59623. /**
  59624. * Sets the highlights Hue value.
  59625. * 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).
  59626. */
  59627. set: function (value) {
  59628. this._highlightsHue = value;
  59629. this._dirty = true;
  59630. },
  59631. enumerable: true,
  59632. configurable: true
  59633. });
  59634. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  59635. /**
  59636. * Gets the highlights Density value.
  59637. * 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.
  59638. * Values less than zero provide a filter of opposite hue.
  59639. */
  59640. get: function () {
  59641. return this._highlightsDensity;
  59642. },
  59643. /**
  59644. * Sets the highlights Density value.
  59645. * 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.
  59646. * Values less than zero provide a filter of opposite hue.
  59647. */
  59648. set: function (value) {
  59649. this._highlightsDensity = value;
  59650. this._dirty = true;
  59651. },
  59652. enumerable: true,
  59653. configurable: true
  59654. });
  59655. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  59656. /**
  59657. * Gets the highlights Saturation value.
  59658. * 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.
  59659. */
  59660. get: function () {
  59661. return this._highlightsSaturation;
  59662. },
  59663. /**
  59664. * Sets the highlights Saturation value.
  59665. * 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.
  59666. */
  59667. set: function (value) {
  59668. this._highlightsSaturation = value;
  59669. this._dirty = true;
  59670. },
  59671. enumerable: true,
  59672. configurable: true
  59673. });
  59674. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  59675. /**
  59676. * Gets the highlights Exposure value.
  59677. * 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.
  59678. */
  59679. get: function () {
  59680. return this._highlightsExposure;
  59681. },
  59682. /**
  59683. * Sets the highlights Exposure value.
  59684. * 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.
  59685. */
  59686. set: function (value) {
  59687. this._highlightsExposure = value;
  59688. this._dirty = true;
  59689. },
  59690. enumerable: true,
  59691. configurable: true
  59692. });
  59693. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  59694. /**
  59695. * Gets the midtones Hue value.
  59696. * 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).
  59697. */
  59698. get: function () {
  59699. return this._midtonesHue;
  59700. },
  59701. /**
  59702. * Sets the midtones Hue value.
  59703. * 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).
  59704. */
  59705. set: function (value) {
  59706. this._midtonesHue = value;
  59707. this._dirty = true;
  59708. },
  59709. enumerable: true,
  59710. configurable: true
  59711. });
  59712. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  59713. /**
  59714. * Gets the midtones Density value.
  59715. * 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.
  59716. * Values less than zero provide a filter of opposite hue.
  59717. */
  59718. get: function () {
  59719. return this._midtonesDensity;
  59720. },
  59721. /**
  59722. * Sets the midtones Density value.
  59723. * 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.
  59724. * Values less than zero provide a filter of opposite hue.
  59725. */
  59726. set: function (value) {
  59727. this._midtonesDensity = value;
  59728. this._dirty = true;
  59729. },
  59730. enumerable: true,
  59731. configurable: true
  59732. });
  59733. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  59734. /**
  59735. * Gets the midtones Saturation value.
  59736. * 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.
  59737. */
  59738. get: function () {
  59739. return this._midtonesSaturation;
  59740. },
  59741. /**
  59742. * Sets the midtones Saturation value.
  59743. * 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.
  59744. */
  59745. set: function (value) {
  59746. this._midtonesSaturation = value;
  59747. this._dirty = true;
  59748. },
  59749. enumerable: true,
  59750. configurable: true
  59751. });
  59752. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  59753. /**
  59754. * Gets the midtones Exposure value.
  59755. * 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.
  59756. */
  59757. get: function () {
  59758. return this._midtonesExposure;
  59759. },
  59760. /**
  59761. * Sets the midtones Exposure value.
  59762. * 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.
  59763. */
  59764. set: function (value) {
  59765. this._midtonesExposure = value;
  59766. this._dirty = true;
  59767. },
  59768. enumerable: true,
  59769. configurable: true
  59770. });
  59771. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  59772. /**
  59773. * Gets the shadows Hue value.
  59774. * 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).
  59775. */
  59776. get: function () {
  59777. return this._shadowsHue;
  59778. },
  59779. /**
  59780. * Sets the shadows Hue value.
  59781. * 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).
  59782. */
  59783. set: function (value) {
  59784. this._shadowsHue = value;
  59785. this._dirty = true;
  59786. },
  59787. enumerable: true,
  59788. configurable: true
  59789. });
  59790. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  59791. /**
  59792. * Gets the shadows Density value.
  59793. * 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.
  59794. * Values less than zero provide a filter of opposite hue.
  59795. */
  59796. get: function () {
  59797. return this._shadowsDensity;
  59798. },
  59799. /**
  59800. * Sets the shadows Density value.
  59801. * 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.
  59802. * Values less than zero provide a filter of opposite hue.
  59803. */
  59804. set: function (value) {
  59805. this._shadowsDensity = value;
  59806. this._dirty = true;
  59807. },
  59808. enumerable: true,
  59809. configurable: true
  59810. });
  59811. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  59812. /**
  59813. * Gets the shadows Saturation value.
  59814. * 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.
  59815. */
  59816. get: function () {
  59817. return this._shadowsSaturation;
  59818. },
  59819. /**
  59820. * Sets the shadows Saturation value.
  59821. * 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.
  59822. */
  59823. set: function (value) {
  59824. this._shadowsSaturation = value;
  59825. this._dirty = true;
  59826. },
  59827. enumerable: true,
  59828. configurable: true
  59829. });
  59830. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  59831. /**
  59832. * Gets the shadows Exposure value.
  59833. * 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.
  59834. */
  59835. get: function () {
  59836. return this._shadowsExposure;
  59837. },
  59838. /**
  59839. * Sets the shadows Exposure value.
  59840. * 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.
  59841. */
  59842. set: function (value) {
  59843. this._shadowsExposure = value;
  59844. this._dirty = true;
  59845. },
  59846. enumerable: true,
  59847. configurable: true
  59848. });
  59849. /**
  59850. * Returns the class name
  59851. * @returns The class name
  59852. */
  59853. ColorCurves.prototype.getClassName = function () {
  59854. return "ColorCurves";
  59855. };
  59856. /**
  59857. * Binds the color curves to the shader.
  59858. * @param colorCurves The color curve to bind
  59859. * @param effect The effect to bind to
  59860. * @param positiveUniform The positive uniform shader parameter
  59861. * @param neutralUniform The neutral uniform shader parameter
  59862. * @param negativeUniform The negative uniform shader parameter
  59863. */
  59864. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  59865. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  59866. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  59867. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  59868. if (colorCurves._dirty) {
  59869. colorCurves._dirty = false;
  59870. // Fill in global info.
  59871. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  59872. // Compute highlights info.
  59873. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  59874. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  59875. // Compute midtones info.
  59876. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  59877. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  59878. // Compute shadows info.
  59879. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  59880. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  59881. // Compute deltas (neutral is midtones).
  59882. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  59883. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  59884. }
  59885. if (effect) {
  59886. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  59887. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  59888. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  59889. }
  59890. };
  59891. /**
  59892. * Prepare the list of uniforms associated with the ColorCurves effects.
  59893. * @param uniformsList The list of uniforms used in the effect
  59894. */
  59895. ColorCurves.PrepareUniforms = function (uniformsList) {
  59896. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  59897. };
  59898. /**
  59899. * Returns color grading data based on a hue, density, saturation and exposure value.
  59900. * @param filterHue The hue of the color filter.
  59901. * @param filterDensity The density of the color filter.
  59902. * @param saturation The saturation.
  59903. * @param exposure The exposure.
  59904. * @param result The result data container.
  59905. */
  59906. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  59907. if (hue == null) {
  59908. return;
  59909. }
  59910. hue = ColorCurves.clamp(hue, 0, 360);
  59911. density = ColorCurves.clamp(density, -100, 100);
  59912. saturation = ColorCurves.clamp(saturation, -100, 100);
  59913. exposure = ColorCurves.clamp(exposure, -100, 100);
  59914. // Remap the slider/config filter density with non-linear mapping and also scale by half
  59915. // so that the maximum filter density is only 50% control. This provides fine control
  59916. // for small values and reasonable range.
  59917. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  59918. density *= 0.5;
  59919. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  59920. if (density < 0) {
  59921. density *= -1;
  59922. hue = (hue + 180) % 360;
  59923. }
  59924. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  59925. result.scaleToRef(2, result);
  59926. result.a = 1 + 0.01 * saturation;
  59927. };
  59928. /**
  59929. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  59930. * @param value The input slider value in range [-100,100].
  59931. * @returns Adjusted value.
  59932. */
  59933. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  59934. value /= 100;
  59935. var x = Math.abs(value);
  59936. x = Math.pow(x, 2);
  59937. if (value < 0) {
  59938. x *= -1;
  59939. }
  59940. x *= 100;
  59941. return x;
  59942. };
  59943. /**
  59944. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  59945. * @param hue The hue (H) input.
  59946. * @param saturation The saturation (S) input.
  59947. * @param brightness The brightness (B) input.
  59948. * @result An RGBA color represented as Vector4.
  59949. */
  59950. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  59951. var h = ColorCurves.clamp(hue, 0, 360);
  59952. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  59953. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  59954. if (s === 0) {
  59955. result.r = v;
  59956. result.g = v;
  59957. result.b = v;
  59958. }
  59959. else {
  59960. // sector 0 to 5
  59961. h /= 60;
  59962. var i = Math.floor(h);
  59963. // fractional part of h
  59964. var f = h - i;
  59965. var p = v * (1 - s);
  59966. var q = v * (1 - s * f);
  59967. var t = v * (1 - s * (1 - f));
  59968. switch (i) {
  59969. case 0:
  59970. result.r = v;
  59971. result.g = t;
  59972. result.b = p;
  59973. break;
  59974. case 1:
  59975. result.r = q;
  59976. result.g = v;
  59977. result.b = p;
  59978. break;
  59979. case 2:
  59980. result.r = p;
  59981. result.g = v;
  59982. result.b = t;
  59983. break;
  59984. case 3:
  59985. result.r = p;
  59986. result.g = q;
  59987. result.b = v;
  59988. break;
  59989. case 4:
  59990. result.r = t;
  59991. result.g = p;
  59992. result.b = v;
  59993. break;
  59994. default: // case 5:
  59995. result.r = v;
  59996. result.g = p;
  59997. result.b = q;
  59998. break;
  59999. }
  60000. }
  60001. result.a = 1;
  60002. };
  60003. /**
  60004. * Returns a value clamped between min and max
  60005. * @param value The value to clamp
  60006. * @param min The minimum of value
  60007. * @param max The maximum of value
  60008. * @returns The clamped value.
  60009. */
  60010. ColorCurves.clamp = function (value, min, max) {
  60011. return Math.min(Math.max(value, min), max);
  60012. };
  60013. /**
  60014. * Clones the current color curve instance.
  60015. * @return The cloned curves
  60016. */
  60017. ColorCurves.prototype.clone = function () {
  60018. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  60019. };
  60020. /**
  60021. * Serializes the current color curve instance to a json representation.
  60022. * @return a JSON representation
  60023. */
  60024. ColorCurves.prototype.serialize = function () {
  60025. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  60026. };
  60027. /**
  60028. * Parses the color curve from a json representation.
  60029. * @param source the JSON source to parse
  60030. * @return The parsed curves
  60031. */
  60032. ColorCurves.Parse = function (source) {
  60033. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  60034. };
  60035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60037. ], ColorCurves.prototype, "_globalHue", void 0);
  60038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60040. ], ColorCurves.prototype, "_globalDensity", void 0);
  60041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60043. ], ColorCurves.prototype, "_globalSaturation", void 0);
  60044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60046. ], ColorCurves.prototype, "_globalExposure", void 0);
  60047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60049. ], ColorCurves.prototype, "_highlightsHue", void 0);
  60050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60052. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  60053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60055. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  60056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60058. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  60059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60061. ], ColorCurves.prototype, "_midtonesHue", void 0);
  60062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60064. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  60065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60067. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  60068. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60070. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  60071. return ColorCurves;
  60072. }());
  60073. // References the dependencies.
  60074. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  60075. /***/ }),
  60076. /***/ "./Materials/effect.ts":
  60077. /*!*****************************!*\
  60078. !*** ./Materials/effect.ts ***!
  60079. \*****************************/
  60080. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  60081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60082. "use strict";
  60083. __webpack_require__.r(__webpack_exports__);
  60084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  60085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  60086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  60087. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  60088. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  60089. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  60090. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  60091. /**
  60092. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  60093. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  60094. */
  60095. var EffectFallbacks = /** @class */ (function () {
  60096. function EffectFallbacks() {
  60097. this._defines = {};
  60098. this._currentRank = 32;
  60099. this._maxRank = -1;
  60100. }
  60101. /**
  60102. * Removes the fallback from the bound mesh.
  60103. */
  60104. EffectFallbacks.prototype.unBindMesh = function () {
  60105. this._mesh = null;
  60106. };
  60107. /**
  60108. * Adds a fallback on the specified property.
  60109. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60110. * @param define The name of the define in the shader
  60111. */
  60112. EffectFallbacks.prototype.addFallback = function (rank, define) {
  60113. if (!this._defines[rank]) {
  60114. if (rank < this._currentRank) {
  60115. this._currentRank = rank;
  60116. }
  60117. if (rank > this._maxRank) {
  60118. this._maxRank = rank;
  60119. }
  60120. this._defines[rank] = new Array();
  60121. }
  60122. this._defines[rank].push(define);
  60123. };
  60124. /**
  60125. * Sets the mesh to use CPU skinning when needing to fallback.
  60126. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60127. * @param mesh The mesh to use the fallbacks.
  60128. */
  60129. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  60130. this._mesh = mesh;
  60131. if (rank < this._currentRank) {
  60132. this._currentRank = rank;
  60133. }
  60134. if (rank > this._maxRank) {
  60135. this._maxRank = rank;
  60136. }
  60137. };
  60138. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  60139. /**
  60140. * Checks to see if more fallbacks are still availible.
  60141. */
  60142. get: function () {
  60143. return this._currentRank <= this._maxRank;
  60144. },
  60145. enumerable: true,
  60146. configurable: true
  60147. });
  60148. /**
  60149. * Removes the defines that shoould be removed when falling back.
  60150. * @param currentDefines defines the current define statements for the shader.
  60151. * @param effect defines the current effect we try to compile
  60152. * @returns The resulting defines with defines of the current rank removed.
  60153. */
  60154. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  60155. // First we try to switch to CPU skinning
  60156. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  60157. this._mesh.computeBonesUsingShaders = false;
  60158. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  60159. effect._bonesComputationForcedToCPU = true;
  60160. var scene = this._mesh.getScene();
  60161. for (var index = 0; index < scene.meshes.length; index++) {
  60162. var otherMesh = scene.meshes[index];
  60163. if (!otherMesh.material) {
  60164. continue;
  60165. }
  60166. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  60167. continue;
  60168. }
  60169. if (otherMesh.material.getEffect() === effect) {
  60170. otherMesh.computeBonesUsingShaders = false;
  60171. }
  60172. else if (otherMesh.subMeshes) {
  60173. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  60174. var subMesh = _a[_i];
  60175. var subMeshEffect = subMesh.effect;
  60176. if (subMeshEffect === effect) {
  60177. otherMesh.computeBonesUsingShaders = false;
  60178. break;
  60179. }
  60180. }
  60181. }
  60182. }
  60183. }
  60184. else {
  60185. var currentFallbacks = this._defines[this._currentRank];
  60186. if (currentFallbacks) {
  60187. for (var index = 0; index < currentFallbacks.length; index++) {
  60188. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  60189. }
  60190. }
  60191. this._currentRank++;
  60192. }
  60193. return currentDefines;
  60194. };
  60195. return EffectFallbacks;
  60196. }());
  60197. /**
  60198. * Options to be used when creating an effect.
  60199. */
  60200. var EffectCreationOptions = /** @class */ (function () {
  60201. function EffectCreationOptions() {
  60202. }
  60203. return EffectCreationOptions;
  60204. }());
  60205. /**
  60206. * Effect containing vertex and fragment shader that can be executed on an object.
  60207. */
  60208. var Effect = /** @class */ (function () {
  60209. /**
  60210. * Instantiates an effect.
  60211. * An effect can be used to create/manage/execute vertex and fragment shaders.
  60212. * @param baseName Name of the effect.
  60213. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  60214. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  60215. * @param samplers List of sampler variables that will be passed to the shader.
  60216. * @param engine Engine to be used to render the effect
  60217. * @param defines Define statements to be added to the shader.
  60218. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  60219. * @param onCompiled Callback that will be called when the shader is compiled.
  60220. * @param onError Callback that will be called if an error occurs during shader compilation.
  60221. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  60222. */
  60223. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  60224. if (samplers === void 0) { samplers = null; }
  60225. if (defines === void 0) { defines = null; }
  60226. if (fallbacks === void 0) { fallbacks = null; }
  60227. if (onCompiled === void 0) { onCompiled = null; }
  60228. if (onError === void 0) { onError = null; }
  60229. var _this = this;
  60230. /**
  60231. * Unique ID of the effect.
  60232. */
  60233. this.uniqueId = 0;
  60234. /**
  60235. * Observable that will be called when the shader is compiled.
  60236. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  60237. */
  60238. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60239. /**
  60240. * Observable that will be called if an error occurs during shader compilation.
  60241. */
  60242. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60243. /** @hidden */
  60244. this._bonesComputationForcedToCPU = false;
  60245. this._uniformBuffersNames = {};
  60246. this._isReady = false;
  60247. this._compilationError = "";
  60248. this.name = baseName;
  60249. if (attributesNamesOrOptions.attributes) {
  60250. var options = attributesNamesOrOptions;
  60251. this._engine = uniformsNamesOrEngine;
  60252. this._attributesNames = options.attributes;
  60253. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  60254. this._samplers = options.samplers.slice();
  60255. this.defines = options.defines;
  60256. this.onError = options.onError;
  60257. this.onCompiled = options.onCompiled;
  60258. this._fallbacks = options.fallbacks;
  60259. this._indexParameters = options.indexParameters;
  60260. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  60261. if (options.uniformBuffersNames) {
  60262. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  60263. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  60264. }
  60265. }
  60266. }
  60267. else {
  60268. this._engine = engine;
  60269. this.defines = defines;
  60270. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  60271. this._samplers = samplers ? samplers.slice() : [];
  60272. this._attributesNames = attributesNamesOrOptions;
  60273. this.onError = onError;
  60274. this.onCompiled = onCompiled;
  60275. this._indexParameters = indexParameters;
  60276. this._fallbacks = fallbacks;
  60277. }
  60278. this.uniqueId = Effect._uniqueIdSeed++;
  60279. var vertexSource;
  60280. var fragmentSource;
  60281. if (baseName.vertexElement) {
  60282. vertexSource = document.getElementById(baseName.vertexElement);
  60283. if (!vertexSource) {
  60284. vertexSource = baseName.vertexElement;
  60285. }
  60286. }
  60287. else {
  60288. vertexSource = baseName.vertex || baseName;
  60289. }
  60290. if (baseName.fragmentElement) {
  60291. fragmentSource = document.getElementById(baseName.fragmentElement);
  60292. if (!fragmentSource) {
  60293. fragmentSource = baseName.fragmentElement;
  60294. }
  60295. }
  60296. else {
  60297. fragmentSource = baseName.fragment || baseName;
  60298. }
  60299. this._loadVertexShader(vertexSource, function (vertexCode) {
  60300. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  60301. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  60302. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  60303. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  60304. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  60305. if (baseName) {
  60306. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  60307. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  60308. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  60309. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  60310. }
  60311. else {
  60312. _this._vertexSourceCode = migratedVertexCode;
  60313. _this._fragmentSourceCode = migratedFragmentCode;
  60314. }
  60315. _this._prepareEffect();
  60316. });
  60317. });
  60318. });
  60319. });
  60320. });
  60321. });
  60322. }
  60323. Object.defineProperty(Effect.prototype, "onBindObservable", {
  60324. /**
  60325. * Observable that will be called when effect is bound.
  60326. */
  60327. get: function () {
  60328. if (!this._onBindObservable) {
  60329. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60330. }
  60331. return this._onBindObservable;
  60332. },
  60333. enumerable: true,
  60334. configurable: true
  60335. });
  60336. Object.defineProperty(Effect.prototype, "key", {
  60337. /**
  60338. * Unique key for this effect
  60339. */
  60340. get: function () {
  60341. return this._key;
  60342. },
  60343. enumerable: true,
  60344. configurable: true
  60345. });
  60346. /**
  60347. * If the effect has been compiled and prepared.
  60348. * @returns if the effect is compiled and prepared.
  60349. */
  60350. Effect.prototype.isReady = function () {
  60351. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  60352. return this._engine._isProgramCompiled(this._program);
  60353. }
  60354. return this._isReady;
  60355. };
  60356. /**
  60357. * The engine the effect was initialized with.
  60358. * @returns the engine.
  60359. */
  60360. Effect.prototype.getEngine = function () {
  60361. return this._engine;
  60362. };
  60363. /**
  60364. * The compiled webGL program for the effect
  60365. * @returns the webGL program.
  60366. */
  60367. Effect.prototype.getProgram = function () {
  60368. return this._program;
  60369. };
  60370. /**
  60371. * The set of names of attribute variables for the shader.
  60372. * @returns An array of attribute names.
  60373. */
  60374. Effect.prototype.getAttributesNames = function () {
  60375. return this._attributesNames;
  60376. };
  60377. /**
  60378. * Returns the attribute at the given index.
  60379. * @param index The index of the attribute.
  60380. * @returns The location of the attribute.
  60381. */
  60382. Effect.prototype.getAttributeLocation = function (index) {
  60383. return this._attributes[index];
  60384. };
  60385. /**
  60386. * Returns the attribute based on the name of the variable.
  60387. * @param name of the attribute to look up.
  60388. * @returns the attribute location.
  60389. */
  60390. Effect.prototype.getAttributeLocationByName = function (name) {
  60391. var index = this._attributesNames.indexOf(name);
  60392. return this._attributes[index];
  60393. };
  60394. /**
  60395. * The number of attributes.
  60396. * @returns the numnber of attributes.
  60397. */
  60398. Effect.prototype.getAttributesCount = function () {
  60399. return this._attributes.length;
  60400. };
  60401. /**
  60402. * Gets the index of a uniform variable.
  60403. * @param uniformName of the uniform to look up.
  60404. * @returns the index.
  60405. */
  60406. Effect.prototype.getUniformIndex = function (uniformName) {
  60407. return this._uniformsNames.indexOf(uniformName);
  60408. };
  60409. /**
  60410. * Returns the attribute based on the name of the variable.
  60411. * @param uniformName of the uniform to look up.
  60412. * @returns the location of the uniform.
  60413. */
  60414. Effect.prototype.getUniform = function (uniformName) {
  60415. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  60416. };
  60417. /**
  60418. * Returns an array of sampler variable names
  60419. * @returns The array of sampler variable neames.
  60420. */
  60421. Effect.prototype.getSamplers = function () {
  60422. return this._samplers;
  60423. };
  60424. /**
  60425. * The error from the last compilation.
  60426. * @returns the error string.
  60427. */
  60428. Effect.prototype.getCompilationError = function () {
  60429. return this._compilationError;
  60430. };
  60431. /**
  60432. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  60433. * @param func The callback to be used.
  60434. */
  60435. Effect.prototype.executeWhenCompiled = function (func) {
  60436. var _this = this;
  60437. if (this.isReady()) {
  60438. func(this);
  60439. return;
  60440. }
  60441. this.onCompileObservable.add(function (effect) {
  60442. func(effect);
  60443. });
  60444. if (!this._program || this._program.isParallelCompiled) {
  60445. setTimeout(function () {
  60446. _this._checkIsReady();
  60447. }, 16);
  60448. }
  60449. };
  60450. Effect.prototype._checkIsReady = function () {
  60451. var _this = this;
  60452. if (this.isReady()) {
  60453. return;
  60454. }
  60455. setTimeout(function () {
  60456. _this._checkIsReady();
  60457. }, 16);
  60458. };
  60459. /** @hidden */
  60460. Effect.prototype._loadVertexShader = function (vertex, callback) {
  60461. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60462. // DOM element ?
  60463. if (vertex instanceof HTMLElement) {
  60464. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  60465. callback(vertexCode);
  60466. return;
  60467. }
  60468. }
  60469. // Base64 encoded ?
  60470. if (vertex.substr(0, 7) === "base64:") {
  60471. var vertexBinary = window.atob(vertex.substr(7));
  60472. callback(vertexBinary);
  60473. return;
  60474. }
  60475. // Is in local store ?
  60476. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  60477. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  60478. return;
  60479. }
  60480. var vertexShaderUrl;
  60481. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  60482. vertexShaderUrl = vertex;
  60483. }
  60484. else {
  60485. vertexShaderUrl = Effect.ShadersRepository + vertex;
  60486. }
  60487. // Vertex shader
  60488. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  60489. };
  60490. /** @hidden */
  60491. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  60492. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60493. // DOM element ?
  60494. if (fragment instanceof HTMLElement) {
  60495. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  60496. callback(fragmentCode);
  60497. return;
  60498. }
  60499. }
  60500. // Base64 encoded ?
  60501. if (fragment.substr(0, 7) === "base64:") {
  60502. var fragmentBinary = window.atob(fragment.substr(7));
  60503. callback(fragmentBinary);
  60504. return;
  60505. }
  60506. // Is in local store ?
  60507. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  60508. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  60509. return;
  60510. }
  60511. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  60512. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  60513. return;
  60514. }
  60515. var fragmentShaderUrl;
  60516. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  60517. fragmentShaderUrl = fragment;
  60518. }
  60519. else {
  60520. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  60521. }
  60522. // Fragment shader
  60523. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  60524. };
  60525. /** @hidden */
  60526. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  60527. // Rebuild shaders source code
  60528. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  60529. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  60530. vertexCode = prefix + vertexCode;
  60531. fragmentCode = prefix + fragmentCode;
  60532. // Number lines of shaders source code
  60533. var i = 2;
  60534. var regex = /\n/gm;
  60535. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60536. i = 2;
  60537. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60538. // Dump shaders name and formatted source code
  60539. if (this.name.vertexElement) {
  60540. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  60541. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  60542. }
  60543. else if (this.name.vertex) {
  60544. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  60545. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  60546. }
  60547. else {
  60548. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  60549. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  60550. }
  60551. };
  60552. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  60553. var preparedSourceCode = this._processPrecision(sourceCode);
  60554. if (this._engine.webGLVersion == 1) {
  60555. callback(preparedSourceCode);
  60556. return;
  60557. }
  60558. // Already converted
  60559. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  60560. callback(preparedSourceCode.replace("#version 300 es", ""));
  60561. return;
  60562. }
  60563. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  60564. // Remove extensions
  60565. // #extension GL_OES_standard_derivatives : enable
  60566. // #extension GL_EXT_shader_texture_lod : enable
  60567. // #extension GL_EXT_frag_depth : enable
  60568. // #extension GL_EXT_draw_buffers : require
  60569. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  60570. var result = preparedSourceCode.replace(regex, "");
  60571. // Migrate to GLSL v300
  60572. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  60573. result = result.replace(/attribute[ \t]/g, "in ");
  60574. result = result.replace(/[ \t]attribute/g, " in");
  60575. result = result.replace(/texture2D\s*\(/g, "texture(");
  60576. if (isFragment) {
  60577. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  60578. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  60579. result = result.replace(/textureCube\s*\(/g, "texture(");
  60580. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  60581. result = result.replace(/gl_FragColor/g, "glFragColor");
  60582. result = result.replace(/gl_FragData/g, "glFragData");
  60583. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  60584. }
  60585. callback(result);
  60586. };
  60587. Effect.prototype._processIncludes = function (sourceCode, callback) {
  60588. var _this = this;
  60589. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  60590. var match = regex.exec(sourceCode);
  60591. var returnValue = new String(sourceCode);
  60592. while (match != null) {
  60593. var includeFile = match[1];
  60594. // Uniform declaration
  60595. if (includeFile.indexOf("__decl__") !== -1) {
  60596. includeFile = includeFile.replace(/__decl__/, "");
  60597. if (this._engine.supportsUniformBuffers) {
  60598. includeFile = includeFile.replace(/Vertex/, "Ubo");
  60599. includeFile = includeFile.replace(/Fragment/, "Ubo");
  60600. }
  60601. includeFile = includeFile + "Declaration";
  60602. }
  60603. if (Effect.IncludesShadersStore[includeFile]) {
  60604. // Substitution
  60605. var includeContent = Effect.IncludesShadersStore[includeFile];
  60606. if (match[2]) {
  60607. var splits = match[3].split(",");
  60608. for (var index = 0; index < splits.length; index += 2) {
  60609. var source = new RegExp(splits[index], "g");
  60610. var dest = splits[index + 1];
  60611. includeContent = includeContent.replace(source, dest);
  60612. }
  60613. }
  60614. if (match[4]) {
  60615. var indexString = match[5];
  60616. if (indexString.indexOf("..") !== -1) {
  60617. var indexSplits = indexString.split("..");
  60618. var minIndex = parseInt(indexSplits[0]);
  60619. var maxIndex = parseInt(indexSplits[1]);
  60620. var sourceIncludeContent = includeContent.slice(0);
  60621. includeContent = "";
  60622. if (isNaN(maxIndex)) {
  60623. maxIndex = this._indexParameters[indexSplits[1]];
  60624. }
  60625. for (var i = minIndex; i < maxIndex; i++) {
  60626. if (!this._engine.supportsUniformBuffers) {
  60627. // Ubo replacement
  60628. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60629. return p1 + "{X}";
  60630. });
  60631. }
  60632. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  60633. }
  60634. }
  60635. else {
  60636. if (!this._engine.supportsUniformBuffers) {
  60637. // Ubo replacement
  60638. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60639. return p1 + "{X}";
  60640. });
  60641. }
  60642. includeContent = includeContent.replace(/\{X\}/g, indexString);
  60643. }
  60644. }
  60645. // Replace
  60646. returnValue = returnValue.replace(match[0], includeContent);
  60647. }
  60648. else {
  60649. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  60650. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  60651. Effect.IncludesShadersStore[includeFile] = fileContent;
  60652. _this._processIncludes(returnValue, callback);
  60653. });
  60654. return;
  60655. }
  60656. match = regex.exec(sourceCode);
  60657. }
  60658. callback(returnValue);
  60659. };
  60660. Effect.prototype._processPrecision = function (source) {
  60661. if (source.indexOf("precision highp float") === -1) {
  60662. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  60663. source = "precision mediump float;\n" + source;
  60664. }
  60665. else {
  60666. source = "precision highp float;\n" + source;
  60667. }
  60668. }
  60669. else {
  60670. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  60671. source = source.replace("precision highp float", "precision mediump float");
  60672. }
  60673. }
  60674. return source;
  60675. };
  60676. /**
  60677. * Recompiles the webGL program
  60678. * @param vertexSourceCode The source code for the vertex shader.
  60679. * @param fragmentSourceCode The source code for the fragment shader.
  60680. * @param onCompiled Callback called when completed.
  60681. * @param onError Callback called on error.
  60682. * @hidden
  60683. */
  60684. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  60685. var _this = this;
  60686. this._isReady = false;
  60687. this._vertexSourceCodeOverride = vertexSourceCode;
  60688. this._fragmentSourceCodeOverride = fragmentSourceCode;
  60689. this.onError = function (effect, error) {
  60690. if (onError) {
  60691. onError(error);
  60692. }
  60693. };
  60694. this.onCompiled = function () {
  60695. var scenes = _this.getEngine().scenes;
  60696. for (var i = 0; i < scenes.length; i++) {
  60697. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  60698. }
  60699. if (onCompiled) {
  60700. onCompiled(_this._program);
  60701. }
  60702. };
  60703. this._fallbacks = null;
  60704. this._prepareEffect();
  60705. };
  60706. /**
  60707. * Gets the uniform locations of the the specified variable names
  60708. * @param names THe names of the variables to lookup.
  60709. * @returns Array of locations in the same order as variable names.
  60710. */
  60711. Effect.prototype.getSpecificUniformLocations = function (names) {
  60712. var engine = this._engine;
  60713. return engine.getUniforms(this._program, names);
  60714. };
  60715. /**
  60716. * Prepares the effect
  60717. * @hidden
  60718. */
  60719. Effect.prototype._prepareEffect = function () {
  60720. var _this = this;
  60721. var attributesNames = this._attributesNames;
  60722. var defines = this.defines;
  60723. var fallbacks = this._fallbacks;
  60724. this._valueCache = {};
  60725. var previousProgram = this._program;
  60726. try {
  60727. var engine_1 = this._engine;
  60728. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  60729. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  60730. }
  60731. else {
  60732. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  60733. }
  60734. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  60735. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  60736. if (engine_1.supportsUniformBuffers) {
  60737. for (var name in _this._uniformBuffersNames) {
  60738. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  60739. }
  60740. }
  60741. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  60742. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  60743. var index;
  60744. for (index = 0; index < _this._samplers.length; index++) {
  60745. var sampler = _this.getUniform(_this._samplers[index]);
  60746. if (sampler == null) {
  60747. _this._samplers.splice(index, 1);
  60748. index--;
  60749. }
  60750. }
  60751. engine_1.bindSamplers(_this);
  60752. _this._compilationError = "";
  60753. _this._isReady = true;
  60754. if (_this.onCompiled) {
  60755. _this.onCompiled(_this);
  60756. }
  60757. _this.onCompileObservable.notifyObservers(_this);
  60758. _this.onCompileObservable.clear();
  60759. // Unbind mesh reference in fallbacks
  60760. if (_this._fallbacks) {
  60761. _this._fallbacks.unBindMesh();
  60762. }
  60763. if (previousProgram) {
  60764. _this.getEngine()._deleteProgram(previousProgram);
  60765. }
  60766. });
  60767. if (this._program.isParallelCompiled) {
  60768. this._checkIsReady();
  60769. }
  60770. }
  60771. catch (e) {
  60772. this._compilationError = e.message;
  60773. // Let's go through fallbacks then
  60774. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  60775. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  60776. return " " + uniform;
  60777. }));
  60778. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  60779. return " " + attribute;
  60780. }));
  60781. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  60782. if (previousProgram) {
  60783. this._program = previousProgram;
  60784. this._isReady = true;
  60785. if (this.onError) {
  60786. this.onError(this, this._compilationError);
  60787. }
  60788. this.onErrorObservable.notifyObservers(this);
  60789. }
  60790. if (fallbacks && fallbacks.isMoreFallbacks) {
  60791. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  60792. this.defines = fallbacks.reduce(this.defines, this);
  60793. this._prepareEffect();
  60794. }
  60795. else { // Sorry we did everything we can
  60796. if (this.onError) {
  60797. this.onError(this, this._compilationError);
  60798. }
  60799. this.onErrorObservable.notifyObservers(this);
  60800. this.onErrorObservable.clear();
  60801. // Unbind mesh reference in fallbacks
  60802. if (this._fallbacks) {
  60803. this._fallbacks.unBindMesh();
  60804. }
  60805. }
  60806. }
  60807. };
  60808. Object.defineProperty(Effect.prototype, "isSupported", {
  60809. /**
  60810. * Checks if the effect is supported. (Must be called after compilation)
  60811. */
  60812. get: function () {
  60813. return this._compilationError === "";
  60814. },
  60815. enumerable: true,
  60816. configurable: true
  60817. });
  60818. /**
  60819. * Binds a texture to the engine to be used as output of the shader.
  60820. * @param channel Name of the output variable.
  60821. * @param texture Texture to bind.
  60822. * @hidden
  60823. */
  60824. Effect.prototype._bindTexture = function (channel, texture) {
  60825. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  60826. };
  60827. /**
  60828. * Sets a texture on the engine to be used in the shader.
  60829. * @param channel Name of the sampler variable.
  60830. * @param texture Texture to set.
  60831. */
  60832. Effect.prototype.setTexture = function (channel, texture) {
  60833. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60834. };
  60835. /**
  60836. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  60837. * @param channel Name of the sampler variable.
  60838. * @param texture Texture to set.
  60839. */
  60840. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  60841. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60842. };
  60843. /**
  60844. * Sets an array of textures on the engine to be used in the shader.
  60845. * @param channel Name of the variable.
  60846. * @param textures Textures to set.
  60847. */
  60848. Effect.prototype.setTextureArray = function (channel, textures) {
  60849. if (this._samplers.indexOf(channel + "Ex") === -1) {
  60850. var initialPos = this._samplers.indexOf(channel);
  60851. for (var index = 1; index < textures.length; index++) {
  60852. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  60853. }
  60854. }
  60855. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  60856. };
  60857. /**
  60858. * 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)
  60859. * @param channel Name of the sampler variable.
  60860. * @param postProcess Post process to get the input texture from.
  60861. */
  60862. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  60863. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  60864. };
  60865. /**
  60866. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  60867. * 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)
  60868. * @param channel Name of the sampler variable.
  60869. * @param postProcess Post process to get the output texture from.
  60870. */
  60871. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  60872. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  60873. };
  60874. /** @hidden */
  60875. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  60876. var cache = this._valueCache[uniformName];
  60877. var flag = matrix.updateFlag;
  60878. if (cache !== undefined && cache === flag) {
  60879. return false;
  60880. }
  60881. this._valueCache[uniformName] = flag;
  60882. return true;
  60883. };
  60884. /** @hidden */
  60885. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  60886. var cache = this._valueCache[uniformName];
  60887. if (!cache) {
  60888. cache = [x, y];
  60889. this._valueCache[uniformName] = cache;
  60890. return true;
  60891. }
  60892. var changed = false;
  60893. if (cache[0] !== x) {
  60894. cache[0] = x;
  60895. changed = true;
  60896. }
  60897. if (cache[1] !== y) {
  60898. cache[1] = y;
  60899. changed = true;
  60900. }
  60901. return changed;
  60902. };
  60903. /** @hidden */
  60904. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  60905. var cache = this._valueCache[uniformName];
  60906. if (!cache) {
  60907. cache = [x, y, z];
  60908. this._valueCache[uniformName] = cache;
  60909. return true;
  60910. }
  60911. var changed = false;
  60912. if (cache[0] !== x) {
  60913. cache[0] = x;
  60914. changed = true;
  60915. }
  60916. if (cache[1] !== y) {
  60917. cache[1] = y;
  60918. changed = true;
  60919. }
  60920. if (cache[2] !== z) {
  60921. cache[2] = z;
  60922. changed = true;
  60923. }
  60924. return changed;
  60925. };
  60926. /** @hidden */
  60927. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  60928. var cache = this._valueCache[uniformName];
  60929. if (!cache) {
  60930. cache = [x, y, z, w];
  60931. this._valueCache[uniformName] = cache;
  60932. return true;
  60933. }
  60934. var changed = false;
  60935. if (cache[0] !== x) {
  60936. cache[0] = x;
  60937. changed = true;
  60938. }
  60939. if (cache[1] !== y) {
  60940. cache[1] = y;
  60941. changed = true;
  60942. }
  60943. if (cache[2] !== z) {
  60944. cache[2] = z;
  60945. changed = true;
  60946. }
  60947. if (cache[3] !== w) {
  60948. cache[3] = w;
  60949. changed = true;
  60950. }
  60951. return changed;
  60952. };
  60953. /**
  60954. * Binds a buffer to a uniform.
  60955. * @param buffer Buffer to bind.
  60956. * @param name Name of the uniform variable to bind to.
  60957. */
  60958. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  60959. var bufferName = this._uniformBuffersNames[name];
  60960. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  60961. return;
  60962. }
  60963. Effect._baseCache[bufferName] = buffer;
  60964. this._engine.bindUniformBufferBase(buffer, bufferName);
  60965. };
  60966. /**
  60967. * Binds block to a uniform.
  60968. * @param blockName Name of the block to bind.
  60969. * @param index Index to bind.
  60970. */
  60971. Effect.prototype.bindUniformBlock = function (blockName, index) {
  60972. this._engine.bindUniformBlock(this._program, blockName, index);
  60973. };
  60974. /**
  60975. * Sets an interger value on a uniform variable.
  60976. * @param uniformName Name of the variable.
  60977. * @param value Value to be set.
  60978. * @returns this effect.
  60979. */
  60980. Effect.prototype.setInt = function (uniformName, value) {
  60981. var cache = this._valueCache[uniformName];
  60982. if (cache !== undefined && cache === value) {
  60983. return this;
  60984. }
  60985. this._valueCache[uniformName] = value;
  60986. this._engine.setInt(this.getUniform(uniformName), value);
  60987. return this;
  60988. };
  60989. /**
  60990. * Sets an int array on a uniform variable.
  60991. * @param uniformName Name of the variable.
  60992. * @param array array to be set.
  60993. * @returns this effect.
  60994. */
  60995. Effect.prototype.setIntArray = function (uniformName, array) {
  60996. this._valueCache[uniformName] = null;
  60997. this._engine.setIntArray(this.getUniform(uniformName), array);
  60998. return this;
  60999. };
  61000. /**
  61001. * 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)
  61002. * @param uniformName Name of the variable.
  61003. * @param array array to be set.
  61004. * @returns this effect.
  61005. */
  61006. Effect.prototype.setIntArray2 = function (uniformName, array) {
  61007. this._valueCache[uniformName] = null;
  61008. this._engine.setIntArray2(this.getUniform(uniformName), array);
  61009. return this;
  61010. };
  61011. /**
  61012. * 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)
  61013. * @param uniformName Name of the variable.
  61014. * @param array array to be set.
  61015. * @returns this effect.
  61016. */
  61017. Effect.prototype.setIntArray3 = function (uniformName, array) {
  61018. this._valueCache[uniformName] = null;
  61019. this._engine.setIntArray3(this.getUniform(uniformName), array);
  61020. return this;
  61021. };
  61022. /**
  61023. * 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)
  61024. * @param uniformName Name of the variable.
  61025. * @param array array to be set.
  61026. * @returns this effect.
  61027. */
  61028. Effect.prototype.setIntArray4 = function (uniformName, array) {
  61029. this._valueCache[uniformName] = null;
  61030. this._engine.setIntArray4(this.getUniform(uniformName), array);
  61031. return this;
  61032. };
  61033. /**
  61034. * Sets an float array on a uniform variable.
  61035. * @param uniformName Name of the variable.
  61036. * @param array array to be set.
  61037. * @returns this effect.
  61038. */
  61039. Effect.prototype.setFloatArray = function (uniformName, array) {
  61040. this._valueCache[uniformName] = null;
  61041. this._engine.setFloatArray(this.getUniform(uniformName), array);
  61042. return this;
  61043. };
  61044. /**
  61045. * 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)
  61046. * @param uniformName Name of the variable.
  61047. * @param array array to be set.
  61048. * @returns this effect.
  61049. */
  61050. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  61051. this._valueCache[uniformName] = null;
  61052. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  61053. return this;
  61054. };
  61055. /**
  61056. * 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)
  61057. * @param uniformName Name of the variable.
  61058. * @param array array to be set.
  61059. * @returns this effect.
  61060. */
  61061. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  61062. this._valueCache[uniformName] = null;
  61063. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  61064. return this;
  61065. };
  61066. /**
  61067. * 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)
  61068. * @param uniformName Name of the variable.
  61069. * @param array array to be set.
  61070. * @returns this effect.
  61071. */
  61072. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  61073. this._valueCache[uniformName] = null;
  61074. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  61075. return this;
  61076. };
  61077. /**
  61078. * Sets an array on a uniform variable.
  61079. * @param uniformName Name of the variable.
  61080. * @param array array to be set.
  61081. * @returns this effect.
  61082. */
  61083. Effect.prototype.setArray = function (uniformName, array) {
  61084. this._valueCache[uniformName] = null;
  61085. this._engine.setArray(this.getUniform(uniformName), array);
  61086. return this;
  61087. };
  61088. /**
  61089. * 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)
  61090. * @param uniformName Name of the variable.
  61091. * @param array array to be set.
  61092. * @returns this effect.
  61093. */
  61094. Effect.prototype.setArray2 = function (uniformName, array) {
  61095. this._valueCache[uniformName] = null;
  61096. this._engine.setArray2(this.getUniform(uniformName), array);
  61097. return this;
  61098. };
  61099. /**
  61100. * 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)
  61101. * @param uniformName Name of the variable.
  61102. * @param array array to be set.
  61103. * @returns this effect.
  61104. */
  61105. Effect.prototype.setArray3 = function (uniformName, array) {
  61106. this._valueCache[uniformName] = null;
  61107. this._engine.setArray3(this.getUniform(uniformName), array);
  61108. return this;
  61109. };
  61110. /**
  61111. * 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)
  61112. * @param uniformName Name of the variable.
  61113. * @param array array to be set.
  61114. * @returns this effect.
  61115. */
  61116. Effect.prototype.setArray4 = function (uniformName, array) {
  61117. this._valueCache[uniformName] = null;
  61118. this._engine.setArray4(this.getUniform(uniformName), array);
  61119. return this;
  61120. };
  61121. /**
  61122. * Sets matrices on a uniform variable.
  61123. * @param uniformName Name of the variable.
  61124. * @param matrices matrices to be set.
  61125. * @returns this effect.
  61126. */
  61127. Effect.prototype.setMatrices = function (uniformName, matrices) {
  61128. if (!matrices) {
  61129. return this;
  61130. }
  61131. this._valueCache[uniformName] = null;
  61132. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  61133. return this;
  61134. };
  61135. /**
  61136. * Sets matrix on a uniform variable.
  61137. * @param uniformName Name of the variable.
  61138. * @param matrix matrix to be set.
  61139. * @returns this effect.
  61140. */
  61141. Effect.prototype.setMatrix = function (uniformName, matrix) {
  61142. if (this._cacheMatrix(uniformName, matrix)) {
  61143. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  61144. }
  61145. return this;
  61146. };
  61147. /**
  61148. * 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)
  61149. * @param uniformName Name of the variable.
  61150. * @param matrix matrix to be set.
  61151. * @returns this effect.
  61152. */
  61153. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  61154. this._valueCache[uniformName] = null;
  61155. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  61156. return this;
  61157. };
  61158. /**
  61159. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  61160. * @param uniformName Name of the variable.
  61161. * @param matrix matrix to be set.
  61162. * @returns this effect.
  61163. */
  61164. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  61165. this._valueCache[uniformName] = null;
  61166. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  61167. return this;
  61168. };
  61169. /**
  61170. * Sets a float on a uniform variable.
  61171. * @param uniformName Name of the variable.
  61172. * @param value value to be set.
  61173. * @returns this effect.
  61174. */
  61175. Effect.prototype.setFloat = function (uniformName, value) {
  61176. var cache = this._valueCache[uniformName];
  61177. if (cache !== undefined && cache === value) {
  61178. return this;
  61179. }
  61180. this._valueCache[uniformName] = value;
  61181. this._engine.setFloat(this.getUniform(uniformName), value);
  61182. return this;
  61183. };
  61184. /**
  61185. * Sets a boolean on a uniform variable.
  61186. * @param uniformName Name of the variable.
  61187. * @param bool value to be set.
  61188. * @returns this effect.
  61189. */
  61190. Effect.prototype.setBool = function (uniformName, bool) {
  61191. var cache = this._valueCache[uniformName];
  61192. if (cache !== undefined && cache === bool) {
  61193. return this;
  61194. }
  61195. this._valueCache[uniformName] = bool;
  61196. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  61197. return this;
  61198. };
  61199. /**
  61200. * Sets a Vector2 on a uniform variable.
  61201. * @param uniformName Name of the variable.
  61202. * @param vector2 vector2 to be set.
  61203. * @returns this effect.
  61204. */
  61205. Effect.prototype.setVector2 = function (uniformName, vector2) {
  61206. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  61207. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  61208. }
  61209. return this;
  61210. };
  61211. /**
  61212. * Sets a float2 on a uniform variable.
  61213. * @param uniformName Name of the variable.
  61214. * @param x First float in float2.
  61215. * @param y Second float in float2.
  61216. * @returns this effect.
  61217. */
  61218. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  61219. if (this._cacheFloat2(uniformName, x, y)) {
  61220. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  61221. }
  61222. return this;
  61223. };
  61224. /**
  61225. * Sets a Vector3 on a uniform variable.
  61226. * @param uniformName Name of the variable.
  61227. * @param vector3 Value to be set.
  61228. * @returns this effect.
  61229. */
  61230. Effect.prototype.setVector3 = function (uniformName, vector3) {
  61231. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  61232. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  61233. }
  61234. return this;
  61235. };
  61236. /**
  61237. * Sets a float3 on a uniform variable.
  61238. * @param uniformName Name of the variable.
  61239. * @param x First float in float3.
  61240. * @param y Second float in float3.
  61241. * @param z Third float in float3.
  61242. * @returns this effect.
  61243. */
  61244. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  61245. if (this._cacheFloat3(uniformName, x, y, z)) {
  61246. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  61247. }
  61248. return this;
  61249. };
  61250. /**
  61251. * Sets a Vector4 on a uniform variable.
  61252. * @param uniformName Name of the variable.
  61253. * @param vector4 Value to be set.
  61254. * @returns this effect.
  61255. */
  61256. Effect.prototype.setVector4 = function (uniformName, vector4) {
  61257. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  61258. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  61259. }
  61260. return this;
  61261. };
  61262. /**
  61263. * Sets a float4 on a uniform variable.
  61264. * @param uniformName Name of the variable.
  61265. * @param x First float in float4.
  61266. * @param y Second float in float4.
  61267. * @param z Third float in float4.
  61268. * @param w Fourth float in float4.
  61269. * @returns this effect.
  61270. */
  61271. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  61272. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  61273. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  61274. }
  61275. return this;
  61276. };
  61277. /**
  61278. * Sets a Color3 on a uniform variable.
  61279. * @param uniformName Name of the variable.
  61280. * @param color3 Value to be set.
  61281. * @returns this effect.
  61282. */
  61283. Effect.prototype.setColor3 = function (uniformName, color3) {
  61284. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  61285. this._engine.setColor3(this.getUniform(uniformName), color3);
  61286. }
  61287. return this;
  61288. };
  61289. /**
  61290. * Sets a Color4 on a uniform variable.
  61291. * @param uniformName Name of the variable.
  61292. * @param color3 Value to be set.
  61293. * @param alpha Alpha value to be set.
  61294. * @returns this effect.
  61295. */
  61296. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  61297. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  61298. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  61299. }
  61300. return this;
  61301. };
  61302. /**
  61303. * Sets a Color4 on a uniform variable
  61304. * @param uniformName defines the name of the variable
  61305. * @param color4 defines the value to be set
  61306. * @returns this effect.
  61307. */
  61308. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  61309. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  61310. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  61311. }
  61312. return this;
  61313. };
  61314. /**
  61315. * This function will add a new shader to the shader store
  61316. * @param name the name of the shader
  61317. * @param pixelShader optional pixel shader content
  61318. * @param vertexShader optional vertex shader content
  61319. */
  61320. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  61321. if (pixelShader) {
  61322. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  61323. }
  61324. if (vertexShader) {
  61325. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  61326. }
  61327. };
  61328. /**
  61329. * Resets the cache of effects.
  61330. */
  61331. Effect.ResetCache = function () {
  61332. Effect._baseCache = {};
  61333. };
  61334. /**
  61335. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  61336. */
  61337. Effect.ShadersRepository = "src/Shaders/";
  61338. Effect._uniqueIdSeed = 0;
  61339. Effect._baseCache = {};
  61340. /**
  61341. * Store of each shader (The can be looked up using effect.key)
  61342. */
  61343. Effect.ShadersStore = {};
  61344. /**
  61345. * Store of each included file for a shader (The can be looked up using effect.key)
  61346. */
  61347. Effect.IncludesShadersStore = {};
  61348. return Effect;
  61349. }());
  61350. /***/ }),
  61351. /***/ "./Materials/fresnelParameters.ts":
  61352. /*!****************************************!*\
  61353. !*** ./Materials/fresnelParameters.ts ***!
  61354. \****************************************/
  61355. /*! exports provided: FresnelParameters */
  61356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61357. "use strict";
  61358. __webpack_require__.r(__webpack_exports__);
  61359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  61360. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  61361. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61362. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  61363. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61364. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61365. /**
  61366. * This represents all the required information to add a fresnel effect on a material:
  61367. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  61368. */
  61369. var FresnelParameters = /** @class */ (function () {
  61370. function FresnelParameters() {
  61371. this._isEnabled = true;
  61372. /**
  61373. * Define the color used on edges (grazing angle)
  61374. */
  61375. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  61376. /**
  61377. * Define the color used on center
  61378. */
  61379. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  61380. /**
  61381. * Define bias applied to computed fresnel term
  61382. */
  61383. this.bias = 0;
  61384. /**
  61385. * Defined the power exponent applied to fresnel term
  61386. */
  61387. this.power = 1;
  61388. }
  61389. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  61390. /**
  61391. * Define if the fresnel effect is enable or not.
  61392. */
  61393. get: function () {
  61394. return this._isEnabled;
  61395. },
  61396. set: function (value) {
  61397. if (this._isEnabled === value) {
  61398. return;
  61399. }
  61400. this._isEnabled = value;
  61401. _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);
  61402. },
  61403. enumerable: true,
  61404. configurable: true
  61405. });
  61406. /**
  61407. * Clones the current fresnel and its valuues
  61408. * @returns a clone fresnel configuration
  61409. */
  61410. FresnelParameters.prototype.clone = function () {
  61411. var newFresnelParameters = new FresnelParameters();
  61412. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  61413. return newFresnelParameters;
  61414. };
  61415. /**
  61416. * Serializes the current fresnel parameters to a JSON representation.
  61417. * @return the JSON serialization
  61418. */
  61419. FresnelParameters.prototype.serialize = function () {
  61420. var serializationObject = {};
  61421. serializationObject.isEnabled = this.isEnabled;
  61422. serializationObject.leftColor = this.leftColor.asArray();
  61423. serializationObject.rightColor = this.rightColor.asArray();
  61424. serializationObject.bias = this.bias;
  61425. serializationObject.power = this.power;
  61426. return serializationObject;
  61427. };
  61428. /**
  61429. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  61430. * @param parsedFresnelParameters Define the JSON representation
  61431. * @returns the parsed parameters
  61432. */
  61433. FresnelParameters.Parse = function (parsedFresnelParameters) {
  61434. var fresnelParameters = new FresnelParameters();
  61435. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  61436. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  61437. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  61438. fresnelParameters.bias = parsedFresnelParameters.bias;
  61439. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  61440. return fresnelParameters;
  61441. };
  61442. return FresnelParameters;
  61443. }());
  61444. // References the dependencies.
  61445. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  61446. /***/ }),
  61447. /***/ "./Materials/imageProcessingConfiguration.ts":
  61448. /*!***************************************************!*\
  61449. !*** ./Materials/imageProcessingConfiguration.ts ***!
  61450. \***************************************************/
  61451. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  61452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61453. "use strict";
  61454. __webpack_require__.r(__webpack_exports__);
  61455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  61456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  61457. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61458. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61459. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61460. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61462. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  61463. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  61464. /**
  61465. * @hidden
  61466. */
  61467. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  61468. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  61469. function ImageProcessingConfigurationDefines() {
  61470. var _this = _super.call(this) || this;
  61471. _this.IMAGEPROCESSING = false;
  61472. _this.VIGNETTE = false;
  61473. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  61474. _this.VIGNETTEBLENDMODEOPAQUE = false;
  61475. _this.TONEMAPPING = false;
  61476. _this.TONEMAPPING_ACES = false;
  61477. _this.CONTRAST = false;
  61478. _this.COLORCURVES = false;
  61479. _this.COLORGRADING = false;
  61480. _this.COLORGRADING3D = false;
  61481. _this.SAMPLER3DGREENDEPTH = false;
  61482. _this.SAMPLER3DBGRMAP = false;
  61483. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  61484. _this.EXPOSURE = false;
  61485. _this.rebuild();
  61486. return _this;
  61487. }
  61488. return ImageProcessingConfigurationDefines;
  61489. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  61490. /**
  61491. * This groups together the common properties used for image processing either in direct forward pass
  61492. * or through post processing effect depending on the use of the image processing pipeline in your scene
  61493. * or not.
  61494. */
  61495. var ImageProcessingConfiguration = /** @class */ (function () {
  61496. function ImageProcessingConfiguration() {
  61497. /**
  61498. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  61499. */
  61500. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  61501. this._colorCurvesEnabled = false;
  61502. this._colorGradingEnabled = false;
  61503. this._colorGradingWithGreenDepth = true;
  61504. this._colorGradingBGR = true;
  61505. /** @hidden */
  61506. this._exposure = 1.0;
  61507. this._toneMappingEnabled = false;
  61508. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  61509. this._contrast = 1.0;
  61510. /**
  61511. * Vignette stretch size.
  61512. */
  61513. this.vignetteStretch = 0;
  61514. /**
  61515. * Vignette centre X Offset.
  61516. */
  61517. this.vignetteCentreX = 0;
  61518. /**
  61519. * Vignette centre Y Offset.
  61520. */
  61521. this.vignetteCentreY = 0;
  61522. /**
  61523. * Vignette weight or intensity of the vignette effect.
  61524. */
  61525. this.vignetteWeight = 1.5;
  61526. /**
  61527. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  61528. * if vignetteEnabled is set to true.
  61529. */
  61530. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  61531. /**
  61532. * Camera field of view used by the Vignette effect.
  61533. */
  61534. this.vignetteCameraFov = 0.5;
  61535. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  61536. this._vignetteEnabled = false;
  61537. this._applyByPostProcess = false;
  61538. this._isEnabled = true;
  61539. /**
  61540. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  61541. */
  61542. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61543. }
  61544. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  61545. /**
  61546. * Gets wether the color curves effect is enabled.
  61547. */
  61548. get: function () {
  61549. return this._colorCurvesEnabled;
  61550. },
  61551. /**
  61552. * Sets wether the color curves effect is enabled.
  61553. */
  61554. set: function (value) {
  61555. if (this._colorCurvesEnabled === value) {
  61556. return;
  61557. }
  61558. this._colorCurvesEnabled = value;
  61559. this._updateParameters();
  61560. },
  61561. enumerable: true,
  61562. configurable: true
  61563. });
  61564. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  61565. /**
  61566. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61567. */
  61568. get: function () {
  61569. return this._colorGradingTexture;
  61570. },
  61571. /**
  61572. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61573. */
  61574. set: function (value) {
  61575. if (this._colorGradingTexture === value) {
  61576. return;
  61577. }
  61578. this._colorGradingTexture = value;
  61579. this._updateParameters();
  61580. },
  61581. enumerable: true,
  61582. configurable: true
  61583. });
  61584. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  61585. /**
  61586. * Gets wether the color grading effect is enabled.
  61587. */
  61588. get: function () {
  61589. return this._colorGradingEnabled;
  61590. },
  61591. /**
  61592. * Sets wether the color grading effect is enabled.
  61593. */
  61594. set: function (value) {
  61595. if (this._colorGradingEnabled === value) {
  61596. return;
  61597. }
  61598. this._colorGradingEnabled = value;
  61599. this._updateParameters();
  61600. },
  61601. enumerable: true,
  61602. configurable: true
  61603. });
  61604. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  61605. /**
  61606. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  61607. */
  61608. get: function () {
  61609. return this._colorGradingWithGreenDepth;
  61610. },
  61611. /**
  61612. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  61613. */
  61614. set: function (value) {
  61615. if (this._colorGradingWithGreenDepth === value) {
  61616. return;
  61617. }
  61618. this._colorGradingWithGreenDepth = value;
  61619. this._updateParameters();
  61620. },
  61621. enumerable: true,
  61622. configurable: true
  61623. });
  61624. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  61625. /**
  61626. * Gets wether the color grading texture contains BGR values.
  61627. */
  61628. get: function () {
  61629. return this._colorGradingBGR;
  61630. },
  61631. /**
  61632. * Sets wether the color grading texture contains BGR values.
  61633. */
  61634. set: function (value) {
  61635. if (this._colorGradingBGR === value) {
  61636. return;
  61637. }
  61638. this._colorGradingBGR = value;
  61639. this._updateParameters();
  61640. },
  61641. enumerable: true,
  61642. configurable: true
  61643. });
  61644. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  61645. /**
  61646. * Gets the Exposure used in the effect.
  61647. */
  61648. get: function () {
  61649. return this._exposure;
  61650. },
  61651. /**
  61652. * Sets the Exposure used in the effect.
  61653. */
  61654. set: function (value) {
  61655. if (this._exposure === value) {
  61656. return;
  61657. }
  61658. this._exposure = value;
  61659. this._updateParameters();
  61660. },
  61661. enumerable: true,
  61662. configurable: true
  61663. });
  61664. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  61665. /**
  61666. * Gets wether the tone mapping effect is enabled.
  61667. */
  61668. get: function () {
  61669. return this._toneMappingEnabled;
  61670. },
  61671. /**
  61672. * Sets wether the tone mapping effect is enabled.
  61673. */
  61674. set: function (value) {
  61675. if (this._toneMappingEnabled === value) {
  61676. return;
  61677. }
  61678. this._toneMappingEnabled = value;
  61679. this._updateParameters();
  61680. },
  61681. enumerable: true,
  61682. configurable: true
  61683. });
  61684. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  61685. /**
  61686. * Gets the type of tone mapping effect.
  61687. */
  61688. get: function () {
  61689. return this._toneMappingType;
  61690. },
  61691. /**
  61692. * Sets the type of tone mapping effect used in BabylonJS.
  61693. */
  61694. set: function (value) {
  61695. if (this._toneMappingType === value) {
  61696. return;
  61697. }
  61698. this._toneMappingType = value;
  61699. this._updateParameters();
  61700. },
  61701. enumerable: true,
  61702. configurable: true
  61703. });
  61704. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  61705. /**
  61706. * Gets the contrast used in the effect.
  61707. */
  61708. get: function () {
  61709. return this._contrast;
  61710. },
  61711. /**
  61712. * Sets the contrast used in the effect.
  61713. */
  61714. set: function (value) {
  61715. if (this._contrast === value) {
  61716. return;
  61717. }
  61718. this._contrast = value;
  61719. this._updateParameters();
  61720. },
  61721. enumerable: true,
  61722. configurable: true
  61723. });
  61724. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  61725. /**
  61726. * Gets the vignette blend mode allowing different kind of effect.
  61727. */
  61728. get: function () {
  61729. return this._vignetteBlendMode;
  61730. },
  61731. /**
  61732. * Sets the vignette blend mode allowing different kind of effect.
  61733. */
  61734. set: function (value) {
  61735. if (this._vignetteBlendMode === value) {
  61736. return;
  61737. }
  61738. this._vignetteBlendMode = value;
  61739. this._updateParameters();
  61740. },
  61741. enumerable: true,
  61742. configurable: true
  61743. });
  61744. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  61745. /**
  61746. * Gets wether the vignette effect is enabled.
  61747. */
  61748. get: function () {
  61749. return this._vignetteEnabled;
  61750. },
  61751. /**
  61752. * Sets wether the vignette effect is enabled.
  61753. */
  61754. set: function (value) {
  61755. if (this._vignetteEnabled === value) {
  61756. return;
  61757. }
  61758. this._vignetteEnabled = value;
  61759. this._updateParameters();
  61760. },
  61761. enumerable: true,
  61762. configurable: true
  61763. });
  61764. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  61765. /**
  61766. * Gets wether the image processing is applied through a post process or not.
  61767. */
  61768. get: function () {
  61769. return this._applyByPostProcess;
  61770. },
  61771. /**
  61772. * Sets wether the image processing is applied through a post process or not.
  61773. */
  61774. set: function (value) {
  61775. if (this._applyByPostProcess === value) {
  61776. return;
  61777. }
  61778. this._applyByPostProcess = value;
  61779. this._updateParameters();
  61780. },
  61781. enumerable: true,
  61782. configurable: true
  61783. });
  61784. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  61785. /**
  61786. * Gets wether the image processing is enabled or not.
  61787. */
  61788. get: function () {
  61789. return this._isEnabled;
  61790. },
  61791. /**
  61792. * Sets wether the image processing is enabled or not.
  61793. */
  61794. set: function (value) {
  61795. if (this._isEnabled === value) {
  61796. return;
  61797. }
  61798. this._isEnabled = value;
  61799. this._updateParameters();
  61800. },
  61801. enumerable: true,
  61802. configurable: true
  61803. });
  61804. /**
  61805. * Method called each time the image processing information changes requires to recompile the effect.
  61806. */
  61807. ImageProcessingConfiguration.prototype._updateParameters = function () {
  61808. this.onUpdateParameters.notifyObservers(this);
  61809. };
  61810. /**
  61811. * Gets the current class name.
  61812. * @return "ImageProcessingConfiguration"
  61813. */
  61814. ImageProcessingConfiguration.prototype.getClassName = function () {
  61815. return "ImageProcessingConfiguration";
  61816. };
  61817. /**
  61818. * Prepare the list of uniforms associated with the Image Processing effects.
  61819. * @param uniforms The list of uniforms used in the effect
  61820. * @param defines the list of defines currently in use
  61821. */
  61822. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  61823. if (defines.EXPOSURE) {
  61824. uniforms.push("exposureLinear");
  61825. }
  61826. if (defines.CONTRAST) {
  61827. uniforms.push("contrast");
  61828. }
  61829. if (defines.COLORGRADING) {
  61830. uniforms.push("colorTransformSettings");
  61831. }
  61832. if (defines.VIGNETTE) {
  61833. uniforms.push("vInverseScreenSize");
  61834. uniforms.push("vignetteSettings1");
  61835. uniforms.push("vignetteSettings2");
  61836. }
  61837. if (defines.COLORCURVES) {
  61838. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  61839. }
  61840. };
  61841. /**
  61842. * Prepare the list of samplers associated with the Image Processing effects.
  61843. * @param samplersList The list of uniforms used in the effect
  61844. * @param defines the list of defines currently in use
  61845. */
  61846. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  61847. if (defines.COLORGRADING) {
  61848. samplersList.push("txColorTransform");
  61849. }
  61850. };
  61851. /**
  61852. * Prepare the list of defines associated to the shader.
  61853. * @param defines the list of defines to complete
  61854. * @param forPostProcess Define if we are currently in post process mode or not
  61855. */
  61856. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  61857. if (forPostProcess === void 0) { forPostProcess = false; }
  61858. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  61859. defines.VIGNETTE = false;
  61860. defines.TONEMAPPING = false;
  61861. defines.TONEMAPPING_ACES = false;
  61862. defines.CONTRAST = false;
  61863. defines.EXPOSURE = false;
  61864. defines.COLORCURVES = false;
  61865. defines.COLORGRADING = false;
  61866. defines.COLORGRADING3D = false;
  61867. defines.IMAGEPROCESSING = false;
  61868. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  61869. return;
  61870. }
  61871. defines.VIGNETTE = this.vignetteEnabled;
  61872. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  61873. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  61874. defines.TONEMAPPING = this.toneMappingEnabled;
  61875. switch (this._toneMappingType) {
  61876. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  61877. defines.TONEMAPPING_ACES = true;
  61878. break;
  61879. default:
  61880. defines.TONEMAPPING_ACES = false;
  61881. break;
  61882. }
  61883. defines.CONTRAST = (this.contrast !== 1.0);
  61884. defines.EXPOSURE = (this.exposure !== 1.0);
  61885. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  61886. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  61887. if (defines.COLORGRADING) {
  61888. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  61889. }
  61890. else {
  61891. defines.COLORGRADING3D = false;
  61892. }
  61893. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  61894. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  61895. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  61896. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  61897. };
  61898. /**
  61899. * Returns true if all the image processing information are ready.
  61900. * @returns True if ready, otherwise, false
  61901. */
  61902. ImageProcessingConfiguration.prototype.isReady = function () {
  61903. // Color Grading texure can not be none blocking.
  61904. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  61905. };
  61906. /**
  61907. * Binds the image processing to the shader.
  61908. * @param effect The effect to bind to
  61909. * @param aspectRatio Define the current aspect ratio of the effect
  61910. */
  61911. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  61912. if (aspectRatio === void 0) { aspectRatio = 1; }
  61913. // Color Curves
  61914. if (this._colorCurvesEnabled && this.colorCurves) {
  61915. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  61916. }
  61917. // Vignette
  61918. if (this._vignetteEnabled) {
  61919. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  61920. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  61921. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  61922. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  61923. var vignetteScaleX = vignetteScaleY * aspectRatio;
  61924. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  61925. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  61926. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  61927. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  61928. var vignettePower = -2.0 * this.vignetteWeight;
  61929. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  61930. }
  61931. // Exposure
  61932. effect.setFloat("exposureLinear", this.exposure);
  61933. // Contrast
  61934. effect.setFloat("contrast", this.contrast);
  61935. // Color transform settings
  61936. if (this.colorGradingTexture) {
  61937. effect.setTexture("txColorTransform", this.colorGradingTexture);
  61938. var textureSize = this.colorGradingTexture.getSize().height;
  61939. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  61940. 0.5 / textureSize, // textureOffset
  61941. textureSize, // textureSize
  61942. this.colorGradingTexture.level // weight
  61943. );
  61944. }
  61945. };
  61946. /**
  61947. * Clones the current image processing instance.
  61948. * @return The cloned image processing
  61949. */
  61950. ImageProcessingConfiguration.prototype.clone = function () {
  61951. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  61952. };
  61953. /**
  61954. * Serializes the current image processing instance to a json representation.
  61955. * @return a JSON representation
  61956. */
  61957. ImageProcessingConfiguration.prototype.serialize = function () {
  61958. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61959. };
  61960. /**
  61961. * Parses the image processing from a json representation.
  61962. * @param source the JSON source to parse
  61963. * @return The parsed image processing
  61964. */
  61965. ImageProcessingConfiguration.Parse = function (source) {
  61966. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  61967. };
  61968. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  61969. /**
  61970. * Used to apply the vignette as a mix with the pixel color.
  61971. */
  61972. get: function () {
  61973. return this._VIGNETTEMODE_MULTIPLY;
  61974. },
  61975. enumerable: true,
  61976. configurable: true
  61977. });
  61978. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  61979. /**
  61980. * Used to apply the vignette as a replacement of the pixel color.
  61981. */
  61982. get: function () {
  61983. return this._VIGNETTEMODE_OPAQUE;
  61984. },
  61985. enumerable: true,
  61986. configurable: true
  61987. });
  61988. /**
  61989. * Default tone mapping applied in BabylonJS.
  61990. */
  61991. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  61992. /**
  61993. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  61994. * to other engines rendering to increase portability.
  61995. */
  61996. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  61997. // Static constants associated to the image processing.
  61998. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  61999. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  62000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  62002. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  62003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62005. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  62006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  62008. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  62009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62011. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  62012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62014. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  62015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62017. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  62018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62020. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  62021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62023. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  62024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62026. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  62027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62029. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  62030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62032. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  62033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62035. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  62036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62038. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  62039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62041. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  62042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  62044. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  62045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62047. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  62048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62050. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  62051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62053. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  62054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62056. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  62057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62059. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  62060. return ImageProcessingConfiguration;
  62061. }());
  62062. // References the dependencies.
  62063. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  62064. /***/ }),
  62065. /***/ "./Materials/index.ts":
  62066. /*!****************************!*\
  62067. !*** ./Materials/index.ts ***!
  62068. \****************************/
  62069. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  62070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62071. "use strict";
  62072. __webpack_require__.r(__webpack_exports__);
  62073. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  62074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  62075. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  62076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  62077. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  62078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  62079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  62080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  62081. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  62082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  62083. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  62084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  62085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  62086. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  62087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  62088. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  62089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  62090. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  62091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  62092. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  62093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  62094. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  62095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  62096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  62097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  62098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  62099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  62100. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  62101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  62102. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  62103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  62104. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  62105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  62106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  62107. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  62108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  62109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  62110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  62111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  62112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  62113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  62114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  62115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  62116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  62117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  62118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  62119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  62120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  62121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  62122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  62123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  62124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  62125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  62126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  62127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  62128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  62129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  62130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  62131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  62132. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  62134. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  62135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  62136. /***/ }),
  62137. /***/ "./Materials/material.ts":
  62138. /*!*******************************!*\
  62139. !*** ./Materials/material.ts ***!
  62140. \*******************************/
  62141. /*! exports provided: Material */
  62142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62143. "use strict";
  62144. __webpack_require__.r(__webpack_exports__);
  62145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  62146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62147. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62148. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  62149. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62150. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62151. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  62152. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  62153. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62154. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62155. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62156. /**
  62157. * Base class for the main features of a material in Babylon.js
  62158. */
  62159. var Material = /** @class */ (function () {
  62160. /**
  62161. * Creates a material instance
  62162. * @param name defines the name of the material
  62163. * @param scene defines the scene to reference
  62164. * @param doNotAdd specifies if the material should be added to the scene
  62165. */
  62166. function Material(name, scene, doNotAdd) {
  62167. /**
  62168. * Gets or sets user defined metadata
  62169. */
  62170. this.metadata = null;
  62171. /**
  62172. * For internal use only. Please do not use.
  62173. */
  62174. this.reservedDataStore = null;
  62175. /**
  62176. * Specifies if the ready state should be checked on each call
  62177. */
  62178. this.checkReadyOnEveryCall = false;
  62179. /**
  62180. * Specifies if the ready state should be checked once
  62181. */
  62182. this.checkReadyOnlyOnce = false;
  62183. /**
  62184. * The state of the material
  62185. */
  62186. this.state = "";
  62187. /**
  62188. * The alpha value of the material
  62189. */
  62190. this._alpha = 1.0;
  62191. /**
  62192. * Specifies if back face culling is enabled
  62193. */
  62194. this._backFaceCulling = true;
  62195. /**
  62196. * Specifies if the material should be serialized
  62197. */
  62198. this.doNotSerialize = false;
  62199. /**
  62200. * @hidden
  62201. */
  62202. this._storeEffectOnSubMeshes = false;
  62203. /**
  62204. * An event triggered when the material is disposed
  62205. */
  62206. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62207. /**
  62208. * Stores the value of the alpha mode
  62209. */
  62210. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  62211. /**
  62212. * Stores the state of the need depth pre-pass value
  62213. */
  62214. this._needDepthPrePass = false;
  62215. /**
  62216. * Specifies if depth writing should be disabled
  62217. */
  62218. this.disableDepthWrite = false;
  62219. /**
  62220. * Specifies if depth writing should be forced
  62221. */
  62222. this.forceDepthWrite = false;
  62223. /**
  62224. * Specifies if there should be a separate pass for culling
  62225. */
  62226. this.separateCullingPass = false;
  62227. /**
  62228. * Stores the state specifing if fog should be enabled
  62229. */
  62230. this._fogEnabled = true;
  62231. /**
  62232. * Stores the size of points
  62233. */
  62234. this.pointSize = 1.0;
  62235. /**
  62236. * Stores the z offset value
  62237. */
  62238. this.zOffset = 0;
  62239. /**
  62240. * @hidden
  62241. * Specifies if the material was previously ready
  62242. */
  62243. this._wasPreviouslyReady = false;
  62244. /**
  62245. * Stores the fill mode state
  62246. */
  62247. this._fillMode = Material.TriangleFillMode;
  62248. /** @hidden */
  62249. this._indexInSceneMaterialArray = -1;
  62250. this.name = name;
  62251. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  62252. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  62253. this.uniqueId = this._scene.getUniqueId();
  62254. if (this._scene.useRightHandedSystem) {
  62255. this.sideOrientation = Material.ClockWiseSideOrientation;
  62256. }
  62257. else {
  62258. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  62259. }
  62260. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  62261. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  62262. if (!doNotAdd) {
  62263. this._scene.addMaterial(this);
  62264. }
  62265. if (this._scene.useMaterialMeshMap) {
  62266. this.meshMap = {};
  62267. }
  62268. }
  62269. Object.defineProperty(Material.prototype, "alpha", {
  62270. /**
  62271. * Gets the alpha value of the material
  62272. */
  62273. get: function () {
  62274. return this._alpha;
  62275. },
  62276. /**
  62277. * Sets the alpha value of the material
  62278. */
  62279. set: function (value) {
  62280. if (this._alpha === value) {
  62281. return;
  62282. }
  62283. this._alpha = value;
  62284. this.markAsDirty(Material.MiscDirtyFlag);
  62285. },
  62286. enumerable: true,
  62287. configurable: true
  62288. });
  62289. Object.defineProperty(Material.prototype, "backFaceCulling", {
  62290. /**
  62291. * Gets the back-face culling state
  62292. */
  62293. get: function () {
  62294. return this._backFaceCulling;
  62295. },
  62296. /**
  62297. * Sets the back-face culling state
  62298. */
  62299. set: function (value) {
  62300. if (this._backFaceCulling === value) {
  62301. return;
  62302. }
  62303. this._backFaceCulling = value;
  62304. this.markAsDirty(Material.TextureDirtyFlag);
  62305. },
  62306. enumerable: true,
  62307. configurable: true
  62308. });
  62309. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  62310. /**
  62311. * Gets a boolean indicating that current material needs to register RTT
  62312. */
  62313. get: function () {
  62314. return false;
  62315. },
  62316. enumerable: true,
  62317. configurable: true
  62318. });
  62319. Object.defineProperty(Material.prototype, "onDispose", {
  62320. /**
  62321. * Called during a dispose event
  62322. */
  62323. set: function (callback) {
  62324. if (this._onDisposeObserver) {
  62325. this.onDisposeObservable.remove(this._onDisposeObserver);
  62326. }
  62327. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  62328. },
  62329. enumerable: true,
  62330. configurable: true
  62331. });
  62332. Object.defineProperty(Material.prototype, "onBindObservable", {
  62333. /**
  62334. * An event triggered when the material is bound
  62335. */
  62336. get: function () {
  62337. if (!this._onBindObservable) {
  62338. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62339. }
  62340. return this._onBindObservable;
  62341. },
  62342. enumerable: true,
  62343. configurable: true
  62344. });
  62345. Object.defineProperty(Material.prototype, "onBind", {
  62346. /**
  62347. * Called during a bind event
  62348. */
  62349. set: function (callback) {
  62350. if (this._onBindObserver) {
  62351. this.onBindObservable.remove(this._onBindObserver);
  62352. }
  62353. this._onBindObserver = this.onBindObservable.add(callback);
  62354. },
  62355. enumerable: true,
  62356. configurable: true
  62357. });
  62358. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  62359. /**
  62360. * An event triggered when the material is unbound
  62361. */
  62362. get: function () {
  62363. if (!this._onUnBindObservable) {
  62364. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62365. }
  62366. return this._onUnBindObservable;
  62367. },
  62368. enumerable: true,
  62369. configurable: true
  62370. });
  62371. Object.defineProperty(Material.prototype, "alphaMode", {
  62372. /**
  62373. * Gets the value of the alpha mode
  62374. */
  62375. get: function () {
  62376. return this._alphaMode;
  62377. },
  62378. /**
  62379. * Sets the value of the alpha mode.
  62380. *
  62381. * | Value | Type | Description |
  62382. * | --- | --- | --- |
  62383. * | 0 | ALPHA_DISABLE | |
  62384. * | 1 | ALPHA_ADD | |
  62385. * | 2 | ALPHA_COMBINE | |
  62386. * | 3 | ALPHA_SUBTRACT | |
  62387. * | 4 | ALPHA_MULTIPLY | |
  62388. * | 5 | ALPHA_MAXIMIZED | |
  62389. * | 6 | ALPHA_ONEONE | |
  62390. * | 7 | ALPHA_PREMULTIPLIED | |
  62391. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  62392. * | 9 | ALPHA_INTERPOLATE | |
  62393. * | 10 | ALPHA_SCREENMODE | |
  62394. *
  62395. */
  62396. set: function (value) {
  62397. if (this._alphaMode === value) {
  62398. return;
  62399. }
  62400. this._alphaMode = value;
  62401. this.markAsDirty(Material.TextureDirtyFlag);
  62402. },
  62403. enumerable: true,
  62404. configurable: true
  62405. });
  62406. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  62407. /**
  62408. * Gets the depth pre-pass value
  62409. */
  62410. get: function () {
  62411. return this._needDepthPrePass;
  62412. },
  62413. /**
  62414. * Sets the need depth pre-pass value
  62415. */
  62416. set: function (value) {
  62417. if (this._needDepthPrePass === value) {
  62418. return;
  62419. }
  62420. this._needDepthPrePass = value;
  62421. if (this._needDepthPrePass) {
  62422. this.checkReadyOnEveryCall = true;
  62423. }
  62424. },
  62425. enumerable: true,
  62426. configurable: true
  62427. });
  62428. Object.defineProperty(Material.prototype, "fogEnabled", {
  62429. /**
  62430. * Gets the value of the fog enabled state
  62431. */
  62432. get: function () {
  62433. return this._fogEnabled;
  62434. },
  62435. /**
  62436. * Sets the state for enabling fog
  62437. */
  62438. set: function (value) {
  62439. if (this._fogEnabled === value) {
  62440. return;
  62441. }
  62442. this._fogEnabled = value;
  62443. this.markAsDirty(Material.MiscDirtyFlag);
  62444. },
  62445. enumerable: true,
  62446. configurable: true
  62447. });
  62448. Object.defineProperty(Material.prototype, "wireframe", {
  62449. /**
  62450. * Gets a value specifying if wireframe mode is enabled
  62451. */
  62452. get: function () {
  62453. switch (this._fillMode) {
  62454. case Material.WireFrameFillMode:
  62455. case Material.LineListDrawMode:
  62456. case Material.LineLoopDrawMode:
  62457. case Material.LineStripDrawMode:
  62458. return true;
  62459. }
  62460. return this._scene.forceWireframe;
  62461. },
  62462. /**
  62463. * Sets the state of wireframe mode
  62464. */
  62465. set: function (value) {
  62466. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  62467. },
  62468. enumerable: true,
  62469. configurable: true
  62470. });
  62471. Object.defineProperty(Material.prototype, "pointsCloud", {
  62472. /**
  62473. * Gets the value specifying if point clouds are enabled
  62474. */
  62475. get: function () {
  62476. switch (this._fillMode) {
  62477. case Material.PointFillMode:
  62478. case Material.PointListDrawMode:
  62479. return true;
  62480. }
  62481. return this._scene.forcePointsCloud;
  62482. },
  62483. /**
  62484. * Sets the state of point cloud mode
  62485. */
  62486. set: function (value) {
  62487. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  62488. },
  62489. enumerable: true,
  62490. configurable: true
  62491. });
  62492. Object.defineProperty(Material.prototype, "fillMode", {
  62493. /**
  62494. * Gets the material fill mode
  62495. */
  62496. get: function () {
  62497. return this._fillMode;
  62498. },
  62499. /**
  62500. * Sets the material fill mode
  62501. */
  62502. set: function (value) {
  62503. if (this._fillMode === value) {
  62504. return;
  62505. }
  62506. this._fillMode = value;
  62507. this.markAsDirty(Material.MiscDirtyFlag);
  62508. },
  62509. enumerable: true,
  62510. configurable: true
  62511. });
  62512. /**
  62513. * Returns a string representation of the current material
  62514. * @param fullDetails defines a boolean indicating which levels of logging is desired
  62515. * @returns a string with material information
  62516. */
  62517. Material.prototype.toString = function (fullDetails) {
  62518. var ret = "Name: " + this.name;
  62519. if (fullDetails) {
  62520. }
  62521. return ret;
  62522. };
  62523. /**
  62524. * Gets the class name of the material
  62525. * @returns a string with the class name of the material
  62526. */
  62527. Material.prototype.getClassName = function () {
  62528. return "Material";
  62529. };
  62530. Object.defineProperty(Material.prototype, "isFrozen", {
  62531. /**
  62532. * Specifies if updates for the material been locked
  62533. */
  62534. get: function () {
  62535. return this.checkReadyOnlyOnce;
  62536. },
  62537. enumerable: true,
  62538. configurable: true
  62539. });
  62540. /**
  62541. * Locks updates for the material
  62542. */
  62543. Material.prototype.freeze = function () {
  62544. this.checkReadyOnlyOnce = true;
  62545. };
  62546. /**
  62547. * Unlocks updates for the material
  62548. */
  62549. Material.prototype.unfreeze = function () {
  62550. this.checkReadyOnlyOnce = false;
  62551. };
  62552. /**
  62553. * Specifies if the material is ready to be used
  62554. * @param mesh defines the mesh to check
  62555. * @param useInstances specifies if instances should be used
  62556. * @returns a boolean indicating if the material is ready to be used
  62557. */
  62558. Material.prototype.isReady = function (mesh, useInstances) {
  62559. return true;
  62560. };
  62561. /**
  62562. * Specifies that the submesh is ready to be used
  62563. * @param mesh defines the mesh to check
  62564. * @param subMesh defines which submesh to check
  62565. * @param useInstances specifies that instances should be used
  62566. * @returns a boolean indicating that the submesh is ready or not
  62567. */
  62568. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  62569. return false;
  62570. };
  62571. /**
  62572. * Returns the material effect
  62573. * @returns the effect associated with the material
  62574. */
  62575. Material.prototype.getEffect = function () {
  62576. return this._effect;
  62577. };
  62578. /**
  62579. * Returns the current scene
  62580. * @returns a Scene
  62581. */
  62582. Material.prototype.getScene = function () {
  62583. return this._scene;
  62584. };
  62585. /**
  62586. * Specifies if the material will require alpha blending
  62587. * @returns a boolean specifying if alpha blending is needed
  62588. */
  62589. Material.prototype.needAlphaBlending = function () {
  62590. return (this.alpha < 1.0);
  62591. };
  62592. /**
  62593. * Specifies if the mesh will require alpha blending
  62594. * @param mesh defines the mesh to check
  62595. * @returns a boolean specifying if alpha blending is needed for the mesh
  62596. */
  62597. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  62598. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  62599. };
  62600. /**
  62601. * Specifies if this material should be rendered in alpha test mode
  62602. * @returns a boolean specifying if an alpha test is needed.
  62603. */
  62604. Material.prototype.needAlphaTesting = function () {
  62605. return false;
  62606. };
  62607. /**
  62608. * Gets the texture used for the alpha test
  62609. * @returns the texture to use for alpha testing
  62610. */
  62611. Material.prototype.getAlphaTestTexture = function () {
  62612. return null;
  62613. };
  62614. /**
  62615. * Marks the material to indicate that it needs to be re-calculated
  62616. */
  62617. Material.prototype.markDirty = function () {
  62618. this._wasPreviouslyReady = false;
  62619. };
  62620. /** @hidden */
  62621. Material.prototype._preBind = function (effect, overrideOrientation) {
  62622. if (overrideOrientation === void 0) { overrideOrientation = null; }
  62623. var engine = this._scene.getEngine();
  62624. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  62625. var reverse = orientation === Material.ClockWiseSideOrientation;
  62626. engine.enableEffect(effect ? effect : this._effect);
  62627. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  62628. return reverse;
  62629. };
  62630. /**
  62631. * Binds the material to the mesh
  62632. * @param world defines the world transformation matrix
  62633. * @param mesh defines the mesh to bind the material to
  62634. */
  62635. Material.prototype.bind = function (world, mesh) {
  62636. };
  62637. /**
  62638. * Binds the submesh to the material
  62639. * @param world defines the world transformation matrix
  62640. * @param mesh defines the mesh containing the submesh
  62641. * @param subMesh defines the submesh to bind the material to
  62642. */
  62643. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  62644. };
  62645. /**
  62646. * Binds the world matrix to the material
  62647. * @param world defines the world transformation matrix
  62648. */
  62649. Material.prototype.bindOnlyWorldMatrix = function (world) {
  62650. };
  62651. /**
  62652. * Binds the scene's uniform buffer to the effect.
  62653. * @param effect defines the effect to bind to the scene uniform buffer
  62654. * @param sceneUbo defines the uniform buffer storing scene data
  62655. */
  62656. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  62657. sceneUbo.bindToEffect(effect, "Scene");
  62658. };
  62659. /**
  62660. * Binds the view matrix to the effect
  62661. * @param effect defines the effect to bind the view matrix to
  62662. */
  62663. Material.prototype.bindView = function (effect) {
  62664. if (!this._useUBO) {
  62665. effect.setMatrix("view", this.getScene().getViewMatrix());
  62666. }
  62667. else {
  62668. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62669. }
  62670. };
  62671. /**
  62672. * Binds the view projection matrix to the effect
  62673. * @param effect defines the effect to bind the view projection matrix to
  62674. */
  62675. Material.prototype.bindViewProjection = function (effect) {
  62676. if (!this._useUBO) {
  62677. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  62678. }
  62679. else {
  62680. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62681. }
  62682. };
  62683. /**
  62684. * Specifies if material alpha testing should be turned on for the mesh
  62685. * @param mesh defines the mesh to check
  62686. */
  62687. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  62688. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  62689. };
  62690. /**
  62691. * Processes to execute after binding the material to a mesh
  62692. * @param mesh defines the rendered mesh
  62693. */
  62694. Material.prototype._afterBind = function (mesh) {
  62695. this._scene._cachedMaterial = this;
  62696. if (mesh) {
  62697. this._scene._cachedVisibility = mesh.visibility;
  62698. }
  62699. else {
  62700. this._scene._cachedVisibility = 1;
  62701. }
  62702. if (this._onBindObservable && mesh) {
  62703. this._onBindObservable.notifyObservers(mesh);
  62704. }
  62705. if (this.disableDepthWrite) {
  62706. var engine = this._scene.getEngine();
  62707. this._cachedDepthWriteState = engine.getDepthWrite();
  62708. engine.setDepthWrite(false);
  62709. }
  62710. };
  62711. /**
  62712. * Unbinds the material from the mesh
  62713. */
  62714. Material.prototype.unbind = function () {
  62715. if (this._onUnBindObservable) {
  62716. this._onUnBindObservable.notifyObservers(this);
  62717. }
  62718. if (this.disableDepthWrite) {
  62719. var engine = this._scene.getEngine();
  62720. engine.setDepthWrite(this._cachedDepthWriteState);
  62721. }
  62722. };
  62723. /**
  62724. * Gets the active textures from the material
  62725. * @returns an array of textures
  62726. */
  62727. Material.prototype.getActiveTextures = function () {
  62728. return [];
  62729. };
  62730. /**
  62731. * Specifies if the material uses a texture
  62732. * @param texture defines the texture to check against the material
  62733. * @returns a boolean specifying if the material uses the texture
  62734. */
  62735. Material.prototype.hasTexture = function (texture) {
  62736. return false;
  62737. };
  62738. /**
  62739. * Makes a duplicate of the material, and gives it a new name
  62740. * @param name defines the new name for the duplicated material
  62741. * @returns the cloned material
  62742. */
  62743. Material.prototype.clone = function (name) {
  62744. return null;
  62745. };
  62746. /**
  62747. * Gets the meshes bound to the material
  62748. * @returns an array of meshes bound to the material
  62749. */
  62750. Material.prototype.getBindedMeshes = function () {
  62751. var _this = this;
  62752. if (this.meshMap) {
  62753. var result = new Array();
  62754. for (var meshId in this.meshMap) {
  62755. var mesh = this.meshMap[meshId];
  62756. if (mesh) {
  62757. result.push(mesh);
  62758. }
  62759. }
  62760. return result;
  62761. }
  62762. else {
  62763. var meshes = this._scene.meshes;
  62764. return meshes.filter(function (mesh) { return mesh.material === _this; });
  62765. }
  62766. };
  62767. /**
  62768. * Force shader compilation
  62769. * @param mesh defines the mesh associated with this material
  62770. * @param onCompiled defines a function to execute once the material is compiled
  62771. * @param options defines the options to configure the compilation
  62772. */
  62773. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  62774. var _this = this;
  62775. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  62776. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  62777. var scene = this.getScene();
  62778. var checkReady = function () {
  62779. if (!_this._scene || !_this._scene.getEngine()) {
  62780. return;
  62781. }
  62782. if (subMesh._materialDefines) {
  62783. subMesh._materialDefines._renderId = -1;
  62784. }
  62785. var clipPlaneState = scene.clipPlane;
  62786. if (localOptions.clipPlane) {
  62787. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  62788. }
  62789. if (_this._storeEffectOnSubMeshes) {
  62790. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  62791. if (onCompiled) {
  62792. onCompiled(_this);
  62793. }
  62794. }
  62795. else {
  62796. setTimeout(checkReady, 16);
  62797. }
  62798. }
  62799. else {
  62800. if (_this.isReady()) {
  62801. if (onCompiled) {
  62802. onCompiled(_this);
  62803. }
  62804. }
  62805. else {
  62806. setTimeout(checkReady, 16);
  62807. }
  62808. }
  62809. if (localOptions.clipPlane) {
  62810. scene.clipPlane = clipPlaneState;
  62811. }
  62812. };
  62813. checkReady();
  62814. };
  62815. /**
  62816. * Force shader compilation
  62817. * @param mesh defines the mesh that will use this material
  62818. * @param options defines additional options for compiling the shaders
  62819. * @returns a promise that resolves when the compilation completes
  62820. */
  62821. Material.prototype.forceCompilationAsync = function (mesh, options) {
  62822. var _this = this;
  62823. return new Promise(function (resolve) {
  62824. _this.forceCompilation(mesh, function () {
  62825. resolve();
  62826. }, options);
  62827. });
  62828. };
  62829. /**
  62830. * Marks a define in the material to indicate that it needs to be re-computed
  62831. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  62832. */
  62833. Material.prototype.markAsDirty = function (flag) {
  62834. if (this.getScene().blockMaterialDirtyMechanism) {
  62835. return;
  62836. }
  62837. Material._DirtyCallbackArray.length = 0;
  62838. if (flag & Material.TextureDirtyFlag) {
  62839. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  62840. }
  62841. if (flag & Material.LightDirtyFlag) {
  62842. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  62843. }
  62844. if (flag & Material.FresnelDirtyFlag) {
  62845. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  62846. }
  62847. if (flag & Material.AttributesDirtyFlag) {
  62848. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  62849. }
  62850. if (flag & Material.MiscDirtyFlag) {
  62851. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  62852. }
  62853. if (Material._DirtyCallbackArray.length) {
  62854. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  62855. }
  62856. this.getScene().resetCachedMaterial();
  62857. };
  62858. /**
  62859. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  62860. * @param func defines a function which checks material defines against the submeshes
  62861. */
  62862. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  62863. if (this.getScene().blockMaterialDirtyMechanism) {
  62864. return;
  62865. }
  62866. var meshes = this.getScene().meshes;
  62867. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  62868. var mesh = meshes_1[_i];
  62869. if (!mesh.subMeshes) {
  62870. continue;
  62871. }
  62872. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  62873. var subMesh = _b[_a];
  62874. if (subMesh.getMaterial() !== this) {
  62875. continue;
  62876. }
  62877. if (!subMesh._materialDefines) {
  62878. continue;
  62879. }
  62880. func(subMesh._materialDefines);
  62881. }
  62882. }
  62883. };
  62884. /**
  62885. * Indicates that image processing needs to be re-calculated for all submeshes
  62886. */
  62887. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  62888. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  62889. };
  62890. /**
  62891. * Indicates that textures need to be re-calculated for all submeshes
  62892. */
  62893. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  62894. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  62895. };
  62896. /**
  62897. * Indicates that fresnel needs to be re-calculated for all submeshes
  62898. */
  62899. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  62900. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  62901. };
  62902. /**
  62903. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  62904. */
  62905. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  62906. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  62907. };
  62908. /**
  62909. * Indicates that lights need to be re-calculated for all submeshes
  62910. */
  62911. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  62912. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  62913. };
  62914. /**
  62915. * Indicates that attributes need to be re-calculated for all submeshes
  62916. */
  62917. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  62918. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  62919. };
  62920. /**
  62921. * Indicates that misc needs to be re-calculated for all submeshes
  62922. */
  62923. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  62924. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  62925. };
  62926. /**
  62927. * Indicates that textures and misc need to be re-calculated for all submeshes
  62928. */
  62929. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  62930. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  62931. };
  62932. /**
  62933. * Disposes the material
  62934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  62935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  62936. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  62937. */
  62938. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  62939. var scene = this.getScene();
  62940. // Animations
  62941. scene.stopAnimation(this);
  62942. scene.freeProcessedMaterials();
  62943. // Remove from scene
  62944. scene.removeMaterial(this);
  62945. if (notBoundToMesh !== true) {
  62946. // Remove from meshes
  62947. if (this.meshMap) {
  62948. for (var meshId in this.meshMap) {
  62949. var mesh = this.meshMap[meshId];
  62950. if (mesh) {
  62951. mesh.material = null; // will set the entry in the map to undefined
  62952. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62953. }
  62954. }
  62955. }
  62956. else {
  62957. var meshes = scene.meshes;
  62958. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  62959. var mesh = meshes_2[_i];
  62960. if (mesh.material === this) {
  62961. mesh.material = null;
  62962. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62963. }
  62964. }
  62965. }
  62966. }
  62967. this._uniformBuffer.dispose();
  62968. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  62969. if (forceDisposeEffect && this._effect) {
  62970. if (!this._storeEffectOnSubMeshes) {
  62971. scene.getEngine()._releaseEffect(this._effect);
  62972. }
  62973. this._effect = null;
  62974. }
  62975. // Callback
  62976. this.onDisposeObservable.notifyObservers(this);
  62977. this.onDisposeObservable.clear();
  62978. if (this._onBindObservable) {
  62979. this._onBindObservable.clear();
  62980. }
  62981. if (this._onUnBindObservable) {
  62982. this._onUnBindObservable.clear();
  62983. }
  62984. };
  62985. /** @hidden */
  62986. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  62987. if (mesh.geometry) {
  62988. var geometry = (mesh.geometry);
  62989. var scene = this.getScene();
  62990. if (this._storeEffectOnSubMeshes) {
  62991. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  62992. var subMesh = _a[_i];
  62993. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  62994. if (forceDisposeEffect && subMesh._materialEffect) {
  62995. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  62996. }
  62997. }
  62998. }
  62999. else {
  63000. geometry._releaseVertexArrayObject(this._effect);
  63001. }
  63002. }
  63003. };
  63004. /**
  63005. * Serializes this material
  63006. * @returns the serialized material object
  63007. */
  63008. Material.prototype.serialize = function () {
  63009. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63010. };
  63011. /**
  63012. * Creates a material from parsed material data
  63013. * @param parsedMaterial defines parsed material data
  63014. * @param scene defines the hosting scene
  63015. * @param rootUrl defines the root URL to use to load textures
  63016. * @returns a new material
  63017. */
  63018. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  63019. if (!parsedMaterial.customType) {
  63020. parsedMaterial.customType = "BABYLON.StandardMaterial";
  63021. }
  63022. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  63023. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  63024. if (!BABYLON.LegacyPBRMaterial) {
  63025. _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.");
  63026. return;
  63027. }
  63028. }
  63029. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  63030. return materialType.Parse(parsedMaterial, scene, rootUrl);
  63031. };
  63032. /**
  63033. * Returns the triangle fill mode
  63034. */
  63035. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  63036. /**
  63037. * Returns the wireframe mode
  63038. */
  63039. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  63040. /**
  63041. * Returns the point fill mode
  63042. */
  63043. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  63044. /**
  63045. * Returns the point list draw mode
  63046. */
  63047. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  63048. /**
  63049. * Returns the line list draw mode
  63050. */
  63051. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  63052. /**
  63053. * Returns the line loop draw mode
  63054. */
  63055. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  63056. /**
  63057. * Returns the line strip draw mode
  63058. */
  63059. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  63060. /**
  63061. * Returns the triangle strip draw mode
  63062. */
  63063. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  63064. /**
  63065. * Returns the triangle fan draw mode
  63066. */
  63067. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  63068. /**
  63069. * Stores the clock-wise side orientation
  63070. */
  63071. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  63072. /**
  63073. * Stores the counter clock-wise side orientation
  63074. */
  63075. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  63076. /**
  63077. * The dirty texture flag value
  63078. */
  63079. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  63080. /**
  63081. * The dirty light flag value
  63082. */
  63083. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  63084. /**
  63085. * The dirty fresnel flag value
  63086. */
  63087. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  63088. /**
  63089. * The dirty attribute flag value
  63090. */
  63091. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  63092. /**
  63093. * The dirty misc flag value
  63094. */
  63095. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  63096. /**
  63097. * The all dirty flag value
  63098. */
  63099. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  63100. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  63101. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  63102. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  63103. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  63104. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  63105. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  63106. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  63107. Material._FresnelDirtyCallBack(defines);
  63108. Material._MiscDirtyCallBack(defines);
  63109. };
  63110. Material._TextureAndMiscDirtyCallBack = function (defines) {
  63111. Material._TextureDirtyCallBack(defines);
  63112. Material._MiscDirtyCallBack(defines);
  63113. };
  63114. Material._DirtyCallbackArray = [];
  63115. Material._RunDirtyCallBacks = function (defines) {
  63116. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  63117. var cb = _a[_i];
  63118. cb(defines);
  63119. }
  63120. };
  63121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63123. ], Material.prototype, "id", void 0);
  63124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63126. ], Material.prototype, "uniqueId", void 0);
  63127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63129. ], Material.prototype, "name", void 0);
  63130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63132. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  63133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63135. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  63136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63138. ], Material.prototype, "state", void 0);
  63139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  63141. ], Material.prototype, "_alpha", void 0);
  63142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  63144. ], Material.prototype, "_backFaceCulling", void 0);
  63145. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63146. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63147. ], Material.prototype, "sideOrientation", void 0);
  63148. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63149. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  63150. ], Material.prototype, "_alphaMode", void 0);
  63151. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63153. ], Material.prototype, "_needDepthPrePass", void 0);
  63154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63156. ], Material.prototype, "disableDepthWrite", void 0);
  63157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63159. ], Material.prototype, "forceDepthWrite", void 0);
  63160. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63161. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63162. ], Material.prototype, "separateCullingPass", void 0);
  63163. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  63165. ], Material.prototype, "_fogEnabled", void 0);
  63166. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63168. ], Material.prototype, "pointSize", void 0);
  63169. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63170. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63171. ], Material.prototype, "zOffset", void 0);
  63172. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63173. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63174. ], Material.prototype, "wireframe", null);
  63175. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63176. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63177. ], Material.prototype, "pointsCloud", null);
  63178. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63179. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63180. ], Material.prototype, "fillMode", null);
  63181. return Material;
  63182. }());
  63183. /***/ }),
  63184. /***/ "./Materials/materialDefines.ts":
  63185. /*!**************************************!*\
  63186. !*** ./Materials/materialDefines.ts ***!
  63187. \**************************************/
  63188. /*! exports provided: MaterialDefines */
  63189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63190. "use strict";
  63191. __webpack_require__.r(__webpack_exports__);
  63192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  63193. /**
  63194. * Manages the defines for the Material
  63195. */
  63196. var MaterialDefines = /** @class */ (function () {
  63197. function MaterialDefines() {
  63198. this._isDirty = true;
  63199. /** @hidden */
  63200. this._areLightsDirty = true;
  63201. /** @hidden */
  63202. this._areAttributesDirty = true;
  63203. /** @hidden */
  63204. this._areTexturesDirty = true;
  63205. /** @hidden */
  63206. this._areFresnelDirty = true;
  63207. /** @hidden */
  63208. this._areMiscDirty = true;
  63209. /** @hidden */
  63210. this._areImageProcessingDirty = true;
  63211. /** @hidden */
  63212. this._normals = false;
  63213. /** @hidden */
  63214. this._uvs = false;
  63215. /** @hidden */
  63216. this._needNormals = false;
  63217. /** @hidden */
  63218. this._needUVs = false;
  63219. }
  63220. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  63221. /**
  63222. * Specifies if the material needs to be re-calculated
  63223. */
  63224. get: function () {
  63225. return this._isDirty;
  63226. },
  63227. enumerable: true,
  63228. configurable: true
  63229. });
  63230. /**
  63231. * Marks the material to indicate that it has been re-calculated
  63232. */
  63233. MaterialDefines.prototype.markAsProcessed = function () {
  63234. this._isDirty = false;
  63235. this._areAttributesDirty = false;
  63236. this._areTexturesDirty = false;
  63237. this._areFresnelDirty = false;
  63238. this._areLightsDirty = false;
  63239. this._areMiscDirty = false;
  63240. this._areImageProcessingDirty = false;
  63241. };
  63242. /**
  63243. * Marks the material to indicate that it needs to be re-calculated
  63244. */
  63245. MaterialDefines.prototype.markAsUnprocessed = function () {
  63246. this._isDirty = true;
  63247. };
  63248. /**
  63249. * Marks the material to indicate all of its defines need to be re-calculated
  63250. */
  63251. MaterialDefines.prototype.markAllAsDirty = function () {
  63252. this._areTexturesDirty = true;
  63253. this._areAttributesDirty = true;
  63254. this._areLightsDirty = true;
  63255. this._areFresnelDirty = true;
  63256. this._areMiscDirty = true;
  63257. this._areImageProcessingDirty = true;
  63258. this._isDirty = true;
  63259. };
  63260. /**
  63261. * Marks the material to indicate that image processing needs to be re-calculated
  63262. */
  63263. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  63264. this._areImageProcessingDirty = true;
  63265. this._isDirty = true;
  63266. };
  63267. /**
  63268. * Marks the material to indicate the lights need to be re-calculated
  63269. */
  63270. MaterialDefines.prototype.markAsLightDirty = function () {
  63271. this._areLightsDirty = true;
  63272. this._isDirty = true;
  63273. };
  63274. /**
  63275. * Marks the attribute state as changed
  63276. */
  63277. MaterialDefines.prototype.markAsAttributesDirty = function () {
  63278. this._areAttributesDirty = true;
  63279. this._isDirty = true;
  63280. };
  63281. /**
  63282. * Marks the texture state as changed
  63283. */
  63284. MaterialDefines.prototype.markAsTexturesDirty = function () {
  63285. this._areTexturesDirty = true;
  63286. this._isDirty = true;
  63287. };
  63288. /**
  63289. * Marks the fresnel state as changed
  63290. */
  63291. MaterialDefines.prototype.markAsFresnelDirty = function () {
  63292. this._areFresnelDirty = true;
  63293. this._isDirty = true;
  63294. };
  63295. /**
  63296. * Marks the misc state as changed
  63297. */
  63298. MaterialDefines.prototype.markAsMiscDirty = function () {
  63299. this._areMiscDirty = true;
  63300. this._isDirty = true;
  63301. };
  63302. /**
  63303. * Rebuilds the material defines
  63304. */
  63305. MaterialDefines.prototype.rebuild = function () {
  63306. if (this._keys) {
  63307. delete this._keys;
  63308. }
  63309. this._keys = [];
  63310. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  63311. var key = _a[_i];
  63312. if (key[0] === "_") {
  63313. continue;
  63314. }
  63315. this._keys.push(key);
  63316. }
  63317. };
  63318. /**
  63319. * Specifies if two material defines are equal
  63320. * @param other - A material define instance to compare to
  63321. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63322. */
  63323. MaterialDefines.prototype.isEqual = function (other) {
  63324. if (this._keys.length !== other._keys.length) {
  63325. return false;
  63326. }
  63327. for (var index = 0; index < this._keys.length; index++) {
  63328. var prop = this._keys[index];
  63329. if (this[prop] !== other[prop]) {
  63330. return false;
  63331. }
  63332. }
  63333. return true;
  63334. };
  63335. /**
  63336. * Clones this instance's defines to another instance
  63337. * @param other - material defines to clone values to
  63338. */
  63339. MaterialDefines.prototype.cloneTo = function (other) {
  63340. if (this._keys.length !== other._keys.length) {
  63341. other._keys = this._keys.slice(0);
  63342. }
  63343. for (var index = 0; index < this._keys.length; index++) {
  63344. var prop = this._keys[index];
  63345. other[prop] = this[prop];
  63346. }
  63347. };
  63348. /**
  63349. * Resets the material define values
  63350. */
  63351. MaterialDefines.prototype.reset = function () {
  63352. for (var index = 0; index < this._keys.length; index++) {
  63353. var prop = this._keys[index];
  63354. var type = typeof this[prop];
  63355. switch (type) {
  63356. case "number":
  63357. this[prop] = 0;
  63358. break;
  63359. case "string":
  63360. this[prop] = "";
  63361. break;
  63362. default:
  63363. this[prop] = false;
  63364. break;
  63365. }
  63366. }
  63367. };
  63368. /**
  63369. * Converts the material define values to a string
  63370. * @returns - String of material define information
  63371. */
  63372. MaterialDefines.prototype.toString = function () {
  63373. var result = "";
  63374. for (var index = 0; index < this._keys.length; index++) {
  63375. var prop = this._keys[index];
  63376. var value = this[prop];
  63377. var type = typeof value;
  63378. switch (type) {
  63379. case "number":
  63380. case "string":
  63381. result += "#define " + prop + " " + value + "\n";
  63382. break;
  63383. default:
  63384. if (value) {
  63385. result += "#define " + prop + "\n";
  63386. }
  63387. break;
  63388. }
  63389. }
  63390. return result;
  63391. };
  63392. return MaterialDefines;
  63393. }());
  63394. /***/ }),
  63395. /***/ "./Materials/materialFlags.ts":
  63396. /*!************************************!*\
  63397. !*** ./Materials/materialFlags.ts ***!
  63398. \************************************/
  63399. /*! exports provided: MaterialFlags */
  63400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63401. "use strict";
  63402. __webpack_require__.r(__webpack_exports__);
  63403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  63404. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63405. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63406. /**
  63407. * This groups all the flags used to control the materials channel.
  63408. */
  63409. var MaterialFlags = /** @class */ (function () {
  63410. function MaterialFlags() {
  63411. }
  63412. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  63413. /**
  63414. * Are diffuse textures enabled in the application.
  63415. */
  63416. get: function () {
  63417. return this._DiffuseTextureEnabled;
  63418. },
  63419. set: function (value) {
  63420. if (this._DiffuseTextureEnabled === value) {
  63421. return;
  63422. }
  63423. this._DiffuseTextureEnabled = value;
  63424. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63425. },
  63426. enumerable: true,
  63427. configurable: true
  63428. });
  63429. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  63430. /**
  63431. * Are ambient textures enabled in the application.
  63432. */
  63433. get: function () {
  63434. return this._AmbientTextureEnabled;
  63435. },
  63436. set: function (value) {
  63437. if (this._AmbientTextureEnabled === value) {
  63438. return;
  63439. }
  63440. this._AmbientTextureEnabled = value;
  63441. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63442. },
  63443. enumerable: true,
  63444. configurable: true
  63445. });
  63446. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  63447. /**
  63448. * Are opacity textures enabled in the application.
  63449. */
  63450. get: function () {
  63451. return this._OpacityTextureEnabled;
  63452. },
  63453. set: function (value) {
  63454. if (this._OpacityTextureEnabled === value) {
  63455. return;
  63456. }
  63457. this._OpacityTextureEnabled = value;
  63458. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63459. },
  63460. enumerable: true,
  63461. configurable: true
  63462. });
  63463. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  63464. /**
  63465. * Are reflection textures enabled in the application.
  63466. */
  63467. get: function () {
  63468. return this._ReflectionTextureEnabled;
  63469. },
  63470. set: function (value) {
  63471. if (this._ReflectionTextureEnabled === value) {
  63472. return;
  63473. }
  63474. this._ReflectionTextureEnabled = value;
  63475. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63476. },
  63477. enumerable: true,
  63478. configurable: true
  63479. });
  63480. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  63481. /**
  63482. * Are emissive textures enabled in the application.
  63483. */
  63484. get: function () {
  63485. return this._EmissiveTextureEnabled;
  63486. },
  63487. set: function (value) {
  63488. if (this._EmissiveTextureEnabled === value) {
  63489. return;
  63490. }
  63491. this._EmissiveTextureEnabled = value;
  63492. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63493. },
  63494. enumerable: true,
  63495. configurable: true
  63496. });
  63497. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  63498. /**
  63499. * Are specular textures enabled in the application.
  63500. */
  63501. get: function () {
  63502. return this._SpecularTextureEnabled;
  63503. },
  63504. set: function (value) {
  63505. if (this._SpecularTextureEnabled === value) {
  63506. return;
  63507. }
  63508. this._SpecularTextureEnabled = value;
  63509. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63510. },
  63511. enumerable: true,
  63512. configurable: true
  63513. });
  63514. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  63515. /**
  63516. * Are bump textures enabled in the application.
  63517. */
  63518. get: function () {
  63519. return this._BumpTextureEnabled;
  63520. },
  63521. set: function (value) {
  63522. if (this._BumpTextureEnabled === value) {
  63523. return;
  63524. }
  63525. this._BumpTextureEnabled = value;
  63526. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63527. },
  63528. enumerable: true,
  63529. configurable: true
  63530. });
  63531. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  63532. /**
  63533. * Are lightmap textures enabled in the application.
  63534. */
  63535. get: function () {
  63536. return this._LightmapTextureEnabled;
  63537. },
  63538. set: function (value) {
  63539. if (this._LightmapTextureEnabled === value) {
  63540. return;
  63541. }
  63542. this._LightmapTextureEnabled = value;
  63543. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63544. },
  63545. enumerable: true,
  63546. configurable: true
  63547. });
  63548. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  63549. /**
  63550. * Are refraction textures enabled in the application.
  63551. */
  63552. get: function () {
  63553. return this._RefractionTextureEnabled;
  63554. },
  63555. set: function (value) {
  63556. if (this._RefractionTextureEnabled === value) {
  63557. return;
  63558. }
  63559. this._RefractionTextureEnabled = value;
  63560. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63561. },
  63562. enumerable: true,
  63563. configurable: true
  63564. });
  63565. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  63566. /**
  63567. * Are color grading textures enabled in the application.
  63568. */
  63569. get: function () {
  63570. return this._ColorGradingTextureEnabled;
  63571. },
  63572. set: function (value) {
  63573. if (this._ColorGradingTextureEnabled === value) {
  63574. return;
  63575. }
  63576. this._ColorGradingTextureEnabled = value;
  63577. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63578. },
  63579. enumerable: true,
  63580. configurable: true
  63581. });
  63582. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  63583. /**
  63584. * Are fresnels enabled in the application.
  63585. */
  63586. get: function () {
  63587. return this._FresnelEnabled;
  63588. },
  63589. set: function (value) {
  63590. if (this._FresnelEnabled === value) {
  63591. return;
  63592. }
  63593. this._FresnelEnabled = value;
  63594. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  63595. },
  63596. enumerable: true,
  63597. configurable: true
  63598. });
  63599. // Flags used to enable or disable a type of texture for all Standard Materials
  63600. MaterialFlags._DiffuseTextureEnabled = true;
  63601. MaterialFlags._AmbientTextureEnabled = true;
  63602. MaterialFlags._OpacityTextureEnabled = true;
  63603. MaterialFlags._ReflectionTextureEnabled = true;
  63604. MaterialFlags._EmissiveTextureEnabled = true;
  63605. MaterialFlags._SpecularTextureEnabled = true;
  63606. MaterialFlags._BumpTextureEnabled = true;
  63607. MaterialFlags._LightmapTextureEnabled = true;
  63608. MaterialFlags._RefractionTextureEnabled = true;
  63609. MaterialFlags._ColorGradingTextureEnabled = true;
  63610. MaterialFlags._FresnelEnabled = true;
  63611. return MaterialFlags;
  63612. }());
  63613. /***/ }),
  63614. /***/ "./Materials/materialHelper.ts":
  63615. /*!*************************************!*\
  63616. !*** ./Materials/materialHelper.ts ***!
  63617. \*************************************/
  63618. /*! exports provided: MaterialHelper */
  63619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63620. "use strict";
  63621. __webpack_require__.r(__webpack_exports__);
  63622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  63623. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63624. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  63625. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63626. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  63627. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  63628. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  63629. /**
  63630. * "Static Class" containing the most commonly used helper while dealing with material for
  63631. * rendering purpose.
  63632. *
  63633. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  63634. *
  63635. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  63636. */
  63637. var MaterialHelper = /** @class */ (function () {
  63638. function MaterialHelper() {
  63639. }
  63640. /**
  63641. * Bind the current view position to an effect.
  63642. * @param effect The effect to be bound
  63643. * @param scene The scene the eyes position is used from
  63644. */
  63645. MaterialHelper.BindEyePosition = function (effect, scene) {
  63646. if (scene._forcedViewPosition) {
  63647. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  63648. return;
  63649. }
  63650. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  63651. };
  63652. /**
  63653. * Helps preparing the defines values about the UVs in used in the effect.
  63654. * UVs are shared as much as we can accross channels in the shaders.
  63655. * @param texture The texture we are preparing the UVs for
  63656. * @param defines The defines to update
  63657. * @param key The channel key "diffuse", "specular"... used in the shader
  63658. */
  63659. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  63660. defines._needUVs = true;
  63661. defines[key] = true;
  63662. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  63663. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  63664. if (texture.coordinatesIndex === 0) {
  63665. defines["MAINUV1"] = true;
  63666. }
  63667. else {
  63668. defines["MAINUV2"] = true;
  63669. }
  63670. }
  63671. else {
  63672. defines[key + "DIRECTUV"] = 0;
  63673. }
  63674. };
  63675. /**
  63676. * Binds a texture matrix value to its corrsponding uniform
  63677. * @param texture The texture to bind the matrix for
  63678. * @param uniformBuffer The uniform buffer receivin the data
  63679. * @param key The channel key "diffuse", "specular"... used in the shader
  63680. */
  63681. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  63682. var matrix = texture.getTextureMatrix();
  63683. if (!matrix.isIdentityAs3x2()) {
  63684. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  63685. }
  63686. };
  63687. /**
  63688. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  63689. * @param mesh defines the current mesh
  63690. * @param scene defines the current scene
  63691. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  63692. * @param pointsCloud defines if point cloud rendering has to be turned on
  63693. * @param fogEnabled defines if fog has to be turned on
  63694. * @param alphaTest defines if alpha testing has to be turned on
  63695. * @param defines defines the current list of defines
  63696. */
  63697. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  63698. if (defines._areMiscDirty) {
  63699. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  63700. defines["POINTSIZE"] = pointsCloud;
  63701. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  63702. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  63703. defines["ALPHATEST"] = alphaTest;
  63704. }
  63705. };
  63706. /**
  63707. * Helper used to prepare the list of defines associated with frame values for shader compilation
  63708. * @param scene defines the current scene
  63709. * @param engine defines the current engine
  63710. * @param defines specifies the list of active defines
  63711. * @param useInstances defines if instances have to be turned on
  63712. * @param useClipPlane defines if clip plane have to be turned on
  63713. */
  63714. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  63715. if (useClipPlane === void 0) { useClipPlane = null; }
  63716. var changed = false;
  63717. var useClipPlane1 = false;
  63718. var useClipPlane2 = false;
  63719. var useClipPlane3 = false;
  63720. var useClipPlane4 = false;
  63721. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  63722. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  63723. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  63724. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  63725. if (defines["CLIPPLANE"] !== useClipPlane1) {
  63726. defines["CLIPPLANE"] = useClipPlane1;
  63727. changed = true;
  63728. }
  63729. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  63730. defines["CLIPPLANE2"] = useClipPlane2;
  63731. changed = true;
  63732. }
  63733. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  63734. defines["CLIPPLANE3"] = useClipPlane3;
  63735. changed = true;
  63736. }
  63737. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  63738. defines["CLIPPLANE4"] = useClipPlane4;
  63739. changed = true;
  63740. }
  63741. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  63742. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  63743. changed = true;
  63744. }
  63745. if (defines["INSTANCES"] !== useInstances) {
  63746. defines["INSTANCES"] = useInstances;
  63747. changed = true;
  63748. }
  63749. if (changed) {
  63750. defines.markAsUnprocessed();
  63751. }
  63752. };
  63753. /**
  63754. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  63755. * @param mesh The mesh containing the geometry data we will draw
  63756. * @param defines The defines to update
  63757. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  63758. * @param useBones Precise whether bones should be used or not (override mesh info)
  63759. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  63760. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  63761. * @returns false if defines are considered not dirty and have not been checked
  63762. */
  63763. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  63764. if (useMorphTargets === void 0) { useMorphTargets = false; }
  63765. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  63766. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  63767. return false;
  63768. }
  63769. defines._normals = defines._needNormals;
  63770. defines._uvs = defines._needUVs;
  63771. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  63772. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  63773. defines["TANGENT"] = true;
  63774. }
  63775. if (defines._needUVs) {
  63776. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  63777. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  63778. }
  63779. else {
  63780. defines["UV1"] = false;
  63781. defines["UV2"] = false;
  63782. }
  63783. if (useVertexColor) {
  63784. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  63785. defines["VERTEXCOLOR"] = hasVertexColors;
  63786. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  63787. }
  63788. if (useBones) {
  63789. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63790. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  63791. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  63792. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  63793. defines["BONETEXTURE"] = true;
  63794. }
  63795. else {
  63796. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  63797. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  63798. }
  63799. }
  63800. else {
  63801. defines["NUM_BONE_INFLUENCERS"] = 0;
  63802. defines["BonesPerMesh"] = 0;
  63803. }
  63804. }
  63805. if (useMorphTargets) {
  63806. var manager = mesh.morphTargetManager;
  63807. if (manager) {
  63808. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  63809. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  63810. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  63811. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  63812. }
  63813. else {
  63814. defines["MORPHTARGETS_TANGENT"] = false;
  63815. defines["MORPHTARGETS_NORMAL"] = false;
  63816. defines["MORPHTARGETS"] = false;
  63817. defines["NUM_MORPH_INFLUENCERS"] = 0;
  63818. }
  63819. }
  63820. return true;
  63821. };
  63822. /**
  63823. * Prepares the defines related to the light information passed in parameter
  63824. * @param scene The scene we are intending to draw
  63825. * @param mesh The mesh the effect is compiling for
  63826. * @param defines The defines to update
  63827. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  63828. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  63829. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  63830. * @returns true if normals will be required for the rest of the effect
  63831. */
  63832. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  63833. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63834. if (disableLighting === void 0) { disableLighting = false; }
  63835. if (!defines._areLightsDirty) {
  63836. return defines._needNormals;
  63837. }
  63838. var lightIndex = 0;
  63839. var needNormals = false;
  63840. var needRebuild = false;
  63841. var lightmapMode = false;
  63842. var shadowEnabled = false;
  63843. var specularEnabled = false;
  63844. if (scene.lightsEnabled && !disableLighting) {
  63845. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  63846. var light = _a[_i];
  63847. needNormals = true;
  63848. if (defines["LIGHT" + lightIndex] === undefined) {
  63849. needRebuild = true;
  63850. }
  63851. defines["LIGHT" + lightIndex] = true;
  63852. defines["SPOTLIGHT" + lightIndex] = false;
  63853. defines["HEMILIGHT" + lightIndex] = false;
  63854. defines["POINTLIGHT" + lightIndex] = false;
  63855. defines["DIRLIGHT" + lightIndex] = false;
  63856. light.prepareLightSpecificDefines(defines, lightIndex);
  63857. // FallOff.
  63858. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  63859. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  63860. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  63861. switch (light.falloffType) {
  63862. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  63863. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  63864. break;
  63865. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  63866. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  63867. break;
  63868. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  63869. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  63870. break;
  63871. }
  63872. // Specular
  63873. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  63874. specularEnabled = true;
  63875. }
  63876. // Shadows
  63877. defines["SHADOW" + lightIndex] = false;
  63878. defines["SHADOWPCF" + lightIndex] = false;
  63879. defines["SHADOWPCSS" + lightIndex] = false;
  63880. defines["SHADOWPOISSON" + lightIndex] = false;
  63881. defines["SHADOWESM" + lightIndex] = false;
  63882. defines["SHADOWCUBE" + lightIndex] = false;
  63883. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  63884. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  63885. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  63886. var shadowGenerator = light.getShadowGenerator();
  63887. if (shadowGenerator) {
  63888. var shadowMap = shadowGenerator.getShadowMap();
  63889. if (shadowMap) {
  63890. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  63891. shadowEnabled = true;
  63892. shadowGenerator.prepareDefines(defines, lightIndex);
  63893. }
  63894. }
  63895. }
  63896. }
  63897. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  63898. lightmapMode = true;
  63899. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  63900. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  63901. }
  63902. else {
  63903. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  63904. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  63905. }
  63906. lightIndex++;
  63907. if (lightIndex === maxSimultaneousLights) {
  63908. break;
  63909. }
  63910. }
  63911. }
  63912. defines["SPECULARTERM"] = specularEnabled;
  63913. defines["SHADOWS"] = shadowEnabled;
  63914. // Resetting all other lights if any
  63915. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  63916. if (defines["LIGHT" + index] !== undefined) {
  63917. defines["LIGHT" + index] = false;
  63918. defines["HEMILIGHT" + index] = false;
  63919. defines["POINTLIGHT" + index] = false;
  63920. defines["DIRLIGHT" + index] = false;
  63921. defines["SPOTLIGHT" + index] = false;
  63922. defines["SHADOW" + index] = false;
  63923. defines["SHADOWPCF" + index] = false;
  63924. defines["SHADOWPCSS" + index] = false;
  63925. defines["SHADOWPOISSON" + index] = false;
  63926. defines["SHADOWESM" + index] = false;
  63927. defines["SHADOWCUBE" + index] = false;
  63928. defines["SHADOWLOWQUALITY" + index] = false;
  63929. defines["SHADOWMEDIUMQUALITY" + index] = false;
  63930. }
  63931. }
  63932. var caps = scene.getEngine().getCaps();
  63933. if (defines["SHADOWFLOAT"] === undefined) {
  63934. needRebuild = true;
  63935. }
  63936. defines["SHADOWFLOAT"] = shadowEnabled &&
  63937. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  63938. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  63939. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  63940. if (needRebuild) {
  63941. defines.rebuild();
  63942. }
  63943. return needNormals;
  63944. };
  63945. /**
  63946. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  63947. * that won t be acctive due to defines being turned off.
  63948. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  63949. * @param samplersList The samplers list
  63950. * @param defines The defines helping in the list generation
  63951. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  63952. */
  63953. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  63954. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63955. var uniformsList;
  63956. var uniformBuffersList = null;
  63957. if (uniformsListOrOptions.uniformsNames) {
  63958. var options = uniformsListOrOptions;
  63959. uniformsList = options.uniformsNames;
  63960. uniformBuffersList = options.uniformBuffersNames;
  63961. samplersList = options.samplers;
  63962. defines = options.defines;
  63963. maxSimultaneousLights = options.maxSimultaneousLights;
  63964. }
  63965. else {
  63966. uniformsList = uniformsListOrOptions;
  63967. if (!samplersList) {
  63968. samplersList = [];
  63969. }
  63970. }
  63971. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63972. if (!defines["LIGHT" + lightIndex]) {
  63973. break;
  63974. }
  63975. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  63976. if (uniformBuffersList) {
  63977. uniformBuffersList.push("Light" + lightIndex);
  63978. }
  63979. samplersList.push("shadowSampler" + lightIndex);
  63980. samplersList.push("depthSampler" + lightIndex);
  63981. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  63982. samplersList.push("projectionLightSampler" + lightIndex);
  63983. uniformsList.push("textureProjectionMatrix" + lightIndex);
  63984. }
  63985. }
  63986. if (defines["NUM_MORPH_INFLUENCERS"]) {
  63987. uniformsList.push("morphTargetInfluences");
  63988. }
  63989. };
  63990. /**
  63991. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  63992. * @param defines The defines to update while falling back
  63993. * @param fallbacks The authorized effect fallbacks
  63994. * @param maxSimultaneousLights The maximum number of lights allowed
  63995. * @param rank the current rank of the Effect
  63996. * @returns The newly affected rank
  63997. */
  63998. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  63999. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64000. if (rank === void 0) { rank = 0; }
  64001. var lightFallbackRank = 0;
  64002. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  64003. if (!defines["LIGHT" + lightIndex]) {
  64004. break;
  64005. }
  64006. if (lightIndex > 0) {
  64007. lightFallbackRank = rank + lightIndex;
  64008. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  64009. }
  64010. if (!defines["SHADOWS"]) {
  64011. if (defines["SHADOW" + lightIndex]) {
  64012. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  64013. }
  64014. if (defines["SHADOWPCF" + lightIndex]) {
  64015. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  64016. }
  64017. if (defines["SHADOWPCSS" + lightIndex]) {
  64018. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  64019. }
  64020. if (defines["SHADOWPOISSON" + lightIndex]) {
  64021. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  64022. }
  64023. if (defines["SHADOWESM" + lightIndex]) {
  64024. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  64025. }
  64026. }
  64027. }
  64028. return lightFallbackRank++;
  64029. };
  64030. /**
  64031. * Prepares the list of attributes required for morph targets according to the effect defines.
  64032. * @param attribs The current list of supported attribs
  64033. * @param mesh The mesh to prepare the morph targets attributes for
  64034. * @param defines The current Defines of the effect
  64035. */
  64036. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  64037. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  64038. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  64039. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  64040. var manager = mesh.morphTargetManager;
  64041. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  64042. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  64043. for (var index = 0; index < influencers; index++) {
  64044. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  64045. if (normal) {
  64046. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  64047. }
  64048. if (tangent) {
  64049. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  64050. }
  64051. if (attribs.length > maxAttributesCount) {
  64052. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  64053. }
  64054. }
  64055. }
  64056. };
  64057. /**
  64058. * Prepares the list of attributes required for bones according to the effect defines.
  64059. * @param attribs The current list of supported attribs
  64060. * @param mesh The mesh to prepare the bones attributes for
  64061. * @param defines The current Defines of the effect
  64062. * @param fallbacks The current efffect fallback strategy
  64063. */
  64064. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  64065. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  64066. fallbacks.addCPUSkinningFallback(0, mesh);
  64067. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  64068. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  64069. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  64070. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  64071. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  64072. }
  64073. }
  64074. };
  64075. /**
  64076. * Prepares the list of attributes required for instances according to the effect defines.
  64077. * @param attribs The current list of supported attribs
  64078. * @param defines The current Defines of the effect
  64079. */
  64080. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  64081. if (defines["INSTANCES"]) {
  64082. attribs.push("world0");
  64083. attribs.push("world1");
  64084. attribs.push("world2");
  64085. attribs.push("world3");
  64086. }
  64087. };
  64088. /**
  64089. * Binds the light shadow information to the effect for the given mesh.
  64090. * @param light The light containing the generator
  64091. * @param scene The scene the lights belongs to
  64092. * @param mesh The mesh we are binding the information to render
  64093. * @param lightIndex The light index in the effect used to render the mesh
  64094. * @param effect The effect we are binding the data to
  64095. */
  64096. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  64097. if (light.shadowEnabled && mesh.receiveShadows) {
  64098. var shadowGenerator = light.getShadowGenerator();
  64099. if (shadowGenerator) {
  64100. shadowGenerator.bindShadowLight(lightIndex, effect);
  64101. }
  64102. }
  64103. };
  64104. /**
  64105. * Binds the light information to the effect.
  64106. * @param light The light containing the generator
  64107. * @param effect The effect we are binding the data to
  64108. * @param lightIndex The light index in the effect used to render
  64109. */
  64110. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  64111. light.transferToEffect(effect, lightIndex + "");
  64112. };
  64113. /**
  64114. * Binds the lights information from the scene to the effect for the given mesh.
  64115. * @param scene The scene the lights belongs to
  64116. * @param mesh The mesh we are binding the information to render
  64117. * @param effect The effect we are binding the data to
  64118. * @param defines The generated defines for the effect
  64119. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  64120. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  64121. */
  64122. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  64123. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64124. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  64125. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  64126. for (var i = 0; i < len; i++) {
  64127. var light = mesh._lightSources[i];
  64128. var iAsString = i.toString();
  64129. var scaledIntensity = light.getScaledIntensity();
  64130. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  64131. MaterialHelper.BindLightProperties(light, effect, i);
  64132. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  64133. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  64134. if (defines["SPECULARTERM"]) {
  64135. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  64136. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  64137. }
  64138. // Shadows
  64139. if (scene.shadowsEnabled) {
  64140. this.BindLightShadow(light, mesh, iAsString, effect);
  64141. }
  64142. light._uniformBuffer.update();
  64143. }
  64144. };
  64145. /**
  64146. * Binds the fog information from the scene to the effect for the given mesh.
  64147. * @param scene The scene the lights belongs to
  64148. * @param mesh The mesh we are binding the information to render
  64149. * @param effect The effect we are binding the data to
  64150. * @param linearSpace Defines if the fog effect is applied in linear space
  64151. */
  64152. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  64153. if (linearSpace === void 0) { linearSpace = false; }
  64154. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  64155. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  64156. // Convert fog color to linear space if used in a linear space computed shader.
  64157. if (linearSpace) {
  64158. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  64159. effect.setColor3("vFogColor", this._tempFogColor);
  64160. }
  64161. else {
  64162. effect.setColor3("vFogColor", scene.fogColor);
  64163. }
  64164. }
  64165. };
  64166. /**
  64167. * Binds the bones information from the mesh to the effect.
  64168. * @param mesh The mesh we are binding the information to render
  64169. * @param effect The effect we are binding the data to
  64170. */
  64171. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  64172. if (!effect || !mesh) {
  64173. return;
  64174. }
  64175. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  64176. mesh.computeBonesUsingShaders = false;
  64177. }
  64178. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64179. var skeleton = mesh.skeleton;
  64180. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  64181. var boneTexture = skeleton.getTransformMatrixTexture();
  64182. effect.setTexture("boneSampler", boneTexture);
  64183. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  64184. }
  64185. else {
  64186. var matrices = skeleton.getTransformMatrices(mesh);
  64187. if (matrices) {
  64188. effect.setMatrices("mBones", matrices);
  64189. }
  64190. }
  64191. }
  64192. };
  64193. /**
  64194. * Binds the morph targets information from the mesh to the effect.
  64195. * @param abstractMesh The mesh we are binding the information to render
  64196. * @param effect The effect we are binding the data to
  64197. */
  64198. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  64199. var manager = abstractMesh.morphTargetManager;
  64200. if (!abstractMesh || !manager) {
  64201. return;
  64202. }
  64203. effect.setFloatArray("morphTargetInfluences", manager.influences);
  64204. };
  64205. /**
  64206. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  64207. * @param defines The generated defines used in the effect
  64208. * @param effect The effect we are binding the data to
  64209. * @param scene The scene we are willing to render with logarithmic scale for
  64210. */
  64211. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  64212. if (defines["LOGARITHMICDEPTH"]) {
  64213. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  64214. }
  64215. };
  64216. /**
  64217. * Binds the clip plane information from the scene to the effect.
  64218. * @param scene The scene the clip plane information are extracted from
  64219. * @param effect The effect we are binding the data to
  64220. */
  64221. MaterialHelper.BindClipPlane = function (effect, scene) {
  64222. if (scene.clipPlane) {
  64223. var clipPlane = scene.clipPlane;
  64224. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64225. }
  64226. if (scene.clipPlane2) {
  64227. var clipPlane = scene.clipPlane2;
  64228. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64229. }
  64230. if (scene.clipPlane3) {
  64231. var clipPlane = scene.clipPlane3;
  64232. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64233. }
  64234. if (scene.clipPlane4) {
  64235. var clipPlane = scene.clipPlane4;
  64236. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64237. }
  64238. };
  64239. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  64240. return MaterialHelper;
  64241. }());
  64242. /***/ }),
  64243. /***/ "./Materials/multiMaterial.ts":
  64244. /*!************************************!*\
  64245. !*** ./Materials/multiMaterial.ts ***!
  64246. \************************************/
  64247. /*! exports provided: MultiMaterial */
  64248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64249. "use strict";
  64250. __webpack_require__.r(__webpack_exports__);
  64251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  64252. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64253. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64254. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  64255. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64256. /**
  64257. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64258. * separate meshes. This can be use to improve performances.
  64259. * @see http://doc.babylonjs.com/how_to/multi_materials
  64260. */
  64261. var MultiMaterial = /** @class */ (function (_super) {
  64262. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  64263. /**
  64264. * Instantiates a new Multi Material
  64265. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64266. * separate meshes. This can be use to improve performances.
  64267. * @see http://doc.babylonjs.com/how_to/multi_materials
  64268. * @param name Define the name in the scene
  64269. * @param scene Define the scene the material belongs to
  64270. */
  64271. function MultiMaterial(name, scene) {
  64272. var _this = _super.call(this, name, scene, true) || this;
  64273. scene.multiMaterials.push(_this);
  64274. _this.subMaterials = new Array();
  64275. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  64276. return _this;
  64277. }
  64278. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  64279. /**
  64280. * Gets or Sets the list of Materials used within the multi material.
  64281. * They need to be ordered according to the submeshes order in the associated mesh
  64282. */
  64283. get: function () {
  64284. return this._subMaterials;
  64285. },
  64286. set: function (value) {
  64287. this._subMaterials = value;
  64288. this._hookArray(value);
  64289. },
  64290. enumerable: true,
  64291. configurable: true
  64292. });
  64293. /**
  64294. * Function used to align with Node.getChildren()
  64295. * @returns the list of Materials used within the multi material
  64296. */
  64297. MultiMaterial.prototype.getChildren = function () {
  64298. return this.subMaterials;
  64299. };
  64300. MultiMaterial.prototype._hookArray = function (array) {
  64301. var _this = this;
  64302. var oldPush = array.push;
  64303. array.push = function () {
  64304. var items = [];
  64305. for (var _i = 0; _i < arguments.length; _i++) {
  64306. items[_i] = arguments[_i];
  64307. }
  64308. var result = oldPush.apply(array, items);
  64309. _this._markAllSubMeshesAsTexturesDirty();
  64310. return result;
  64311. };
  64312. var oldSplice = array.splice;
  64313. array.splice = function (index, deleteCount) {
  64314. var deleted = oldSplice.apply(array, [index, deleteCount]);
  64315. _this._markAllSubMeshesAsTexturesDirty();
  64316. return deleted;
  64317. };
  64318. };
  64319. /**
  64320. * Get one of the submaterial by its index in the submaterials array
  64321. * @param index The index to look the sub material at
  64322. * @returns The Material if the index has been defined
  64323. */
  64324. MultiMaterial.prototype.getSubMaterial = function (index) {
  64325. if (index < 0 || index >= this.subMaterials.length) {
  64326. return this.getScene().defaultMaterial;
  64327. }
  64328. return this.subMaterials[index];
  64329. };
  64330. /**
  64331. * Get the list of active textures for the whole sub materials list.
  64332. * @returns All the textures that will be used during the rendering
  64333. */
  64334. MultiMaterial.prototype.getActiveTextures = function () {
  64335. var _a;
  64336. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  64337. if (subMaterial) {
  64338. return subMaterial.getActiveTextures();
  64339. }
  64340. else {
  64341. return [];
  64342. }
  64343. }));
  64344. };
  64345. /**
  64346. * Gets the current class name of the material e.g. "MultiMaterial"
  64347. * Mainly use in serialization.
  64348. * @returns the class name
  64349. */
  64350. MultiMaterial.prototype.getClassName = function () {
  64351. return "MultiMaterial";
  64352. };
  64353. /**
  64354. * Checks if the material is ready to render the requested sub mesh
  64355. * @param mesh Define the mesh the submesh belongs to
  64356. * @param subMesh Define the sub mesh to look readyness for
  64357. * @param useInstances Define whether or not the material is used with instances
  64358. * @returns true if ready, otherwise false
  64359. */
  64360. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64361. for (var index = 0; index < this.subMaterials.length; index++) {
  64362. var subMaterial = this.subMaterials[index];
  64363. if (subMaterial) {
  64364. if (subMaterial._storeEffectOnSubMeshes) {
  64365. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  64366. return false;
  64367. }
  64368. continue;
  64369. }
  64370. if (!subMaterial.isReady(mesh)) {
  64371. return false;
  64372. }
  64373. }
  64374. }
  64375. return true;
  64376. };
  64377. /**
  64378. * Clones the current material and its related sub materials
  64379. * @param name Define the name of the newly cloned material
  64380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64381. * @returns the cloned material
  64382. */
  64383. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  64384. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  64385. for (var index = 0; index < this.subMaterials.length; index++) {
  64386. var subMaterial = null;
  64387. var current = this.subMaterials[index];
  64388. if (cloneChildren && current) {
  64389. subMaterial = current.clone(name + "-" + current.name);
  64390. }
  64391. else {
  64392. subMaterial = this.subMaterials[index];
  64393. }
  64394. newMultiMaterial.subMaterials.push(subMaterial);
  64395. }
  64396. return newMultiMaterial;
  64397. };
  64398. /**
  64399. * Serializes the materials into a JSON representation.
  64400. * @returns the JSON representation
  64401. */
  64402. MultiMaterial.prototype.serialize = function () {
  64403. var serializationObject = {};
  64404. serializationObject.name = this.name;
  64405. serializationObject.id = this.id;
  64406. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64407. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  64408. }
  64409. serializationObject.materials = [];
  64410. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  64411. var subMat = this.subMaterials[matIndex];
  64412. if (subMat) {
  64413. serializationObject.materials.push(subMat.id);
  64414. }
  64415. else {
  64416. serializationObject.materials.push(null);
  64417. }
  64418. }
  64419. return serializationObject;
  64420. };
  64421. /**
  64422. * Dispose the material and release its associated resources
  64423. * @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)
  64424. * @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)
  64425. * @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)
  64426. */
  64427. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  64428. var scene = this.getScene();
  64429. if (!scene) {
  64430. return;
  64431. }
  64432. if (forceDisposeChildren) {
  64433. for (var index = 0; index < this.subMaterials.length; index++) {
  64434. var subMaterial = this.subMaterials[index];
  64435. if (subMaterial) {
  64436. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  64437. }
  64438. }
  64439. }
  64440. var index = scene.multiMaterials.indexOf(this);
  64441. if (index >= 0) {
  64442. scene.multiMaterials.splice(index, 1);
  64443. }
  64444. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  64445. };
  64446. /**
  64447. * Creates a MultiMaterial from parsed MultiMaterial data.
  64448. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64449. * @param scene defines the hosting scene
  64450. * @returns a new MultiMaterial
  64451. */
  64452. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  64453. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  64454. multiMaterial.id = parsedMultiMaterial.id;
  64455. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64456. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  64457. }
  64458. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  64459. var subMatId = parsedMultiMaterial.materials[matIndex];
  64460. if (subMatId) {
  64461. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  64462. }
  64463. else {
  64464. multiMaterial.subMaterials.push(null);
  64465. }
  64466. }
  64467. return multiMaterial;
  64468. };
  64469. return MultiMaterial;
  64470. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  64471. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  64472. /***/ }),
  64473. /***/ "./Materials/pushMaterial.ts":
  64474. /*!***********************************!*\
  64475. !*** ./Materials/pushMaterial.ts ***!
  64476. \***********************************/
  64477. /*! exports provided: PushMaterial */
  64478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64479. "use strict";
  64480. __webpack_require__.r(__webpack_exports__);
  64481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  64482. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64483. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64484. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64485. /**
  64486. * Base class of materials working in push mode in babylon JS
  64487. * @hidden
  64488. */
  64489. var PushMaterial = /** @class */ (function (_super) {
  64490. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  64491. function PushMaterial(name, scene) {
  64492. var _this = _super.call(this, name, scene) || this;
  64493. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  64494. /**
  64495. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  64496. * This means that the material can keep using a previous shader while a new one is being compiled.
  64497. * This is mostly used when shader parallel compilation is supported (true by default)
  64498. */
  64499. _this.allowShaderHotSwapping = true;
  64500. _this._storeEffectOnSubMeshes = true;
  64501. return _this;
  64502. }
  64503. PushMaterial.prototype.getEffect = function () {
  64504. return this._activeEffect;
  64505. };
  64506. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  64507. if (!mesh) {
  64508. return false;
  64509. }
  64510. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  64511. return true;
  64512. }
  64513. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  64514. };
  64515. /**
  64516. * Binds the given world matrix to the active effect
  64517. *
  64518. * @param world the matrix to bind
  64519. */
  64520. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64521. this._activeEffect.setMatrix("world", world);
  64522. };
  64523. /**
  64524. * Binds the given normal matrix to the active effect
  64525. *
  64526. * @param normalMatrix the matrix to bind
  64527. */
  64528. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  64529. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  64530. };
  64531. PushMaterial.prototype.bind = function (world, mesh) {
  64532. if (!mesh) {
  64533. return;
  64534. }
  64535. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  64536. };
  64537. PushMaterial.prototype._afterBind = function (mesh, effect) {
  64538. if (effect === void 0) { effect = null; }
  64539. _super.prototype._afterBind.call(this, mesh);
  64540. this.getScene()._cachedEffect = effect;
  64541. };
  64542. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  64543. if (visibility === void 0) { visibility = 1; }
  64544. return scene.isCachedMaterialInvalid(this, effect, visibility);
  64545. };
  64546. return PushMaterial;
  64547. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  64548. /***/ }),
  64549. /***/ "./Materials/shaderMaterial.ts":
  64550. /*!*************************************!*\
  64551. !*** ./Materials/shaderMaterial.ts ***!
  64552. \*************************************/
  64553. /*! exports provided: ShaderMaterial */
  64554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64555. "use strict";
  64556. __webpack_require__.r(__webpack_exports__);
  64557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  64558. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64559. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64560. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64561. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64562. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  64563. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64564. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64565. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  64566. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64567. /**
  64568. * 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.
  64569. *
  64570. * This returned material effects how the mesh will look based on the code in the shaders.
  64571. *
  64572. * @see http://doc.babylonjs.com/how_to/shader_material
  64573. */
  64574. var ShaderMaterial = /** @class */ (function (_super) {
  64575. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  64576. /**
  64577. * Instantiate a new shader material.
  64578. * 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.
  64579. * This returned material effects how the mesh will look based on the code in the shaders.
  64580. * @see http://doc.babylonjs.com/how_to/shader_material
  64581. * @param name Define the name of the material in the scene
  64582. * @param scene Define the scene the material belongs to
  64583. * @param shaderPath Defines the route to the shader code in one of three ways:
  64584. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  64585. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  64586. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  64587. * @param options Define the options used to create the shader
  64588. */
  64589. function ShaderMaterial(name, scene, shaderPath, options) {
  64590. if (options === void 0) { options = {}; }
  64591. var _this = _super.call(this, name, scene) || this;
  64592. _this._textures = {};
  64593. _this._textureArrays = {};
  64594. _this._floats = {};
  64595. _this._ints = {};
  64596. _this._floatsArrays = {};
  64597. _this._colors3 = {};
  64598. _this._colors3Arrays = {};
  64599. _this._colors4 = {};
  64600. _this._vectors2 = {};
  64601. _this._vectors3 = {};
  64602. _this._vectors4 = {};
  64603. _this._matrices = {};
  64604. _this._matrices3x3 = {};
  64605. _this._matrices2x2 = {};
  64606. _this._vectors2Arrays = {};
  64607. _this._vectors3Arrays = {};
  64608. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  64609. _this._shaderPath = shaderPath;
  64610. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  64611. return _this;
  64612. }
  64613. /**
  64614. * Gets the current class name of the material e.g. "ShaderMaterial"
  64615. * Mainly use in serialization.
  64616. * @returns the class name
  64617. */
  64618. ShaderMaterial.prototype.getClassName = function () {
  64619. return "ShaderMaterial";
  64620. };
  64621. /**
  64622. * Specifies if the material will require alpha blending
  64623. * @returns a boolean specifying if alpha blending is needed
  64624. */
  64625. ShaderMaterial.prototype.needAlphaBlending = function () {
  64626. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  64627. };
  64628. /**
  64629. * Specifies if this material should be rendered in alpha test mode
  64630. * @returns a boolean specifying if an alpha test is needed.
  64631. */
  64632. ShaderMaterial.prototype.needAlphaTesting = function () {
  64633. return this._options.needAlphaTesting;
  64634. };
  64635. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  64636. if (this._options.uniforms.indexOf(uniformName) === -1) {
  64637. this._options.uniforms.push(uniformName);
  64638. }
  64639. };
  64640. /**
  64641. * Set a texture in the shader.
  64642. * @param name Define the name of the uniform samplers as defined in the shader
  64643. * @param texture Define the texture to bind to this sampler
  64644. * @return the material itself allowing "fluent" like uniform updates
  64645. */
  64646. ShaderMaterial.prototype.setTexture = function (name, texture) {
  64647. if (this._options.samplers.indexOf(name) === -1) {
  64648. this._options.samplers.push(name);
  64649. }
  64650. this._textures[name] = texture;
  64651. return this;
  64652. };
  64653. /**
  64654. * Set a texture array in the shader.
  64655. * @param name Define the name of the uniform sampler array as defined in the shader
  64656. * @param textures Define the list of textures to bind to this sampler
  64657. * @return the material itself allowing "fluent" like uniform updates
  64658. */
  64659. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  64660. if (this._options.samplers.indexOf(name) === -1) {
  64661. this._options.samplers.push(name);
  64662. }
  64663. this._checkUniform(name);
  64664. this._textureArrays[name] = textures;
  64665. return this;
  64666. };
  64667. /**
  64668. * Set a float in the shader.
  64669. * @param name Define the name of the uniform as defined in the shader
  64670. * @param value Define the value to give to the uniform
  64671. * @return the material itself allowing "fluent" like uniform updates
  64672. */
  64673. ShaderMaterial.prototype.setFloat = function (name, value) {
  64674. this._checkUniform(name);
  64675. this._floats[name] = value;
  64676. return this;
  64677. };
  64678. /**
  64679. * Set a int in the shader.
  64680. * @param name Define the name of the uniform as defined in the shader
  64681. * @param value Define the value to give to the uniform
  64682. * @return the material itself allowing "fluent" like uniform updates
  64683. */
  64684. ShaderMaterial.prototype.setInt = function (name, value) {
  64685. this._checkUniform(name);
  64686. this._ints[name] = value;
  64687. return this;
  64688. };
  64689. /**
  64690. * Set an array of floats in the shader.
  64691. * @param name Define the name of the uniform as defined in the shader
  64692. * @param value Define the value to give to the uniform
  64693. * @return the material itself allowing "fluent" like uniform updates
  64694. */
  64695. ShaderMaterial.prototype.setFloats = function (name, value) {
  64696. this._checkUniform(name);
  64697. this._floatsArrays[name] = value;
  64698. return this;
  64699. };
  64700. /**
  64701. * Set a vec3 in the shader from a Color3.
  64702. * @param name Define the name of the uniform as defined in the shader
  64703. * @param value Define the value to give to the uniform
  64704. * @return the material itself allowing "fluent" like uniform updates
  64705. */
  64706. ShaderMaterial.prototype.setColor3 = function (name, value) {
  64707. this._checkUniform(name);
  64708. this._colors3[name] = value;
  64709. return this;
  64710. };
  64711. /**
  64712. * Set a vec3 array in the shader from a Color3 array.
  64713. * @param name Define the name of the uniform as defined in the shader
  64714. * @param value Define the value to give to the uniform
  64715. * @return the material itself allowing "fluent" like uniform updates
  64716. */
  64717. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  64718. this._checkUniform(name);
  64719. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  64720. color.toArray(arr, arr.length);
  64721. return arr;
  64722. }, []);
  64723. return this;
  64724. };
  64725. /**
  64726. * Set a vec4 in the shader from a Color4.
  64727. * @param name Define the name of the uniform as defined in the shader
  64728. * @param value Define the value to give to the uniform
  64729. * @return the material itself allowing "fluent" like uniform updates
  64730. */
  64731. ShaderMaterial.prototype.setColor4 = function (name, value) {
  64732. this._checkUniform(name);
  64733. this._colors4[name] = value;
  64734. return this;
  64735. };
  64736. /**
  64737. * Set a vec2 in the shader from a Vector2.
  64738. * @param name Define the name of the uniform as defined in the shader
  64739. * @param value Define the value to give to the uniform
  64740. * @return the material itself allowing "fluent" like uniform updates
  64741. */
  64742. ShaderMaterial.prototype.setVector2 = function (name, value) {
  64743. this._checkUniform(name);
  64744. this._vectors2[name] = value;
  64745. return this;
  64746. };
  64747. /**
  64748. * Set a vec3 in the shader from a Vector3.
  64749. * @param name Define the name of the uniform as defined in the shader
  64750. * @param value Define the value to give to the uniform
  64751. * @return the material itself allowing "fluent" like uniform updates
  64752. */
  64753. ShaderMaterial.prototype.setVector3 = function (name, value) {
  64754. this._checkUniform(name);
  64755. this._vectors3[name] = value;
  64756. return this;
  64757. };
  64758. /**
  64759. * Set a vec4 in the shader from a Vector4.
  64760. * @param name Define the name of the uniform as defined in the shader
  64761. * @param value Define the value to give to the uniform
  64762. * @return the material itself allowing "fluent" like uniform updates
  64763. */
  64764. ShaderMaterial.prototype.setVector4 = function (name, value) {
  64765. this._checkUniform(name);
  64766. this._vectors4[name] = value;
  64767. return this;
  64768. };
  64769. /**
  64770. * Set a mat4 in the shader from a Matrix.
  64771. * @param name Define the name of the uniform as defined in the shader
  64772. * @param value Define the value to give to the uniform
  64773. * @return the material itself allowing "fluent" like uniform updates
  64774. */
  64775. ShaderMaterial.prototype.setMatrix = function (name, value) {
  64776. this._checkUniform(name);
  64777. this._matrices[name] = value;
  64778. return this;
  64779. };
  64780. /**
  64781. * Set a mat3 in the shader from a Float32Array.
  64782. * @param name Define the name of the uniform as defined in the shader
  64783. * @param value Define the value to give to the uniform
  64784. * @return the material itself allowing "fluent" like uniform updates
  64785. */
  64786. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  64787. this._checkUniform(name);
  64788. this._matrices3x3[name] = value;
  64789. return this;
  64790. };
  64791. /**
  64792. * Set a mat2 in the shader from a Float32Array.
  64793. * @param name Define the name of the uniform as defined in the shader
  64794. * @param value Define the value to give to the uniform
  64795. * @return the material itself allowing "fluent" like uniform updates
  64796. */
  64797. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  64798. this._checkUniform(name);
  64799. this._matrices2x2[name] = value;
  64800. return this;
  64801. };
  64802. /**
  64803. * Set a vec2 array in the shader from a number array.
  64804. * @param name Define the name of the uniform as defined in the shader
  64805. * @param value Define the value to give to the uniform
  64806. * @return the material itself allowing "fluent" like uniform updates
  64807. */
  64808. ShaderMaterial.prototype.setArray2 = function (name, value) {
  64809. this._checkUniform(name);
  64810. this._vectors2Arrays[name] = value;
  64811. return this;
  64812. };
  64813. /**
  64814. * Set a vec3 array in the shader from a number array.
  64815. * @param name Define the name of the uniform as defined in the shader
  64816. * @param value Define the value to give to the uniform
  64817. * @return the material itself allowing "fluent" like uniform updates
  64818. */
  64819. ShaderMaterial.prototype.setArray3 = function (name, value) {
  64820. this._checkUniform(name);
  64821. this._vectors3Arrays[name] = value;
  64822. return this;
  64823. };
  64824. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  64825. if (!mesh) {
  64826. return true;
  64827. }
  64828. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  64829. return false;
  64830. }
  64831. return false;
  64832. };
  64833. /**
  64834. * Checks if the material is ready to render the requested mesh
  64835. * @param mesh Define the mesh to render
  64836. * @param useInstances Define whether or not the material is used with instances
  64837. * @returns true if ready, otherwise false
  64838. */
  64839. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  64840. var scene = this.getScene();
  64841. var engine = scene.getEngine();
  64842. if (!this.checkReadyOnEveryCall) {
  64843. if (this._renderId === scene.getRenderId()) {
  64844. if (this._checkCache(mesh, useInstances)) {
  64845. return true;
  64846. }
  64847. }
  64848. }
  64849. // Instances
  64850. var defines = [];
  64851. var attribs = [];
  64852. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  64853. for (var index = 0; index < this._options.defines.length; index++) {
  64854. defines.push(this._options.defines[index]);
  64855. }
  64856. for (var index = 0; index < this._options.attributes.length; index++) {
  64857. attribs.push(this._options.attributes[index]);
  64858. }
  64859. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  64860. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  64861. defines.push("#define VERTEXCOLOR");
  64862. }
  64863. if (useInstances) {
  64864. defines.push("#define INSTANCES");
  64865. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  64866. }
  64867. // Bones
  64868. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64869. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  64870. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  64871. if (mesh.numBoneInfluencers > 4) {
  64872. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  64873. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  64874. }
  64875. var skeleton = mesh.skeleton;
  64876. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  64877. fallbacks.addCPUSkinningFallback(0, mesh);
  64878. if (skeleton.isUsingTextureForMatrices) {
  64879. defines.push("#define BONETEXTURE");
  64880. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  64881. this._options.uniforms.push("boneTextureWidth");
  64882. }
  64883. if (this._options.samplers.indexOf("boneSampler") === -1) {
  64884. this._options.samplers.push("boneSampler");
  64885. }
  64886. }
  64887. else {
  64888. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  64889. if (this._options.uniforms.indexOf("mBones") === -1) {
  64890. this._options.uniforms.push("mBones");
  64891. }
  64892. }
  64893. }
  64894. else {
  64895. defines.push("#define NUM_BONE_INFLUENCERS 0");
  64896. }
  64897. // Textures
  64898. for (var name in this._textures) {
  64899. if (!this._textures[name].isReady()) {
  64900. return false;
  64901. }
  64902. }
  64903. // Alpha test
  64904. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  64905. defines.push("#define ALPHATEST");
  64906. }
  64907. var previousEffect = this._effect;
  64908. var join = defines.join("\n");
  64909. this._effect = engine.createEffect(this._shaderPath, {
  64910. attributes: attribs,
  64911. uniformsNames: this._options.uniforms,
  64912. uniformBuffersNames: this._options.uniformBuffers,
  64913. samplers: this._options.samplers,
  64914. defines: join,
  64915. fallbacks: fallbacks,
  64916. onCompiled: this.onCompiled,
  64917. onError: this.onError
  64918. }, engine);
  64919. if (!this._effect.isReady()) {
  64920. return false;
  64921. }
  64922. if (previousEffect !== this._effect) {
  64923. scene.resetCachedMaterial();
  64924. }
  64925. this._renderId = scene.getRenderId();
  64926. return true;
  64927. };
  64928. /**
  64929. * Binds the world matrix to the material
  64930. * @param world defines the world transformation matrix
  64931. */
  64932. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64933. var scene = this.getScene();
  64934. if (!this._effect) {
  64935. return;
  64936. }
  64937. if (this._options.uniforms.indexOf("world") !== -1) {
  64938. this._effect.setMatrix("world", world);
  64939. }
  64940. if (this._options.uniforms.indexOf("worldView") !== -1) {
  64941. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  64942. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  64943. }
  64944. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  64945. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  64946. }
  64947. };
  64948. /**
  64949. * Binds the material to the mesh
  64950. * @param world defines the world transformation matrix
  64951. * @param mesh defines the mesh to bind the material to
  64952. */
  64953. ShaderMaterial.prototype.bind = function (world, mesh) {
  64954. // Std values
  64955. this.bindOnlyWorldMatrix(world);
  64956. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  64957. if (this._options.uniforms.indexOf("view") !== -1) {
  64958. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  64959. }
  64960. if (this._options.uniforms.indexOf("projection") !== -1) {
  64961. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  64962. }
  64963. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  64964. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64965. }
  64966. // Bones
  64967. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  64968. var name;
  64969. // Texture
  64970. for (name in this._textures) {
  64971. this._effect.setTexture(name, this._textures[name]);
  64972. }
  64973. // Texture arrays
  64974. for (name in this._textureArrays) {
  64975. this._effect.setTextureArray(name, this._textureArrays[name]);
  64976. }
  64977. // Int
  64978. for (name in this._ints) {
  64979. this._effect.setInt(name, this._ints[name]);
  64980. }
  64981. // Float
  64982. for (name in this._floats) {
  64983. this._effect.setFloat(name, this._floats[name]);
  64984. }
  64985. // Floats
  64986. for (name in this._floatsArrays) {
  64987. this._effect.setArray(name, this._floatsArrays[name]);
  64988. }
  64989. // Color3
  64990. for (name in this._colors3) {
  64991. this._effect.setColor3(name, this._colors3[name]);
  64992. }
  64993. for (name in this._colors3Arrays) {
  64994. this._effect.setArray3(name, this._colors3Arrays[name]);
  64995. }
  64996. // Color4
  64997. for (name in this._colors4) {
  64998. var color = this._colors4[name];
  64999. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  65000. }
  65001. // Vector2
  65002. for (name in this._vectors2) {
  65003. this._effect.setVector2(name, this._vectors2[name]);
  65004. }
  65005. // Vector3
  65006. for (name in this._vectors3) {
  65007. this._effect.setVector3(name, this._vectors3[name]);
  65008. }
  65009. // Vector4
  65010. for (name in this._vectors4) {
  65011. this._effect.setVector4(name, this._vectors4[name]);
  65012. }
  65013. // Matrix
  65014. for (name in this._matrices) {
  65015. this._effect.setMatrix(name, this._matrices[name]);
  65016. }
  65017. // Matrix 3x3
  65018. for (name in this._matrices3x3) {
  65019. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  65020. }
  65021. // Matrix 2x2
  65022. for (name in this._matrices2x2) {
  65023. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  65024. }
  65025. // Vector2Array
  65026. for (name in this._vectors2Arrays) {
  65027. this._effect.setArray2(name, this._vectors2Arrays[name]);
  65028. }
  65029. // Vector3Array
  65030. for (name in this._vectors3Arrays) {
  65031. this._effect.setArray3(name, this._vectors3Arrays[name]);
  65032. }
  65033. }
  65034. this._afterBind(mesh);
  65035. };
  65036. /**
  65037. * Gets the active textures from the material
  65038. * @returns an array of textures
  65039. */
  65040. ShaderMaterial.prototype.getActiveTextures = function () {
  65041. var activeTextures = _super.prototype.getActiveTextures.call(this);
  65042. for (var name in this._textures) {
  65043. activeTextures.push(this._textures[name]);
  65044. }
  65045. for (var name in this._textureArrays) {
  65046. var array = this._textureArrays[name];
  65047. for (var index = 0; index < array.length; index++) {
  65048. activeTextures.push(array[index]);
  65049. }
  65050. }
  65051. return activeTextures;
  65052. };
  65053. /**
  65054. * Specifies if the material uses a texture
  65055. * @param texture defines the texture to check against the material
  65056. * @returns a boolean specifying if the material uses the texture
  65057. */
  65058. ShaderMaterial.prototype.hasTexture = function (texture) {
  65059. if (_super.prototype.hasTexture.call(this, texture)) {
  65060. return true;
  65061. }
  65062. for (var name in this._textures) {
  65063. if (this._textures[name] === texture) {
  65064. return true;
  65065. }
  65066. }
  65067. for (var name in this._textureArrays) {
  65068. var array = this._textureArrays[name];
  65069. for (var index = 0; index < array.length; index++) {
  65070. if (array[index] === texture) {
  65071. return true;
  65072. }
  65073. }
  65074. }
  65075. return false;
  65076. };
  65077. /**
  65078. * Makes a duplicate of the material, and gives it a new name
  65079. * @param name defines the new name for the duplicated material
  65080. * @returns the cloned material
  65081. */
  65082. ShaderMaterial.prototype.clone = function (name) {
  65083. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  65084. return newShaderMaterial;
  65085. };
  65086. /**
  65087. * Disposes the material
  65088. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65089. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65090. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  65091. */
  65092. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  65093. if (forceDisposeTextures) {
  65094. var name;
  65095. for (name in this._textures) {
  65096. this._textures[name].dispose();
  65097. }
  65098. for (name in this._textureArrays) {
  65099. var array = this._textureArrays[name];
  65100. for (var index = 0; index < array.length; index++) {
  65101. array[index].dispose();
  65102. }
  65103. }
  65104. }
  65105. this._textures = {};
  65106. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  65107. };
  65108. /**
  65109. * Serializes this material in a JSON representation
  65110. * @returns the serialized material object
  65111. */
  65112. ShaderMaterial.prototype.serialize = function () {
  65113. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65114. serializationObject.customType = "ShaderMaterial";
  65115. serializationObject.options = this._options;
  65116. serializationObject.shaderPath = this._shaderPath;
  65117. var name;
  65118. // Texture
  65119. serializationObject.textures = {};
  65120. for (name in this._textures) {
  65121. serializationObject.textures[name] = this._textures[name].serialize();
  65122. }
  65123. // Texture arrays
  65124. serializationObject.textureArrays = {};
  65125. for (name in this._textureArrays) {
  65126. serializationObject.textureArrays[name] = [];
  65127. var array = this._textureArrays[name];
  65128. for (var index = 0; index < array.length; index++) {
  65129. serializationObject.textureArrays[name].push(array[index].serialize());
  65130. }
  65131. }
  65132. // Float
  65133. serializationObject.floats = {};
  65134. for (name in this._floats) {
  65135. serializationObject.floats[name] = this._floats[name];
  65136. }
  65137. // Float s
  65138. serializationObject.FloatArrays = {};
  65139. for (name in this._floatsArrays) {
  65140. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  65141. }
  65142. // Color3
  65143. serializationObject.colors3 = {};
  65144. for (name in this._colors3) {
  65145. serializationObject.colors3[name] = this._colors3[name].asArray();
  65146. }
  65147. // Color3 array
  65148. serializationObject.colors3Arrays = {};
  65149. for (name in this._colors3Arrays) {
  65150. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  65151. }
  65152. // Color4
  65153. serializationObject.colors4 = {};
  65154. for (name in this._colors4) {
  65155. serializationObject.colors4[name] = this._colors4[name].asArray();
  65156. }
  65157. // Vector2
  65158. serializationObject.vectors2 = {};
  65159. for (name in this._vectors2) {
  65160. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  65161. }
  65162. // Vector3
  65163. serializationObject.vectors3 = {};
  65164. for (name in this._vectors3) {
  65165. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  65166. }
  65167. // Vector4
  65168. serializationObject.vectors4 = {};
  65169. for (name in this._vectors4) {
  65170. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  65171. }
  65172. // Matrix
  65173. serializationObject.matrices = {};
  65174. for (name in this._matrices) {
  65175. serializationObject.matrices[name] = this._matrices[name].asArray();
  65176. }
  65177. // Matrix 3x3
  65178. serializationObject.matrices3x3 = {};
  65179. for (name in this._matrices3x3) {
  65180. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  65181. }
  65182. // Matrix 2x2
  65183. serializationObject.matrices2x2 = {};
  65184. for (name in this._matrices2x2) {
  65185. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  65186. }
  65187. // Vector2Array
  65188. serializationObject.vectors2Arrays = {};
  65189. for (name in this._vectors2Arrays) {
  65190. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  65191. }
  65192. // Vector3Array
  65193. serializationObject.vectors3Arrays = {};
  65194. for (name in this._vectors3Arrays) {
  65195. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  65196. }
  65197. return serializationObject;
  65198. };
  65199. /**
  65200. * Creates a shader material from parsed shader material data
  65201. * @param source defines the JSON represnetation of the material
  65202. * @param scene defines the hosting scene
  65203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65204. * @returns a new material
  65205. */
  65206. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  65207. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  65208. var name;
  65209. // Texture
  65210. for (name in source.textures) {
  65211. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  65212. }
  65213. // Texture arrays
  65214. for (name in source.textureArrays) {
  65215. var array = source.textureArrays[name];
  65216. var textureArray = new Array();
  65217. for (var index = 0; index < array.length; index++) {
  65218. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  65219. }
  65220. material.setTextureArray(name, textureArray);
  65221. }
  65222. // Float
  65223. for (name in source.floats) {
  65224. material.setFloat(name, source.floats[name]);
  65225. }
  65226. // Float s
  65227. for (name in source.floatsArrays) {
  65228. material.setFloats(name, source.floatsArrays[name]);
  65229. }
  65230. // Color3
  65231. for (name in source.colors3) {
  65232. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  65233. }
  65234. // Color3 arrays
  65235. for (name in source.colors3Arrays) {
  65236. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  65237. if (i % 3 === 0) {
  65238. arr.push([num]);
  65239. }
  65240. else {
  65241. arr[arr.length - 1].push(num);
  65242. }
  65243. return arr;
  65244. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  65245. material.setColor3Array(name, colors);
  65246. }
  65247. // Color4
  65248. for (name in source.colors4) {
  65249. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  65250. }
  65251. // Vector2
  65252. for (name in source.vectors2) {
  65253. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  65254. }
  65255. // Vector3
  65256. for (name in source.vectors3) {
  65257. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  65258. }
  65259. // Vector4
  65260. for (name in source.vectors4) {
  65261. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  65262. }
  65263. // Matrix
  65264. for (name in source.matrices) {
  65265. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  65266. }
  65267. // Matrix 3x3
  65268. for (name in source.matrices3x3) {
  65269. material.setMatrix3x3(name, source.matrices3x3[name]);
  65270. }
  65271. // Matrix 2x2
  65272. for (name in source.matrices2x2) {
  65273. material.setMatrix2x2(name, source.matrices2x2[name]);
  65274. }
  65275. // Vector2Array
  65276. for (name in source.vectors2Arrays) {
  65277. material.setArray2(name, source.vectors2Arrays[name]);
  65278. }
  65279. // Vector3Array
  65280. for (name in source.vectors3Arrays) {
  65281. material.setArray3(name, source.vectors3Arrays[name]);
  65282. }
  65283. return material;
  65284. };
  65285. return ShaderMaterial;
  65286. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  65287. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  65288. /***/ }),
  65289. /***/ "./Materials/standardMaterial.ts":
  65290. /*!***************************************!*\
  65291. !*** ./Materials/standardMaterial.ts ***!
  65292. \***************************************/
  65293. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  65294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65295. "use strict";
  65296. __webpack_require__.r(__webpack_exports__);
  65297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  65298. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  65299. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65300. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65301. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  65302. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65303. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65304. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65305. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65306. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65307. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  65308. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65309. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65310. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65311. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65312. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65313. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  65314. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  65315. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65316. /** @hidden */
  65317. var StandardMaterialDefines = /** @class */ (function (_super) {
  65318. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  65319. function StandardMaterialDefines() {
  65320. var _this = _super.call(this) || this;
  65321. _this.MAINUV1 = false;
  65322. _this.MAINUV2 = false;
  65323. _this.DIFFUSE = false;
  65324. _this.DIFFUSEDIRECTUV = 0;
  65325. _this.AMBIENT = false;
  65326. _this.AMBIENTDIRECTUV = 0;
  65327. _this.OPACITY = false;
  65328. _this.OPACITYDIRECTUV = 0;
  65329. _this.OPACITYRGB = false;
  65330. _this.REFLECTION = false;
  65331. _this.EMISSIVE = false;
  65332. _this.EMISSIVEDIRECTUV = 0;
  65333. _this.SPECULAR = false;
  65334. _this.SPECULARDIRECTUV = 0;
  65335. _this.BUMP = false;
  65336. _this.BUMPDIRECTUV = 0;
  65337. _this.PARALLAX = false;
  65338. _this.PARALLAXOCCLUSION = false;
  65339. _this.SPECULAROVERALPHA = false;
  65340. _this.CLIPPLANE = false;
  65341. _this.CLIPPLANE2 = false;
  65342. _this.CLIPPLANE3 = false;
  65343. _this.CLIPPLANE4 = false;
  65344. _this.ALPHATEST = false;
  65345. _this.DEPTHPREPASS = false;
  65346. _this.ALPHAFROMDIFFUSE = false;
  65347. _this.POINTSIZE = false;
  65348. _this.FOG = false;
  65349. _this.SPECULARTERM = false;
  65350. _this.DIFFUSEFRESNEL = false;
  65351. _this.OPACITYFRESNEL = false;
  65352. _this.REFLECTIONFRESNEL = false;
  65353. _this.REFRACTIONFRESNEL = false;
  65354. _this.EMISSIVEFRESNEL = false;
  65355. _this.FRESNEL = false;
  65356. _this.NORMAL = false;
  65357. _this.UV1 = false;
  65358. _this.UV2 = false;
  65359. _this.VERTEXCOLOR = false;
  65360. _this.VERTEXALPHA = false;
  65361. _this.NUM_BONE_INFLUENCERS = 0;
  65362. _this.BonesPerMesh = 0;
  65363. _this.BONETEXTURE = false;
  65364. _this.INSTANCES = false;
  65365. _this.GLOSSINESS = false;
  65366. _this.ROUGHNESS = false;
  65367. _this.EMISSIVEASILLUMINATION = false;
  65368. _this.LINKEMISSIVEWITHDIFFUSE = false;
  65369. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  65370. _this.LIGHTMAP = false;
  65371. _this.LIGHTMAPDIRECTUV = 0;
  65372. _this.OBJECTSPACE_NORMALMAP = false;
  65373. _this.USELIGHTMAPASSHADOWMAP = false;
  65374. _this.REFLECTIONMAP_3D = false;
  65375. _this.REFLECTIONMAP_SPHERICAL = false;
  65376. _this.REFLECTIONMAP_PLANAR = false;
  65377. _this.REFLECTIONMAP_CUBIC = false;
  65378. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  65379. _this.REFLECTIONMAP_PROJECTION = false;
  65380. _this.REFLECTIONMAP_SKYBOX = false;
  65381. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  65382. _this.REFLECTIONMAP_EXPLICIT = false;
  65383. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  65384. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  65385. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  65386. _this.INVERTCUBICMAP = false;
  65387. _this.LOGARITHMICDEPTH = false;
  65388. _this.REFRACTION = false;
  65389. _this.REFRACTIONMAP_3D = false;
  65390. _this.REFLECTIONOVERALPHA = false;
  65391. _this.TWOSIDEDLIGHTING = false;
  65392. _this.SHADOWFLOAT = false;
  65393. _this.MORPHTARGETS = false;
  65394. _this.MORPHTARGETS_NORMAL = false;
  65395. _this.MORPHTARGETS_TANGENT = false;
  65396. _this.NUM_MORPH_INFLUENCERS = 0;
  65397. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  65398. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  65399. _this.IMAGEPROCESSING = false;
  65400. _this.VIGNETTE = false;
  65401. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  65402. _this.VIGNETTEBLENDMODEOPAQUE = false;
  65403. _this.TONEMAPPING = false;
  65404. _this.TONEMAPPING_ACES = false;
  65405. _this.CONTRAST = false;
  65406. _this.COLORCURVES = false;
  65407. _this.COLORGRADING = false;
  65408. _this.COLORGRADING3D = false;
  65409. _this.SAMPLER3DGREENDEPTH = false;
  65410. _this.SAMPLER3DBGRMAP = false;
  65411. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  65412. /**
  65413. * If the reflection texture on this material is in linear color space
  65414. * @hidden
  65415. */
  65416. _this.IS_REFLECTION_LINEAR = false;
  65417. /**
  65418. * If the refraction texture on this material is in linear color space
  65419. * @hidden
  65420. */
  65421. _this.IS_REFRACTION_LINEAR = false;
  65422. _this.EXPOSURE = false;
  65423. _this.rebuild();
  65424. return _this;
  65425. }
  65426. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  65427. var modes = [
  65428. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  65429. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  65430. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  65431. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  65432. ];
  65433. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  65434. var mode = modes_1[_i];
  65435. this[mode] = (mode === modeToEnable);
  65436. }
  65437. };
  65438. return StandardMaterialDefines;
  65439. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  65440. /**
  65441. * This is the default material used in Babylon. It is the best trade off between quality
  65442. * and performances.
  65443. * @see http://doc.babylonjs.com/babylon101/materials
  65444. */
  65445. var StandardMaterial = /** @class */ (function (_super) {
  65446. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  65447. /**
  65448. * Instantiates a new standard material.
  65449. * This is the default material used in Babylon. It is the best trade off between quality
  65450. * and performances.
  65451. * @see http://doc.babylonjs.com/babylon101/materials
  65452. * @param name Define the name of the material in the scene
  65453. * @param scene Define the scene the material belong to
  65454. */
  65455. function StandardMaterial(name, scene) {
  65456. var _this = _super.call(this, name, scene) || this;
  65457. /**
  65458. * The color of the material lit by the environmental background lighting.
  65459. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  65460. */
  65461. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65462. /**
  65463. * The basic color of the material as viewed under a light.
  65464. */
  65465. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65466. /**
  65467. * Define how the color and intensity of the highlight given by the light in the material.
  65468. */
  65469. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65470. /**
  65471. * Define the color of the material as if self lit.
  65472. * This will be mixed in the final result even in the absence of light.
  65473. */
  65474. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65475. /**
  65476. * Defines how sharp are the highlights in the material.
  65477. * The bigger the value the sharper giving a more glossy feeling to the result.
  65478. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  65479. */
  65480. _this.specularPower = 64;
  65481. _this._useAlphaFromDiffuseTexture = false;
  65482. _this._useEmissiveAsIllumination = false;
  65483. _this._linkEmissiveWithDiffuse = false;
  65484. _this._useSpecularOverAlpha = false;
  65485. _this._useReflectionOverAlpha = false;
  65486. _this._disableLighting = false;
  65487. _this._useObjectSpaceNormalMap = false;
  65488. _this._useParallax = false;
  65489. _this._useParallaxOcclusion = false;
  65490. /**
  65491. * 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.
  65492. */
  65493. _this.parallaxScaleBias = 0.05;
  65494. _this._roughness = 0;
  65495. /**
  65496. * In case of refraction, define the value of the indice of refraction.
  65497. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65498. */
  65499. _this.indexOfRefraction = 0.98;
  65500. /**
  65501. * Invert the refraction texture alongside the y axis.
  65502. * It can be useful with procedural textures or probe for instance.
  65503. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65504. */
  65505. _this.invertRefractionY = true;
  65506. /**
  65507. * Defines the alpha limits in alpha test mode.
  65508. */
  65509. _this.alphaCutOff = 0.4;
  65510. _this._useLightmapAsShadowmap = false;
  65511. _this._useReflectionFresnelFromSpecular = false;
  65512. _this._useGlossinessFromSpecularMapAlpha = false;
  65513. _this._maxSimultaneousLights = 4;
  65514. _this._invertNormalMapX = false;
  65515. _this._invertNormalMapY = false;
  65516. _this._twoSidedLighting = false;
  65517. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  65518. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  65519. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65520. // Setup the default processing configuration to the scene.
  65521. _this._attachImageProcessingConfiguration(null);
  65522. _this.getRenderTargetTextures = function () {
  65523. _this._renderTargets.reset();
  65524. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  65525. _this._renderTargets.push(_this._reflectionTexture);
  65526. }
  65527. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  65528. _this._renderTargets.push(_this._refractionTexture);
  65529. }
  65530. return _this._renderTargets;
  65531. };
  65532. return _this;
  65533. }
  65534. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  65535. /**
  65536. * Gets the image processing configuration used either in this material.
  65537. */
  65538. get: function () {
  65539. return this._imageProcessingConfiguration;
  65540. },
  65541. /**
  65542. * Sets the Default image processing configuration used either in the this material.
  65543. *
  65544. * If sets to null, the scene one is in use.
  65545. */
  65546. set: function (value) {
  65547. this._attachImageProcessingConfiguration(value);
  65548. // Ensure the effect will be rebuilt.
  65549. this._markAllSubMeshesAsTexturesDirty();
  65550. },
  65551. enumerable: true,
  65552. configurable: true
  65553. });
  65554. /**
  65555. * Attaches a new image processing configuration to the Standard Material.
  65556. * @param configuration
  65557. */
  65558. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  65559. var _this = this;
  65560. if (configuration === this._imageProcessingConfiguration) {
  65561. return;
  65562. }
  65563. // Detaches observer.
  65564. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  65565. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  65566. }
  65567. // Pick the scene configuration if needed.
  65568. if (!configuration) {
  65569. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  65570. }
  65571. else {
  65572. this._imageProcessingConfiguration = configuration;
  65573. }
  65574. // Attaches observer.
  65575. if (this._imageProcessingConfiguration) {
  65576. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  65577. _this._markAllSubMeshesAsImageProcessingDirty();
  65578. });
  65579. }
  65580. };
  65581. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  65582. /**
  65583. * Gets wether the color curves effect is enabled.
  65584. */
  65585. get: function () {
  65586. return this.imageProcessingConfiguration.colorCurvesEnabled;
  65587. },
  65588. /**
  65589. * Sets wether the color curves effect is enabled.
  65590. */
  65591. set: function (value) {
  65592. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  65593. },
  65594. enumerable: true,
  65595. configurable: true
  65596. });
  65597. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  65598. /**
  65599. * Gets wether the color grading effect is enabled.
  65600. */
  65601. get: function () {
  65602. return this.imageProcessingConfiguration.colorGradingEnabled;
  65603. },
  65604. /**
  65605. * Gets wether the color grading effect is enabled.
  65606. */
  65607. set: function (value) {
  65608. this.imageProcessingConfiguration.colorGradingEnabled = value;
  65609. },
  65610. enumerable: true,
  65611. configurable: true
  65612. });
  65613. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  65614. /**
  65615. * Gets wether tonemapping is enabled or not.
  65616. */
  65617. get: function () {
  65618. return this._imageProcessingConfiguration.toneMappingEnabled;
  65619. },
  65620. /**
  65621. * Sets wether tonemapping is enabled or not
  65622. */
  65623. set: function (value) {
  65624. this._imageProcessingConfiguration.toneMappingEnabled = value;
  65625. },
  65626. enumerable: true,
  65627. configurable: true
  65628. });
  65629. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  65630. /**
  65631. * The camera exposure used on this material.
  65632. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65633. * This corresponds to a photographic exposure.
  65634. */
  65635. get: function () {
  65636. return this._imageProcessingConfiguration.exposure;
  65637. },
  65638. /**
  65639. * The camera exposure used on this material.
  65640. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65641. * This corresponds to a photographic exposure.
  65642. */
  65643. set: function (value) {
  65644. this._imageProcessingConfiguration.exposure = value;
  65645. },
  65646. enumerable: true,
  65647. configurable: true
  65648. });
  65649. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  65650. /**
  65651. * Gets The camera contrast used on this material.
  65652. */
  65653. get: function () {
  65654. return this._imageProcessingConfiguration.contrast;
  65655. },
  65656. /**
  65657. * Sets The camera contrast used on this material.
  65658. */
  65659. set: function (value) {
  65660. this._imageProcessingConfiguration.contrast = value;
  65661. },
  65662. enumerable: true,
  65663. configurable: true
  65664. });
  65665. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  65666. /**
  65667. * Gets the Color Grading 2D Lookup Texture.
  65668. */
  65669. get: function () {
  65670. return this._imageProcessingConfiguration.colorGradingTexture;
  65671. },
  65672. /**
  65673. * Sets the Color Grading 2D Lookup Texture.
  65674. */
  65675. set: function (value) {
  65676. this._imageProcessingConfiguration.colorGradingTexture = value;
  65677. },
  65678. enumerable: true,
  65679. configurable: true
  65680. });
  65681. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  65682. /**
  65683. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65684. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65685. * 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;
  65686. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65687. */
  65688. get: function () {
  65689. return this._imageProcessingConfiguration.colorCurves;
  65690. },
  65691. /**
  65692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65694. * 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;
  65695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65696. */
  65697. set: function (value) {
  65698. this._imageProcessingConfiguration.colorCurves = value;
  65699. },
  65700. enumerable: true,
  65701. configurable: true
  65702. });
  65703. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  65704. /**
  65705. * Gets a boolean indicating that current material needs to register RTT
  65706. */
  65707. get: function () {
  65708. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65709. return true;
  65710. }
  65711. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65712. return true;
  65713. }
  65714. return false;
  65715. },
  65716. enumerable: true,
  65717. configurable: true
  65718. });
  65719. /**
  65720. * Gets the current class name of the material e.g. "StandardMaterial"
  65721. * Mainly use in serialization.
  65722. * @returns the class name
  65723. */
  65724. StandardMaterial.prototype.getClassName = function () {
  65725. return "StandardMaterial";
  65726. };
  65727. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  65728. /**
  65729. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  65730. * You can try switching to logarithmic depth.
  65731. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  65732. */
  65733. get: function () {
  65734. return this._useLogarithmicDepth;
  65735. },
  65736. set: function (value) {
  65737. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  65738. this._markAllSubMeshesAsMiscDirty();
  65739. },
  65740. enumerable: true,
  65741. configurable: true
  65742. });
  65743. /**
  65744. * Specifies if the material will require alpha blending
  65745. * @returns a boolean specifying if alpha blending is needed
  65746. */
  65747. StandardMaterial.prototype.needAlphaBlending = function () {
  65748. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  65749. };
  65750. /**
  65751. * Specifies if this material should be rendered in alpha test mode
  65752. * @returns a boolean specifying if an alpha test is needed.
  65753. */
  65754. StandardMaterial.prototype.needAlphaTesting = function () {
  65755. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  65756. };
  65757. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  65758. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  65759. };
  65760. /**
  65761. * Get the texture used for alpha test purpose.
  65762. * @returns the diffuse texture in case of the standard material.
  65763. */
  65764. StandardMaterial.prototype.getAlphaTestTexture = function () {
  65765. return this._diffuseTexture;
  65766. };
  65767. /**
  65768. * Get if the submesh is ready to be used and all its information available.
  65769. * Child classes can use it to update shaders
  65770. * @param mesh defines the mesh to check
  65771. * @param subMesh defines which submesh to check
  65772. * @param useInstances specifies that instances should be used
  65773. * @returns a boolean indicating that the submesh is ready or not
  65774. */
  65775. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65776. if (useInstances === void 0) { useInstances = false; }
  65777. if (subMesh.effect && this.isFrozen) {
  65778. if (this._wasPreviouslyReady) {
  65779. return true;
  65780. }
  65781. }
  65782. if (!subMesh._materialDefines) {
  65783. subMesh._materialDefines = new StandardMaterialDefines();
  65784. }
  65785. var scene = this.getScene();
  65786. var defines = subMesh._materialDefines;
  65787. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  65788. if (defines._renderId === scene.getRenderId()) {
  65789. return true;
  65790. }
  65791. }
  65792. var engine = scene.getEngine();
  65793. // Lights
  65794. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  65795. // Textures
  65796. if (defines._areTexturesDirty) {
  65797. defines._needUVs = false;
  65798. defines.MAINUV1 = false;
  65799. defines.MAINUV2 = false;
  65800. if (scene.texturesEnabled) {
  65801. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65802. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  65803. return false;
  65804. }
  65805. else {
  65806. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  65807. }
  65808. }
  65809. else {
  65810. defines.DIFFUSE = false;
  65811. }
  65812. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65813. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  65814. return false;
  65815. }
  65816. else {
  65817. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  65818. }
  65819. }
  65820. else {
  65821. defines.AMBIENT = false;
  65822. }
  65823. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65824. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  65825. return false;
  65826. }
  65827. else {
  65828. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  65829. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  65830. }
  65831. }
  65832. else {
  65833. defines.OPACITY = false;
  65834. }
  65835. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65836. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  65837. return false;
  65838. }
  65839. else {
  65840. defines._needNormals = true;
  65841. defines.REFLECTION = true;
  65842. defines.ROUGHNESS = (this._roughness > 0);
  65843. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  65844. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  65845. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  65846. switch (this._reflectionTexture.coordinatesMode) {
  65847. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  65848. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  65849. break;
  65850. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  65851. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  65852. break;
  65853. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  65854. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  65855. break;
  65856. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  65857. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  65858. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  65859. break;
  65860. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  65861. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  65862. break;
  65863. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  65864. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  65865. break;
  65866. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  65867. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  65868. break;
  65869. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  65870. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  65871. break;
  65872. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  65873. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  65874. default:
  65875. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  65876. break;
  65877. }
  65878. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  65879. }
  65880. }
  65881. else {
  65882. defines.REFLECTION = false;
  65883. }
  65884. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65885. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  65886. return false;
  65887. }
  65888. else {
  65889. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  65890. }
  65891. }
  65892. else {
  65893. defines.EMISSIVE = false;
  65894. }
  65895. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65896. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  65897. return false;
  65898. }
  65899. else {
  65900. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  65901. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  65902. }
  65903. }
  65904. else {
  65905. defines.LIGHTMAP = false;
  65906. }
  65907. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65908. if (!this._specularTexture.isReadyOrNotBlocking()) {
  65909. return false;
  65910. }
  65911. else {
  65912. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  65913. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  65914. }
  65915. }
  65916. else {
  65917. defines.SPECULAR = false;
  65918. }
  65919. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  65920. // Bump texure can not be not blocking.
  65921. if (!this._bumpTexture.isReady()) {
  65922. return false;
  65923. }
  65924. else {
  65925. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  65926. defines.PARALLAX = this._useParallax;
  65927. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  65928. }
  65929. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  65930. }
  65931. else {
  65932. defines.BUMP = false;
  65933. }
  65934. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65935. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  65936. return false;
  65937. }
  65938. else {
  65939. defines._needUVs = true;
  65940. defines.REFRACTION = true;
  65941. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  65942. }
  65943. }
  65944. else {
  65945. defines.REFRACTION = false;
  65946. }
  65947. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  65948. }
  65949. else {
  65950. defines.DIFFUSE = false;
  65951. defines.AMBIENT = false;
  65952. defines.OPACITY = false;
  65953. defines.REFLECTION = false;
  65954. defines.EMISSIVE = false;
  65955. defines.LIGHTMAP = false;
  65956. defines.BUMP = false;
  65957. defines.REFRACTION = false;
  65958. }
  65959. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  65960. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  65961. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  65962. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  65963. 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);
  65964. }
  65965. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  65966. if (!this._imageProcessingConfiguration.isReady()) {
  65967. return false;
  65968. }
  65969. this._imageProcessingConfiguration.prepareDefines(defines);
  65970. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  65971. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  65972. }
  65973. if (defines._areFresnelDirty) {
  65974. if (StandardMaterial.FresnelEnabled) {
  65975. // Fresnel
  65976. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  65977. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  65978. this._reflectionFresnelParameters) {
  65979. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  65980. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  65981. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  65982. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  65983. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  65984. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  65985. defines._needNormals = true;
  65986. defines.FRESNEL = true;
  65987. }
  65988. }
  65989. else {
  65990. defines.FRESNEL = false;
  65991. }
  65992. }
  65993. // Misc.
  65994. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  65995. // Attribs
  65996. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  65997. // Values that need to be evaluated on every frame
  65998. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  65999. // Get correct effect
  66000. if (defines.isDirty) {
  66001. defines.markAsProcessed();
  66002. // Fallbacks
  66003. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  66004. if (defines.REFLECTION) {
  66005. fallbacks.addFallback(0, "REFLECTION");
  66006. }
  66007. if (defines.SPECULAR) {
  66008. fallbacks.addFallback(0, "SPECULAR");
  66009. }
  66010. if (defines.BUMP) {
  66011. fallbacks.addFallback(0, "BUMP");
  66012. }
  66013. if (defines.PARALLAX) {
  66014. fallbacks.addFallback(1, "PARALLAX");
  66015. }
  66016. if (defines.PARALLAXOCCLUSION) {
  66017. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  66018. }
  66019. if (defines.SPECULAROVERALPHA) {
  66020. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  66021. }
  66022. if (defines.FOG) {
  66023. fallbacks.addFallback(1, "FOG");
  66024. }
  66025. if (defines.POINTSIZE) {
  66026. fallbacks.addFallback(0, "POINTSIZE");
  66027. }
  66028. if (defines.LOGARITHMICDEPTH) {
  66029. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  66030. }
  66031. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  66032. if (defines.SPECULARTERM) {
  66033. fallbacks.addFallback(0, "SPECULARTERM");
  66034. }
  66035. if (defines.DIFFUSEFRESNEL) {
  66036. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  66037. }
  66038. if (defines.OPACITYFRESNEL) {
  66039. fallbacks.addFallback(2, "OPACITYFRESNEL");
  66040. }
  66041. if (defines.REFLECTIONFRESNEL) {
  66042. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  66043. }
  66044. if (defines.EMISSIVEFRESNEL) {
  66045. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  66046. }
  66047. if (defines.FRESNEL) {
  66048. fallbacks.addFallback(4, "FRESNEL");
  66049. }
  66050. //Attributes
  66051. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  66052. if (defines.NORMAL) {
  66053. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  66054. }
  66055. if (defines.UV1) {
  66056. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  66057. }
  66058. if (defines.UV2) {
  66059. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  66060. }
  66061. if (defines.VERTEXCOLOR) {
  66062. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  66063. }
  66064. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  66065. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  66066. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  66067. var shaderName = "default";
  66068. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  66069. "vFogInfos", "vFogColor", "pointSize",
  66070. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  66071. "mBones",
  66072. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  66073. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  66074. "vReflectionPosition", "vReflectionSize",
  66075. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  66076. ];
  66077. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  66078. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  66079. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  66080. var uniformBuffers = ["Material", "Scene"];
  66081. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  66082. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  66083. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  66084. }
  66085. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  66086. uniformsNames: uniforms,
  66087. uniformBuffersNames: uniformBuffers,
  66088. samplers: samplers,
  66089. defines: defines,
  66090. maxSimultaneousLights: this._maxSimultaneousLights
  66091. });
  66092. if (this.customShaderNameResolve) {
  66093. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  66094. }
  66095. var join = defines.toString();
  66096. var previousEffect = subMesh.effect;
  66097. var effect = scene.getEngine().createEffect(shaderName, {
  66098. attributes: attribs,
  66099. uniformsNames: uniforms,
  66100. uniformBuffersNames: uniformBuffers,
  66101. samplers: samplers,
  66102. defines: join,
  66103. fallbacks: fallbacks,
  66104. onCompiled: this.onCompiled,
  66105. onError: this.onError,
  66106. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  66107. }, engine);
  66108. if (effect) {
  66109. // Use previous effect while new one is compiling
  66110. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  66111. effect = previousEffect;
  66112. defines.markAsUnprocessed();
  66113. }
  66114. else {
  66115. scene.resetCachedMaterial();
  66116. subMesh.setEffect(effect, defines);
  66117. this.buildUniformLayout();
  66118. }
  66119. }
  66120. }
  66121. if (!subMesh.effect || !subMesh.effect.isReady()) {
  66122. return false;
  66123. }
  66124. defines._renderId = scene.getRenderId();
  66125. this._wasPreviouslyReady = true;
  66126. return true;
  66127. };
  66128. /**
  66129. * Builds the material UBO layouts.
  66130. * Used internally during the effect preparation.
  66131. */
  66132. StandardMaterial.prototype.buildUniformLayout = function () {
  66133. // Order is important !
  66134. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  66135. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  66136. this._uniformBuffer.addUniform("opacityParts", 4);
  66137. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  66138. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  66139. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  66140. this._uniformBuffer.addUniform("refractionRightColor", 4);
  66141. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  66142. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  66143. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  66144. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  66145. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  66146. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  66147. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  66148. this._uniformBuffer.addUniform("vReflectionSize", 3);
  66149. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  66150. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  66151. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  66152. this._uniformBuffer.addUniform("vBumpInfos", 3);
  66153. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  66154. this._uniformBuffer.addUniform("ambientMatrix", 16);
  66155. this._uniformBuffer.addUniform("opacityMatrix", 16);
  66156. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  66157. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  66158. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  66159. this._uniformBuffer.addUniform("specularMatrix", 16);
  66160. this._uniformBuffer.addUniform("bumpMatrix", 16);
  66161. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  66162. this._uniformBuffer.addUniform("refractionMatrix", 16);
  66163. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  66164. this._uniformBuffer.addUniform("vSpecularColor", 4);
  66165. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  66166. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  66167. this._uniformBuffer.addUniform("pointSize", 1);
  66168. this._uniformBuffer.create();
  66169. };
  66170. /**
  66171. * Unbinds the material from the mesh
  66172. */
  66173. StandardMaterial.prototype.unbind = function () {
  66174. if (this._activeEffect) {
  66175. var needFlag = false;
  66176. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  66177. this._activeEffect.setTexture("reflection2DSampler", null);
  66178. needFlag = true;
  66179. }
  66180. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  66181. this._activeEffect.setTexture("refraction2DSampler", null);
  66182. needFlag = true;
  66183. }
  66184. if (needFlag) {
  66185. this._markAllSubMeshesAsTexturesDirty();
  66186. }
  66187. }
  66188. _super.prototype.unbind.call(this);
  66189. };
  66190. /**
  66191. * Binds the submesh to this material by preparing the effect and shader to draw
  66192. * @param world defines the world transformation matrix
  66193. * @param mesh defines the mesh containing the submesh
  66194. * @param subMesh defines the submesh to bind the material to
  66195. */
  66196. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  66197. var scene = this.getScene();
  66198. var defines = subMesh._materialDefines;
  66199. if (!defines) {
  66200. return;
  66201. }
  66202. var effect = subMesh.effect;
  66203. if (!effect) {
  66204. return;
  66205. }
  66206. this._activeEffect = effect;
  66207. // Matrices
  66208. this.bindOnlyWorldMatrix(world);
  66209. // Normal Matrix
  66210. if (defines.OBJECTSPACE_NORMALMAP) {
  66211. world.toNormalMatrix(this._normalMatrix);
  66212. this.bindOnlyNormalMatrix(this._normalMatrix);
  66213. }
  66214. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  66215. // Bones
  66216. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  66217. if (mustRebind) {
  66218. this._uniformBuffer.bindToEffect(effect, "Material");
  66219. this.bindViewProjection(effect);
  66220. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  66221. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  66222. // Fresnel
  66223. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  66224. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  66225. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  66226. }
  66227. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  66228. 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);
  66229. }
  66230. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  66231. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  66232. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  66233. }
  66234. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  66235. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  66236. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  66237. }
  66238. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  66239. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  66240. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  66241. }
  66242. }
  66243. // Textures
  66244. if (scene.texturesEnabled) {
  66245. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66246. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  66247. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  66248. if (this._diffuseTexture.hasAlpha) {
  66249. effect.setFloat("alphaCutOff", this.alphaCutOff);
  66250. }
  66251. }
  66252. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66253. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  66254. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  66255. }
  66256. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66257. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  66258. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  66259. }
  66260. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66261. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  66262. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  66263. if (this._reflectionTexture.boundingBoxSize) {
  66264. var cubeTexture = this._reflectionTexture;
  66265. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  66266. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  66267. }
  66268. }
  66269. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66270. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  66271. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  66272. }
  66273. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66274. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  66275. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  66276. }
  66277. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66278. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  66279. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  66280. }
  66281. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66282. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  66283. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  66284. if (scene._mirroredCameraPosition) {
  66285. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  66286. }
  66287. else {
  66288. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  66289. }
  66290. }
  66291. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66292. var depth = 1.0;
  66293. if (!this._refractionTexture.isCube) {
  66294. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  66295. if (this._refractionTexture.depth) {
  66296. depth = this._refractionTexture.depth;
  66297. }
  66298. }
  66299. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  66300. }
  66301. }
  66302. // Point size
  66303. if (this.pointsCloud) {
  66304. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  66305. }
  66306. if (defines.SPECULARTERM) {
  66307. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  66308. }
  66309. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  66310. // Diffuse
  66311. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  66312. }
  66313. // Textures
  66314. if (scene.texturesEnabled) {
  66315. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66316. effect.setTexture("diffuseSampler", this._diffuseTexture);
  66317. }
  66318. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66319. effect.setTexture("ambientSampler", this._ambientTexture);
  66320. }
  66321. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66322. effect.setTexture("opacitySampler", this._opacityTexture);
  66323. }
  66324. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66325. if (this._reflectionTexture.isCube) {
  66326. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  66327. }
  66328. else {
  66329. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  66330. }
  66331. }
  66332. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66333. effect.setTexture("emissiveSampler", this._emissiveTexture);
  66334. }
  66335. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66336. effect.setTexture("lightmapSampler", this._lightmapTexture);
  66337. }
  66338. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66339. effect.setTexture("specularSampler", this._specularTexture);
  66340. }
  66341. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66342. effect.setTexture("bumpSampler", this._bumpTexture);
  66343. }
  66344. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66345. var depth = 1.0;
  66346. if (this._refractionTexture.isCube) {
  66347. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  66348. }
  66349. else {
  66350. effect.setTexture("refraction2DSampler", this._refractionTexture);
  66351. }
  66352. }
  66353. }
  66354. // Clip plane
  66355. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  66356. // Colors
  66357. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  66358. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  66359. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  66360. }
  66361. if (mustRebind || !this.isFrozen) {
  66362. // Lights
  66363. if (scene.lightsEnabled && !this._disableLighting) {
  66364. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  66365. }
  66366. // View
  66367. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  66368. this.bindView(effect);
  66369. }
  66370. // Fog
  66371. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  66372. // Morph targets
  66373. if (defines.NUM_MORPH_INFLUENCERS) {
  66374. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  66375. }
  66376. // Log. depth
  66377. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  66378. // image processing
  66379. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  66380. this._imageProcessingConfiguration.bind(this._activeEffect);
  66381. }
  66382. }
  66383. this._uniformBuffer.update();
  66384. this._afterBind(mesh, this._activeEffect);
  66385. };
  66386. /**
  66387. * Get the list of animatables in the material.
  66388. * @returns the list of animatables object used in the material
  66389. */
  66390. StandardMaterial.prototype.getAnimatables = function () {
  66391. var results = [];
  66392. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  66393. results.push(this._diffuseTexture);
  66394. }
  66395. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  66396. results.push(this._ambientTexture);
  66397. }
  66398. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  66399. results.push(this._opacityTexture);
  66400. }
  66401. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  66402. results.push(this._reflectionTexture);
  66403. }
  66404. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  66405. results.push(this._emissiveTexture);
  66406. }
  66407. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  66408. results.push(this._specularTexture);
  66409. }
  66410. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  66411. results.push(this._bumpTexture);
  66412. }
  66413. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  66414. results.push(this._lightmapTexture);
  66415. }
  66416. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  66417. results.push(this._refractionTexture);
  66418. }
  66419. return results;
  66420. };
  66421. /**
  66422. * Gets the active textures from the material
  66423. * @returns an array of textures
  66424. */
  66425. StandardMaterial.prototype.getActiveTextures = function () {
  66426. var activeTextures = _super.prototype.getActiveTextures.call(this);
  66427. if (this._diffuseTexture) {
  66428. activeTextures.push(this._diffuseTexture);
  66429. }
  66430. if (this._ambientTexture) {
  66431. activeTextures.push(this._ambientTexture);
  66432. }
  66433. if (this._opacityTexture) {
  66434. activeTextures.push(this._opacityTexture);
  66435. }
  66436. if (this._reflectionTexture) {
  66437. activeTextures.push(this._reflectionTexture);
  66438. }
  66439. if (this._emissiveTexture) {
  66440. activeTextures.push(this._emissiveTexture);
  66441. }
  66442. if (this._specularTexture) {
  66443. activeTextures.push(this._specularTexture);
  66444. }
  66445. if (this._bumpTexture) {
  66446. activeTextures.push(this._bumpTexture);
  66447. }
  66448. if (this._lightmapTexture) {
  66449. activeTextures.push(this._lightmapTexture);
  66450. }
  66451. if (this._refractionTexture) {
  66452. activeTextures.push(this._refractionTexture);
  66453. }
  66454. return activeTextures;
  66455. };
  66456. /**
  66457. * Specifies if the material uses a texture
  66458. * @param texture defines the texture to check against the material
  66459. * @returns a boolean specifying if the material uses the texture
  66460. */
  66461. StandardMaterial.prototype.hasTexture = function (texture) {
  66462. if (_super.prototype.hasTexture.call(this, texture)) {
  66463. return true;
  66464. }
  66465. if (this._diffuseTexture === texture) {
  66466. return true;
  66467. }
  66468. if (this._ambientTexture === texture) {
  66469. return true;
  66470. }
  66471. if (this._opacityTexture === texture) {
  66472. return true;
  66473. }
  66474. if (this._reflectionTexture === texture) {
  66475. return true;
  66476. }
  66477. if (this._emissiveTexture === texture) {
  66478. return true;
  66479. }
  66480. if (this._specularTexture === texture) {
  66481. return true;
  66482. }
  66483. if (this._bumpTexture === texture) {
  66484. return true;
  66485. }
  66486. if (this._lightmapTexture === texture) {
  66487. return true;
  66488. }
  66489. if (this._refractionTexture === texture) {
  66490. return true;
  66491. }
  66492. return false;
  66493. };
  66494. /**
  66495. * Disposes the material
  66496. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66497. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66498. */
  66499. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  66500. if (forceDisposeTextures) {
  66501. if (this._diffuseTexture) {
  66502. this._diffuseTexture.dispose();
  66503. }
  66504. if (this._ambientTexture) {
  66505. this._ambientTexture.dispose();
  66506. }
  66507. if (this._opacityTexture) {
  66508. this._opacityTexture.dispose();
  66509. }
  66510. if (this._reflectionTexture) {
  66511. this._reflectionTexture.dispose();
  66512. }
  66513. if (this._emissiveTexture) {
  66514. this._emissiveTexture.dispose();
  66515. }
  66516. if (this._specularTexture) {
  66517. this._specularTexture.dispose();
  66518. }
  66519. if (this._bumpTexture) {
  66520. this._bumpTexture.dispose();
  66521. }
  66522. if (this._lightmapTexture) {
  66523. this._lightmapTexture.dispose();
  66524. }
  66525. if (this._refractionTexture) {
  66526. this._refractionTexture.dispose();
  66527. }
  66528. }
  66529. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  66530. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  66531. }
  66532. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66533. };
  66534. /**
  66535. * Makes a duplicate of the material, and gives it a new name
  66536. * @param name defines the new name for the duplicated material
  66537. * @returns the cloned material
  66538. */
  66539. StandardMaterial.prototype.clone = function (name) {
  66540. var _this = this;
  66541. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  66542. result.name = name;
  66543. result.id = name;
  66544. return result;
  66545. };
  66546. /**
  66547. * Serializes this material in a JSON representation
  66548. * @returns the serialized material object
  66549. */
  66550. StandardMaterial.prototype.serialize = function () {
  66551. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66552. };
  66553. /**
  66554. * Creates a standard material from parsed material data
  66555. * @param source defines the JSON representation of the material
  66556. * @param scene defines the hosting scene
  66557. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66558. * @returns a new standard material
  66559. */
  66560. StandardMaterial.Parse = function (source, scene, rootUrl) {
  66561. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  66562. };
  66563. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  66564. // Flags used to enable or disable a type of texture for all Standard Materials
  66565. /**
  66566. * Are diffuse textures enabled in the application.
  66567. */
  66568. get: function () {
  66569. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  66570. },
  66571. set: function (value) {
  66572. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  66573. },
  66574. enumerable: true,
  66575. configurable: true
  66576. });
  66577. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  66578. /**
  66579. * Are ambient textures enabled in the application.
  66580. */
  66581. get: function () {
  66582. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  66583. },
  66584. set: function (value) {
  66585. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  66586. },
  66587. enumerable: true,
  66588. configurable: true
  66589. });
  66590. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  66591. /**
  66592. * Are opacity textures enabled in the application.
  66593. */
  66594. get: function () {
  66595. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  66596. },
  66597. set: function (value) {
  66598. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  66599. },
  66600. enumerable: true,
  66601. configurable: true
  66602. });
  66603. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  66604. /**
  66605. * Are reflection textures enabled in the application.
  66606. */
  66607. get: function () {
  66608. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  66609. },
  66610. set: function (value) {
  66611. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  66612. },
  66613. enumerable: true,
  66614. configurable: true
  66615. });
  66616. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  66617. /**
  66618. * Are emissive textures enabled in the application.
  66619. */
  66620. get: function () {
  66621. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  66622. },
  66623. set: function (value) {
  66624. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  66625. },
  66626. enumerable: true,
  66627. configurable: true
  66628. });
  66629. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  66630. /**
  66631. * Are specular textures enabled in the application.
  66632. */
  66633. get: function () {
  66634. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  66635. },
  66636. set: function (value) {
  66637. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  66638. },
  66639. enumerable: true,
  66640. configurable: true
  66641. });
  66642. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  66643. /**
  66644. * Are bump textures enabled in the application.
  66645. */
  66646. get: function () {
  66647. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  66648. },
  66649. set: function (value) {
  66650. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  66651. },
  66652. enumerable: true,
  66653. configurable: true
  66654. });
  66655. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  66656. /**
  66657. * Are lightmap textures enabled in the application.
  66658. */
  66659. get: function () {
  66660. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  66661. },
  66662. set: function (value) {
  66663. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  66664. },
  66665. enumerable: true,
  66666. configurable: true
  66667. });
  66668. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  66669. /**
  66670. * Are refraction textures enabled in the application.
  66671. */
  66672. get: function () {
  66673. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  66674. },
  66675. set: function (value) {
  66676. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  66677. },
  66678. enumerable: true,
  66679. configurable: true
  66680. });
  66681. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  66682. /**
  66683. * Are color grading textures enabled in the application.
  66684. */
  66685. get: function () {
  66686. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  66687. },
  66688. set: function (value) {
  66689. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  66690. },
  66691. enumerable: true,
  66692. configurable: true
  66693. });
  66694. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  66695. /**
  66696. * Are fresnels enabled in the application.
  66697. */
  66698. get: function () {
  66699. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  66700. },
  66701. set: function (value) {
  66702. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  66703. },
  66704. enumerable: true,
  66705. configurable: true
  66706. });
  66707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  66709. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  66710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66712. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  66713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66714. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  66715. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  66716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66718. ], StandardMaterial.prototype, "ambientTexture", void 0);
  66719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  66721. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  66722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66724. ], StandardMaterial.prototype, "opacityTexture", void 0);
  66725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  66727. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  66728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66730. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  66731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  66733. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  66734. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66735. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66736. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  66737. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66738. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  66739. ], StandardMaterial.prototype, "_specularTexture", void 0);
  66740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66742. ], StandardMaterial.prototype, "specularTexture", void 0);
  66743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  66745. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  66746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66748. ], StandardMaterial.prototype, "bumpTexture", void 0);
  66749. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66750. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  66751. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  66752. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66754. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  66755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  66757. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  66758. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66759. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66760. ], StandardMaterial.prototype, "refractionTexture", void 0);
  66761. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66762. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  66763. ], StandardMaterial.prototype, "ambientColor", void 0);
  66764. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66765. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  66766. ], StandardMaterial.prototype, "diffuseColor", void 0);
  66767. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  66769. ], StandardMaterial.prototype, "specularColor", void 0);
  66770. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66771. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  66772. ], StandardMaterial.prototype, "emissiveColor", void 0);
  66773. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66774. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66775. ], StandardMaterial.prototype, "specularPower", void 0);
  66776. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66777. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  66778. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  66779. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66780. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66781. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  66782. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66783. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  66784. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  66785. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66786. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66787. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  66788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  66790. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  66791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66793. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  66794. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66795. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  66796. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  66797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66799. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  66800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  66802. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  66803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66805. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  66806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  66808. ], StandardMaterial.prototype, "_disableLighting", void 0);
  66809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66811. ], StandardMaterial.prototype, "disableLighting", void 0);
  66812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  66814. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  66815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66817. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  66818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  66820. ], StandardMaterial.prototype, "_useParallax", void 0);
  66821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66823. ], StandardMaterial.prototype, "useParallax", void 0);
  66824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  66826. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  66827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66829. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  66830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66832. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  66833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  66835. ], StandardMaterial.prototype, "_roughness", void 0);
  66836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66838. ], StandardMaterial.prototype, "roughness", void 0);
  66839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66841. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  66842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66844. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  66845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66847. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  66848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  66850. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  66851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66853. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  66854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  66856. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  66857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66859. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  66860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  66862. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  66863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  66865. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  66866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  66868. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  66869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66871. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  66872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  66874. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  66875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66877. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  66878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  66880. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  66881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66883. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  66884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  66886. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  66887. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66889. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  66890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  66892. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  66893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66895. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  66896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  66898. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  66899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66901. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  66902. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  66904. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  66905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66907. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  66908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  66910. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  66911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66913. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  66914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  66916. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  66917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66919. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  66920. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66922. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  66923. return StandardMaterial;
  66924. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  66925. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  66926. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  66927. return new StandardMaterial("default material", scene);
  66928. };
  66929. /***/ }),
  66930. /***/ "./Materials/uniformBuffer.ts":
  66931. /*!************************************!*\
  66932. !*** ./Materials/uniformBuffer.ts ***!
  66933. \************************************/
  66934. /*! exports provided: UniformBuffer */
  66935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66936. "use strict";
  66937. __webpack_require__.r(__webpack_exports__);
  66938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  66939. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66940. /**
  66941. * Uniform buffer objects.
  66942. *
  66943. * Handles blocks of uniform on the GPU.
  66944. *
  66945. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66946. *
  66947. * For more information, please refer to :
  66948. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66949. */
  66950. var UniformBuffer = /** @class */ (function () {
  66951. /**
  66952. * Instantiates a new Uniform buffer objects.
  66953. *
  66954. * Handles blocks of uniform on the GPU.
  66955. *
  66956. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66957. *
  66958. * For more information, please refer to :
  66959. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66960. * @param engine Define the engine the buffer is associated with
  66961. * @param data Define the data contained in the buffer
  66962. * @param dynamic Define if the buffer is updatable
  66963. */
  66964. function UniformBuffer(engine, data, dynamic) {
  66965. this._engine = engine;
  66966. this._noUBO = !engine.supportsUniformBuffers;
  66967. this._dynamic = dynamic;
  66968. this._data = data || [];
  66969. this._uniformLocations = {};
  66970. this._uniformSizes = {};
  66971. this._uniformLocationPointer = 0;
  66972. this._needSync = false;
  66973. if (this._noUBO) {
  66974. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  66975. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  66976. this.updateFloat = this._updateFloatForEffect;
  66977. this.updateFloat2 = this._updateFloat2ForEffect;
  66978. this.updateFloat3 = this._updateFloat3ForEffect;
  66979. this.updateFloat4 = this._updateFloat4ForEffect;
  66980. this.updateMatrix = this._updateMatrixForEffect;
  66981. this.updateVector3 = this._updateVector3ForEffect;
  66982. this.updateVector4 = this._updateVector4ForEffect;
  66983. this.updateColor3 = this._updateColor3ForEffect;
  66984. this.updateColor4 = this._updateColor4ForEffect;
  66985. }
  66986. else {
  66987. this._engine._uniformBuffers.push(this);
  66988. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  66989. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  66990. this.updateFloat = this._updateFloatForUniform;
  66991. this.updateFloat2 = this._updateFloat2ForUniform;
  66992. this.updateFloat3 = this._updateFloat3ForUniform;
  66993. this.updateFloat4 = this._updateFloat4ForUniform;
  66994. this.updateMatrix = this._updateMatrixForUniform;
  66995. this.updateVector3 = this._updateVector3ForUniform;
  66996. this.updateVector4 = this._updateVector4ForUniform;
  66997. this.updateColor3 = this._updateColor3ForUniform;
  66998. this.updateColor4 = this._updateColor4ForUniform;
  66999. }
  67000. }
  67001. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  67002. /**
  67003. * Indicates if the buffer is using the WebGL2 UBO implementation,
  67004. * or just falling back on setUniformXXX calls.
  67005. */
  67006. get: function () {
  67007. return !this._noUBO;
  67008. },
  67009. enumerable: true,
  67010. configurable: true
  67011. });
  67012. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  67013. /**
  67014. * Indicates if the WebGL underlying uniform buffer is in sync
  67015. * with the javascript cache data.
  67016. */
  67017. get: function () {
  67018. return !this._needSync;
  67019. },
  67020. enumerable: true,
  67021. configurable: true
  67022. });
  67023. /**
  67024. * Indicates if the WebGL underlying uniform buffer is dynamic.
  67025. * Also, a dynamic UniformBuffer will disable cache verification and always
  67026. * update the underlying WebGL uniform buffer to the GPU.
  67027. * @returns if Dynamic, otherwise false
  67028. */
  67029. UniformBuffer.prototype.isDynamic = function () {
  67030. return this._dynamic !== undefined;
  67031. };
  67032. /**
  67033. * The data cache on JS side.
  67034. * @returns the underlying data as a float array
  67035. */
  67036. UniformBuffer.prototype.getData = function () {
  67037. return this._bufferData;
  67038. };
  67039. /**
  67040. * The underlying WebGL Uniform buffer.
  67041. * @returns the webgl buffer
  67042. */
  67043. UniformBuffer.prototype.getBuffer = function () {
  67044. return this._buffer;
  67045. };
  67046. /**
  67047. * std140 layout specifies how to align data within an UBO structure.
  67048. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  67049. * for specs.
  67050. */
  67051. UniformBuffer.prototype._fillAlignment = function (size) {
  67052. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  67053. // and 4x4 matrices
  67054. // TODO : change if other types are used
  67055. var alignment;
  67056. if (size <= 2) {
  67057. alignment = size;
  67058. }
  67059. else {
  67060. alignment = 4;
  67061. }
  67062. if ((this._uniformLocationPointer % alignment) !== 0) {
  67063. var oldPointer = this._uniformLocationPointer;
  67064. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  67065. var diff = this._uniformLocationPointer - oldPointer;
  67066. for (var i = 0; i < diff; i++) {
  67067. this._data.push(0);
  67068. }
  67069. }
  67070. };
  67071. /**
  67072. * Adds an uniform in the buffer.
  67073. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  67074. * for the layout to be correct !
  67075. * @param name Name of the uniform, as used in the uniform block in the shader.
  67076. * @param size Data size, or data directly.
  67077. */
  67078. UniformBuffer.prototype.addUniform = function (name, size) {
  67079. if (this._noUBO) {
  67080. return;
  67081. }
  67082. if (this._uniformLocations[name] !== undefined) {
  67083. // Already existing uniform
  67084. return;
  67085. }
  67086. // This function must be called in the order of the shader layout !
  67087. // size can be the size of the uniform, or data directly
  67088. var data;
  67089. if (size instanceof Array) {
  67090. data = size;
  67091. size = data.length;
  67092. }
  67093. else {
  67094. size = size;
  67095. data = [];
  67096. // Fill with zeros
  67097. for (var i = 0; i < size; i++) {
  67098. data.push(0);
  67099. }
  67100. }
  67101. this._fillAlignment(size);
  67102. this._uniformSizes[name] = size;
  67103. this._uniformLocations[name] = this._uniformLocationPointer;
  67104. this._uniformLocationPointer += size;
  67105. for (var i = 0; i < size; i++) {
  67106. this._data.push(data[i]);
  67107. }
  67108. this._needSync = true;
  67109. };
  67110. /**
  67111. * Adds a Matrix 4x4 to the uniform buffer.
  67112. * @param name Name of the uniform, as used in the uniform block in the shader.
  67113. * @param mat A 4x4 matrix.
  67114. */
  67115. UniformBuffer.prototype.addMatrix = function (name, mat) {
  67116. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  67117. };
  67118. /**
  67119. * Adds a vec2 to the uniform buffer.
  67120. * @param name Name of the uniform, as used in the uniform block in the shader.
  67121. * @param x Define the x component value of the vec2
  67122. * @param y Define the y component value of the vec2
  67123. */
  67124. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  67125. var temp = [x, y];
  67126. this.addUniform(name, temp);
  67127. };
  67128. /**
  67129. * Adds a vec3 to the uniform buffer.
  67130. * @param name Name of the uniform, as used in the uniform block in the shader.
  67131. * @param x Define the x component value of the vec3
  67132. * @param y Define the y component value of the vec3
  67133. * @param z Define the z component value of the vec3
  67134. */
  67135. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  67136. var temp = [x, y, z];
  67137. this.addUniform(name, temp);
  67138. };
  67139. /**
  67140. * Adds a vec3 to the uniform buffer.
  67141. * @param name Name of the uniform, as used in the uniform block in the shader.
  67142. * @param color Define the vec3 from a Color
  67143. */
  67144. UniformBuffer.prototype.addColor3 = function (name, color) {
  67145. var temp = new Array();
  67146. color.toArray(temp);
  67147. this.addUniform(name, temp);
  67148. };
  67149. /**
  67150. * Adds a vec4 to the uniform buffer.
  67151. * @param name Name of the uniform, as used in the uniform block in the shader.
  67152. * @param color Define the rgb components from a Color
  67153. * @param alpha Define the a component of the vec4
  67154. */
  67155. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  67156. var temp = new Array();
  67157. color.toArray(temp);
  67158. temp.push(alpha);
  67159. this.addUniform(name, temp);
  67160. };
  67161. /**
  67162. * Adds a vec3 to the uniform buffer.
  67163. * @param name Name of the uniform, as used in the uniform block in the shader.
  67164. * @param vector Define the vec3 components from a Vector
  67165. */
  67166. UniformBuffer.prototype.addVector3 = function (name, vector) {
  67167. var temp = new Array();
  67168. vector.toArray(temp);
  67169. this.addUniform(name, temp);
  67170. };
  67171. /**
  67172. * Adds a Matrix 3x3 to the uniform buffer.
  67173. * @param name Name of the uniform, as used in the uniform block in the shader.
  67174. */
  67175. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  67176. this.addUniform(name, 12);
  67177. };
  67178. /**
  67179. * Adds a Matrix 2x2 to the uniform buffer.
  67180. * @param name Name of the uniform, as used in the uniform block in the shader.
  67181. */
  67182. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  67183. this.addUniform(name, 8);
  67184. };
  67185. /**
  67186. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  67187. */
  67188. UniformBuffer.prototype.create = function () {
  67189. if (this._noUBO) {
  67190. return;
  67191. }
  67192. if (this._buffer) {
  67193. return; // nothing to do
  67194. }
  67195. // See spec, alignment must be filled as a vec4
  67196. this._fillAlignment(4);
  67197. this._bufferData = new Float32Array(this._data);
  67198. this._rebuild();
  67199. this._needSync = true;
  67200. };
  67201. /** @hidden */
  67202. UniformBuffer.prototype._rebuild = function () {
  67203. if (this._noUBO) {
  67204. return;
  67205. }
  67206. if (this._dynamic) {
  67207. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  67208. }
  67209. else {
  67210. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  67211. }
  67212. };
  67213. /**
  67214. * Updates the WebGL Uniform Buffer on the GPU.
  67215. * If the `dynamic` flag is set to true, no cache comparison is done.
  67216. * Otherwise, the buffer will be updated only if the cache differs.
  67217. */
  67218. UniformBuffer.prototype.update = function () {
  67219. if (!this._buffer) {
  67220. this.create();
  67221. return;
  67222. }
  67223. if (!this._dynamic && !this._needSync) {
  67224. return;
  67225. }
  67226. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  67227. this._needSync = false;
  67228. };
  67229. /**
  67230. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  67231. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67232. * @param data Define the flattened data
  67233. * @param size Define the size of the data.
  67234. */
  67235. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  67236. var location = this._uniformLocations[uniformName];
  67237. if (location === undefined) {
  67238. if (this._buffer) {
  67239. // Cannot add an uniform if the buffer is already created
  67240. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  67241. return;
  67242. }
  67243. this.addUniform(uniformName, size);
  67244. location = this._uniformLocations[uniformName];
  67245. }
  67246. if (!this._buffer) {
  67247. this.create();
  67248. }
  67249. if (!this._dynamic) {
  67250. // Cache for static uniform buffers
  67251. var changed = false;
  67252. for (var i = 0; i < size; i++) {
  67253. if (this._bufferData[location + i] !== data[i]) {
  67254. changed = true;
  67255. this._bufferData[location + i] = data[i];
  67256. }
  67257. }
  67258. this._needSync = this._needSync || changed;
  67259. }
  67260. else {
  67261. // No cache for dynamic
  67262. for (var i = 0; i < size; i++) {
  67263. this._bufferData[location + i] = data[i];
  67264. }
  67265. }
  67266. };
  67267. // Update methods
  67268. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  67269. // To match std140, matrix must be realigned
  67270. for (var i = 0; i < 3; i++) {
  67271. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  67272. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  67273. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  67274. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67275. }
  67276. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  67277. };
  67278. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  67279. this._currentEffect.setMatrix3x3(name, matrix);
  67280. };
  67281. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  67282. this._currentEffect.setMatrix2x2(name, matrix);
  67283. };
  67284. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  67285. // To match std140, matrix must be realigned
  67286. for (var i = 0; i < 2; i++) {
  67287. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  67288. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  67289. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  67290. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67291. }
  67292. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  67293. };
  67294. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  67295. this._currentEffect.setFloat(name, x);
  67296. };
  67297. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  67298. UniformBuffer._tempBuffer[0] = x;
  67299. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  67300. };
  67301. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  67302. if (suffix === void 0) { suffix = ""; }
  67303. this._currentEffect.setFloat2(name + suffix, x, y);
  67304. };
  67305. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  67306. UniformBuffer._tempBuffer[0] = x;
  67307. UniformBuffer._tempBuffer[1] = y;
  67308. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  67309. };
  67310. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  67311. if (suffix === void 0) { suffix = ""; }
  67312. this._currentEffect.setFloat3(name + suffix, x, y, z);
  67313. };
  67314. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  67315. UniformBuffer._tempBuffer[0] = x;
  67316. UniformBuffer._tempBuffer[1] = y;
  67317. UniformBuffer._tempBuffer[2] = z;
  67318. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67319. };
  67320. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  67321. if (suffix === void 0) { suffix = ""; }
  67322. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  67323. };
  67324. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  67325. UniformBuffer._tempBuffer[0] = x;
  67326. UniformBuffer._tempBuffer[1] = y;
  67327. UniformBuffer._tempBuffer[2] = z;
  67328. UniformBuffer._tempBuffer[3] = w;
  67329. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67330. };
  67331. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  67332. this._currentEffect.setMatrix(name, mat);
  67333. };
  67334. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  67335. this.updateUniform(name, mat.toArray(), 16);
  67336. };
  67337. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  67338. this._currentEffect.setVector3(name, vector);
  67339. };
  67340. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  67341. vector.toArray(UniformBuffer._tempBuffer);
  67342. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67343. };
  67344. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  67345. this._currentEffect.setVector4(name, vector);
  67346. };
  67347. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  67348. vector.toArray(UniformBuffer._tempBuffer);
  67349. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67350. };
  67351. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  67352. if (suffix === void 0) { suffix = ""; }
  67353. this._currentEffect.setColor3(name + suffix, color);
  67354. };
  67355. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  67356. color.toArray(UniformBuffer._tempBuffer);
  67357. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67358. };
  67359. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  67360. if (suffix === void 0) { suffix = ""; }
  67361. this._currentEffect.setColor4(name + suffix, color, alpha);
  67362. };
  67363. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  67364. color.toArray(UniformBuffer._tempBuffer);
  67365. UniformBuffer._tempBuffer[3] = alpha;
  67366. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67367. };
  67368. /**
  67369. * Sets a sampler uniform on the effect.
  67370. * @param name Define the name of the sampler.
  67371. * @param texture Define the texture to set in the sampler
  67372. */
  67373. UniformBuffer.prototype.setTexture = function (name, texture) {
  67374. this._currentEffect.setTexture(name, texture);
  67375. };
  67376. /**
  67377. * Directly updates the value of the uniform in the cache AND on the GPU.
  67378. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67379. * @param data Define the flattened data
  67380. */
  67381. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  67382. this.updateUniform(uniformName, data, data.length);
  67383. this.update();
  67384. };
  67385. /**
  67386. * Binds this uniform buffer to an effect.
  67387. * @param effect Define the effect to bind the buffer to
  67388. * @param name Name of the uniform block in the shader.
  67389. */
  67390. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  67391. this._currentEffect = effect;
  67392. if (this._noUBO || !this._buffer) {
  67393. return;
  67394. }
  67395. effect.bindUniformBuffer(this._buffer, name);
  67396. };
  67397. /**
  67398. * Disposes the uniform buffer.
  67399. */
  67400. UniformBuffer.prototype.dispose = function () {
  67401. if (this._noUBO) {
  67402. return;
  67403. }
  67404. var uniformBuffers = this._engine._uniformBuffers;
  67405. var index = uniformBuffers.indexOf(this);
  67406. if (index !== -1) {
  67407. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  67408. uniformBuffers.pop();
  67409. }
  67410. if (!this._buffer) {
  67411. return;
  67412. }
  67413. if (this._engine._releaseBuffer(this._buffer)) {
  67414. this._buffer = null;
  67415. }
  67416. };
  67417. // Pool for avoiding memory leaks
  67418. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  67419. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  67420. return UniformBuffer;
  67421. }());
  67422. /***/ }),
  67423. /***/ "./Maths/index.ts":
  67424. /*!************************!*\
  67425. !*** ./Maths/index.ts ***!
  67426. \************************/
  67427. /*! 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 */
  67428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67429. "use strict";
  67430. __webpack_require__.r(__webpack_exports__);
  67431. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  67433. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  67434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  67435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  67436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  67437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  67438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  67439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  67440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  67441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  67442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  67443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  67444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  67445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  67446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  67447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  67448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  67449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  67450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  67451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  67452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  67453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  67454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  67455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  67456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  67457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  67458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  67459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  67460. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  67461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  67462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  67463. /***/ }),
  67464. /***/ "./Maths/math.scalar.ts":
  67465. /*!******************************!*\
  67466. !*** ./Maths/math.scalar.ts ***!
  67467. \******************************/
  67468. /*! exports provided: Scalar */
  67469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67470. "use strict";
  67471. __webpack_require__.r(__webpack_exports__);
  67472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  67473. /**
  67474. * Scalar computation library
  67475. */
  67476. var Scalar = /** @class */ (function () {
  67477. function Scalar() {
  67478. }
  67479. /**
  67480. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67481. * @param a number
  67482. * @param b number
  67483. * @param epsilon (default = 1.401298E-45)
  67484. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67485. */
  67486. Scalar.WithinEpsilon = function (a, b, epsilon) {
  67487. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  67488. var num = a - b;
  67489. return -epsilon <= num && num <= epsilon;
  67490. };
  67491. /**
  67492. * Returns a string : the upper case translation of the number i to hexadecimal.
  67493. * @param i number
  67494. * @returns the upper case translation of the number i to hexadecimal.
  67495. */
  67496. Scalar.ToHex = function (i) {
  67497. var str = i.toString(16);
  67498. if (i <= 15) {
  67499. return ("0" + str).toUpperCase();
  67500. }
  67501. return str.toUpperCase();
  67502. };
  67503. /**
  67504. * Returns -1 if value is negative and +1 is value is positive.
  67505. * @param value the value
  67506. * @returns the value itself if it's equal to zero.
  67507. */
  67508. Scalar.Sign = function (value) {
  67509. value = +value; // convert to a number
  67510. if (value === 0 || isNaN(value)) {
  67511. return value;
  67512. }
  67513. return value > 0 ? 1 : -1;
  67514. };
  67515. /**
  67516. * Returns the value itself if it's between min and max.
  67517. * Returns min if the value is lower than min.
  67518. * Returns max if the value is greater than max.
  67519. * @param value the value to clmap
  67520. * @param min the min value to clamp to (default: 0)
  67521. * @param max the max value to clamp to (default: 1)
  67522. * @returns the clamped value
  67523. */
  67524. Scalar.Clamp = function (value, min, max) {
  67525. if (min === void 0) { min = 0; }
  67526. if (max === void 0) { max = 1; }
  67527. return Math.min(max, Math.max(min, value));
  67528. };
  67529. /**
  67530. * the log2 of value.
  67531. * @param value the value to compute log2 of
  67532. * @returns the log2 of value.
  67533. */
  67534. Scalar.Log2 = function (value) {
  67535. return Math.log(value) * Math.LOG2E;
  67536. };
  67537. /**
  67538. * Loops the value, so that it is never larger than length and never smaller than 0.
  67539. *
  67540. * This is similar to the modulo operator but it works with floating point numbers.
  67541. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67542. * With t = 5 and length = 2.5, the result would be 0.0.
  67543. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67544. * @param value the value
  67545. * @param length the length
  67546. * @returns the looped value
  67547. */
  67548. Scalar.Repeat = function (value, length) {
  67549. return value - Math.floor(value / length) * length;
  67550. };
  67551. /**
  67552. * Normalize the value between 0.0 and 1.0 using min and max values
  67553. * @param value value to normalize
  67554. * @param min max to normalize between
  67555. * @param max min to normalize between
  67556. * @returns the normalized value
  67557. */
  67558. Scalar.Normalize = function (value, min, max) {
  67559. return (value - min) / (max - min);
  67560. };
  67561. /**
  67562. * Denormalize the value from 0.0 and 1.0 using min and max values
  67563. * @param normalized value to denormalize
  67564. * @param min max to denormalize between
  67565. * @param max min to denormalize between
  67566. * @returns the denormalized value
  67567. */
  67568. Scalar.Denormalize = function (normalized, min, max) {
  67569. return (normalized * (max - min) + min);
  67570. };
  67571. /**
  67572. * Calculates the shortest difference between two given angles given in degrees.
  67573. * @param current current angle in degrees
  67574. * @param target target angle in degrees
  67575. * @returns the delta
  67576. */
  67577. Scalar.DeltaAngle = function (current, target) {
  67578. var num = Scalar.Repeat(target - current, 360.0);
  67579. if (num > 180.0) {
  67580. num -= 360.0;
  67581. }
  67582. return num;
  67583. };
  67584. /**
  67585. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67586. * @param tx value
  67587. * @param length length
  67588. * @returns The returned value will move back and forth between 0 and length
  67589. */
  67590. Scalar.PingPong = function (tx, length) {
  67591. var t = Scalar.Repeat(tx, length * 2.0);
  67592. return length - Math.abs(t - length);
  67593. };
  67594. /**
  67595. * Interpolates between min and max with smoothing at the limits.
  67596. *
  67597. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67598. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67599. * @param from from
  67600. * @param to to
  67601. * @param tx value
  67602. * @returns the smooth stepped value
  67603. */
  67604. Scalar.SmoothStep = function (from, to, tx) {
  67605. var t = Scalar.Clamp(tx);
  67606. t = -2.0 * t * t * t + 3.0 * t * t;
  67607. return to * t + from * (1.0 - t);
  67608. };
  67609. /**
  67610. * Moves a value current towards target.
  67611. *
  67612. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67613. * Negative values of maxDelta pushes the value away from target.
  67614. * @param current current value
  67615. * @param target target value
  67616. * @param maxDelta max distance to move
  67617. * @returns resulting value
  67618. */
  67619. Scalar.MoveTowards = function (current, target, maxDelta) {
  67620. var result = 0;
  67621. if (Math.abs(target - current) <= maxDelta) {
  67622. result = target;
  67623. }
  67624. else {
  67625. result = current + Scalar.Sign(target - current) * maxDelta;
  67626. }
  67627. return result;
  67628. };
  67629. /**
  67630. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67631. *
  67632. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67633. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67634. * @param current current value
  67635. * @param target target value
  67636. * @param maxDelta max distance to move
  67637. * @returns resulting angle
  67638. */
  67639. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  67640. var num = Scalar.DeltaAngle(current, target);
  67641. var result = 0;
  67642. if (-maxDelta < num && num < maxDelta) {
  67643. result = target;
  67644. }
  67645. else {
  67646. target = current + num;
  67647. result = Scalar.MoveTowards(current, target, maxDelta);
  67648. }
  67649. return result;
  67650. };
  67651. /**
  67652. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67653. * @param start start value
  67654. * @param end target value
  67655. * @param amount amount to lerp between
  67656. * @returns the lerped value
  67657. */
  67658. Scalar.Lerp = function (start, end, amount) {
  67659. return start + ((end - start) * amount);
  67660. };
  67661. /**
  67662. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67663. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67664. * @param start start value
  67665. * @param end target value
  67666. * @param amount amount to lerp between
  67667. * @returns the lerped value
  67668. */
  67669. Scalar.LerpAngle = function (start, end, amount) {
  67670. var num = Scalar.Repeat(end - start, 360.0);
  67671. if (num > 180.0) {
  67672. num -= 360.0;
  67673. }
  67674. return start + num * Scalar.Clamp(amount);
  67675. };
  67676. /**
  67677. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67678. * @param a start value
  67679. * @param b target value
  67680. * @param value value between a and b
  67681. * @returns the inverseLerp value
  67682. */
  67683. Scalar.InverseLerp = function (a, b, value) {
  67684. var result = 0;
  67685. if (a != b) {
  67686. result = Scalar.Clamp((value - a) / (b - a));
  67687. }
  67688. else {
  67689. result = 0.0;
  67690. }
  67691. return result;
  67692. };
  67693. /**
  67694. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67695. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67696. * @param value1 spline value
  67697. * @param tangent1 spline value
  67698. * @param value2 spline value
  67699. * @param tangent2 spline value
  67700. * @param amount input value
  67701. * @returns hermite result
  67702. */
  67703. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  67704. var squared = amount * amount;
  67705. var cubed = amount * squared;
  67706. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  67707. var part2 = (-2.0 * cubed) + (3.0 * squared);
  67708. var part3 = (cubed - (2.0 * squared)) + amount;
  67709. var part4 = cubed - squared;
  67710. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  67711. };
  67712. /**
  67713. * Returns a random float number between and min and max values
  67714. * @param min min value of random
  67715. * @param max max value of random
  67716. * @returns random value
  67717. */
  67718. Scalar.RandomRange = function (min, max) {
  67719. if (min === max) {
  67720. return min;
  67721. }
  67722. return ((Math.random() * (max - min)) + min);
  67723. };
  67724. /**
  67725. * This function returns percentage of a number in a given range.
  67726. *
  67727. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67728. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67729. * @param number to convert to percentage
  67730. * @param min min range
  67731. * @param max max range
  67732. * @returns the percentage
  67733. */
  67734. Scalar.RangeToPercent = function (number, min, max) {
  67735. return ((number - min) / (max - min));
  67736. };
  67737. /**
  67738. * This function returns number that corresponds to the percentage in a given range.
  67739. *
  67740. * PercentToRange(0.34,0,100) will return 34.
  67741. * @param percent to convert to number
  67742. * @param min min range
  67743. * @param max max range
  67744. * @returns the number
  67745. */
  67746. Scalar.PercentToRange = function (percent, min, max) {
  67747. return ((max - min) * percent + min);
  67748. };
  67749. /**
  67750. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67751. * @param angle The angle to normalize in radian.
  67752. * @return The converted angle.
  67753. */
  67754. Scalar.NormalizeRadians = function (angle) {
  67755. // More precise but slower version kept for reference.
  67756. // angle = angle % Tools.TwoPi;
  67757. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  67758. //if (angle > Math.PI) {
  67759. // angle -= Tools.TwoPi;
  67760. //}
  67761. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  67762. return angle;
  67763. };
  67764. /**
  67765. * Two pi constants convenient for computation.
  67766. */
  67767. Scalar.TwoPi = Math.PI * 2;
  67768. return Scalar;
  67769. }());
  67770. /***/ }),
  67771. /***/ "./Maths/math.ts":
  67772. /*!***********************!*\
  67773. !*** ./Maths/math.ts ***!
  67774. \***********************/
  67775. /*! 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 */
  67776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67777. "use strict";
  67778. __webpack_require__.r(__webpack_exports__);
  67779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  67780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  67781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  67782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  67783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  67784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  67785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  67786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  67787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  67788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  67789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  67790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  67791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  67792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  67793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  67794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  67795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  67796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  67797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  67798. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  67799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  67800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  67801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  67802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  67803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  67804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  67805. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  67806. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67807. /**
  67808. * Constant used to convert a value to gamma space
  67809. * @ignorenaming
  67810. */
  67811. var ToGammaSpace = 1 / 2.2;
  67812. /**
  67813. * Constant used to convert a value to linear space
  67814. * @ignorenaming
  67815. */
  67816. var ToLinearSpace = 2.2;
  67817. /**
  67818. * Constant used to define the minimal number value in Babylon.js
  67819. * @ignorenaming
  67820. */
  67821. var Epsilon = 0.001;
  67822. /**
  67823. * Class used to hold a RBG color
  67824. */
  67825. var Color3 = /** @class */ (function () {
  67826. /**
  67827. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  67828. * @param r defines the red component (between 0 and 1, default is 0)
  67829. * @param g defines the green component (between 0 and 1, default is 0)
  67830. * @param b defines the blue component (between 0 and 1, default is 0)
  67831. */
  67832. function Color3(
  67833. /**
  67834. * Defines the red component (between 0 and 1, default is 0)
  67835. */
  67836. r,
  67837. /**
  67838. * Defines the green component (between 0 and 1, default is 0)
  67839. */
  67840. g,
  67841. /**
  67842. * Defines the blue component (between 0 and 1, default is 0)
  67843. */
  67844. b) {
  67845. if (r === void 0) { r = 0; }
  67846. if (g === void 0) { g = 0; }
  67847. if (b === void 0) { b = 0; }
  67848. this.r = r;
  67849. this.g = g;
  67850. this.b = b;
  67851. }
  67852. /**
  67853. * Creates a string with the Color3 current values
  67854. * @returns the string representation of the Color3 object
  67855. */
  67856. Color3.prototype.toString = function () {
  67857. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  67858. };
  67859. /**
  67860. * Returns the string "Color3"
  67861. * @returns "Color3"
  67862. */
  67863. Color3.prototype.getClassName = function () {
  67864. return "Color3";
  67865. };
  67866. /**
  67867. * Compute the Color3 hash code
  67868. * @returns an unique number that can be used to hash Color3 objects
  67869. */
  67870. Color3.prototype.getHashCode = function () {
  67871. var hash = this.r || 0;
  67872. hash = (hash * 397) ^ (this.g || 0);
  67873. hash = (hash * 397) ^ (this.b || 0);
  67874. return hash;
  67875. };
  67876. // Operators
  67877. /**
  67878. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  67879. * @param array defines the array where to store the r,g,b components
  67880. * @param index defines an optional index in the target array to define where to start storing values
  67881. * @returns the current Color3 object
  67882. */
  67883. Color3.prototype.toArray = function (array, index) {
  67884. if (index === void 0) { index = 0; }
  67885. array[index] = this.r;
  67886. array[index + 1] = this.g;
  67887. array[index + 2] = this.b;
  67888. return this;
  67889. };
  67890. /**
  67891. * Returns a new Color4 object from the current Color3 and the given alpha
  67892. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  67893. * @returns a new Color4 object
  67894. */
  67895. Color3.prototype.toColor4 = function (alpha) {
  67896. if (alpha === void 0) { alpha = 1; }
  67897. return new Color4(this.r, this.g, this.b, alpha);
  67898. };
  67899. /**
  67900. * Returns a new array populated with 3 numeric elements : red, green and blue values
  67901. * @returns the new array
  67902. */
  67903. Color3.prototype.asArray = function () {
  67904. var result = new Array();
  67905. this.toArray(result, 0);
  67906. return result;
  67907. };
  67908. /**
  67909. * Returns the luminance value
  67910. * @returns a float value
  67911. */
  67912. Color3.prototype.toLuminance = function () {
  67913. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  67914. };
  67915. /**
  67916. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  67917. * @param otherColor defines the second operand
  67918. * @returns the new Color3 object
  67919. */
  67920. Color3.prototype.multiply = function (otherColor) {
  67921. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  67922. };
  67923. /**
  67924. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  67925. * @param otherColor defines the second operand
  67926. * @param result defines the Color3 object where to store the result
  67927. * @returns the current Color3
  67928. */
  67929. Color3.prototype.multiplyToRef = function (otherColor, result) {
  67930. result.r = this.r * otherColor.r;
  67931. result.g = this.g * otherColor.g;
  67932. result.b = this.b * otherColor.b;
  67933. return this;
  67934. };
  67935. /**
  67936. * Determines equality between Color3 objects
  67937. * @param otherColor defines the second operand
  67938. * @returns true if the rgb values are equal to the given ones
  67939. */
  67940. Color3.prototype.equals = function (otherColor) {
  67941. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  67942. };
  67943. /**
  67944. * Determines equality between the current Color3 object and a set of r,b,g values
  67945. * @param r defines the red component to check
  67946. * @param g defines the green component to check
  67947. * @param b defines the blue component to check
  67948. * @returns true if the rgb values are equal to the given ones
  67949. */
  67950. Color3.prototype.equalsFloats = function (r, g, b) {
  67951. return this.r === r && this.g === g && this.b === b;
  67952. };
  67953. /**
  67954. * Multiplies in place each rgb value by scale
  67955. * @param scale defines the scaling factor
  67956. * @returns the updated Color3
  67957. */
  67958. Color3.prototype.scale = function (scale) {
  67959. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  67960. };
  67961. /**
  67962. * Multiplies the rgb values by scale and stores the result into "result"
  67963. * @param scale defines the scaling factor
  67964. * @param result defines the Color3 object where to store the result
  67965. * @returns the unmodified current Color3
  67966. */
  67967. Color3.prototype.scaleToRef = function (scale, result) {
  67968. result.r = this.r * scale;
  67969. result.g = this.g * scale;
  67970. result.b = this.b * scale;
  67971. return this;
  67972. };
  67973. /**
  67974. * Scale the current Color3 values by a factor and add the result to a given Color3
  67975. * @param scale defines the scale factor
  67976. * @param result defines color to store the result into
  67977. * @returns the unmodified current Color3
  67978. */
  67979. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  67980. result.r += this.r * scale;
  67981. result.g += this.g * scale;
  67982. result.b += this.b * scale;
  67983. return this;
  67984. };
  67985. /**
  67986. * Clamps the rgb values by the min and max values and stores the result into "result"
  67987. * @param min defines minimum clamping value (default is 0)
  67988. * @param max defines maximum clamping value (default is 1)
  67989. * @param result defines color to store the result into
  67990. * @returns the original Color3
  67991. */
  67992. Color3.prototype.clampToRef = function (min, max, result) {
  67993. if (min === void 0) { min = 0; }
  67994. if (max === void 0) { max = 1; }
  67995. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67996. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67997. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67998. return this;
  67999. };
  68000. /**
  68001. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68002. * @param otherColor defines the second operand
  68003. * @returns the new Color3
  68004. */
  68005. Color3.prototype.add = function (otherColor) {
  68006. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  68007. };
  68008. /**
  68009. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68010. * @param otherColor defines the second operand
  68011. * @param result defines Color3 object to store the result into
  68012. * @returns the unmodified current Color3
  68013. */
  68014. Color3.prototype.addToRef = function (otherColor, result) {
  68015. result.r = this.r + otherColor.r;
  68016. result.g = this.g + otherColor.g;
  68017. result.b = this.b + otherColor.b;
  68018. return this;
  68019. };
  68020. /**
  68021. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68022. * @param otherColor defines the second operand
  68023. * @returns the new Color3
  68024. */
  68025. Color3.prototype.subtract = function (otherColor) {
  68026. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  68027. };
  68028. /**
  68029. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68030. * @param otherColor defines the second operand
  68031. * @param result defines Color3 object to store the result into
  68032. * @returns the unmodified current Color3
  68033. */
  68034. Color3.prototype.subtractToRef = function (otherColor, result) {
  68035. result.r = this.r - otherColor.r;
  68036. result.g = this.g - otherColor.g;
  68037. result.b = this.b - otherColor.b;
  68038. return this;
  68039. };
  68040. /**
  68041. * Copy the current object
  68042. * @returns a new Color3 copied the current one
  68043. */
  68044. Color3.prototype.clone = function () {
  68045. return new Color3(this.r, this.g, this.b);
  68046. };
  68047. /**
  68048. * Copies the rgb values from the source in the current Color3
  68049. * @param source defines the source Color3 object
  68050. * @returns the updated Color3 object
  68051. */
  68052. Color3.prototype.copyFrom = function (source) {
  68053. this.r = source.r;
  68054. this.g = source.g;
  68055. this.b = source.b;
  68056. return this;
  68057. };
  68058. /**
  68059. * Updates the Color3 rgb values from the given floats
  68060. * @param r defines the red component to read from
  68061. * @param g defines the green component to read from
  68062. * @param b defines the blue component to read from
  68063. * @returns the current Color3 object
  68064. */
  68065. Color3.prototype.copyFromFloats = function (r, g, b) {
  68066. this.r = r;
  68067. this.g = g;
  68068. this.b = b;
  68069. return this;
  68070. };
  68071. /**
  68072. * Updates the Color3 rgb values from the given floats
  68073. * @param r defines the red component to read from
  68074. * @param g defines the green component to read from
  68075. * @param b defines the blue component to read from
  68076. * @returns the current Color3 object
  68077. */
  68078. Color3.prototype.set = function (r, g, b) {
  68079. return this.copyFromFloats(r, g, b);
  68080. };
  68081. /**
  68082. * Compute the Color3 hexadecimal code as a string
  68083. * @returns a string containing the hexadecimal representation of the Color3 object
  68084. */
  68085. Color3.prototype.toHexString = function () {
  68086. var intR = (this.r * 255) | 0;
  68087. var intG = (this.g * 255) | 0;
  68088. var intB = (this.b * 255) | 0;
  68089. 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);
  68090. };
  68091. /**
  68092. * Computes a new Color3 converted from the current one to linear space
  68093. * @returns a new Color3 object
  68094. */
  68095. Color3.prototype.toLinearSpace = function () {
  68096. var convertedColor = new Color3();
  68097. this.toLinearSpaceToRef(convertedColor);
  68098. return convertedColor;
  68099. };
  68100. /**
  68101. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68102. * @param convertedColor defines the Color3 object where to store the linear space version
  68103. * @returns the unmodified Color3
  68104. */
  68105. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  68106. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68107. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68108. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68109. return this;
  68110. };
  68111. /**
  68112. * Computes a new Color3 converted from the current one to gamma space
  68113. * @returns a new Color3 object
  68114. */
  68115. Color3.prototype.toGammaSpace = function () {
  68116. var convertedColor = new Color3();
  68117. this.toGammaSpaceToRef(convertedColor);
  68118. return convertedColor;
  68119. };
  68120. /**
  68121. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68122. * @param convertedColor defines the Color3 object where to store the gamma space version
  68123. * @returns the unmodified Color3
  68124. */
  68125. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  68126. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68127. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68128. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68129. return this;
  68130. };
  68131. /**
  68132. * Creates a new Color3 from the string containing valid hexadecimal values
  68133. * @param hex defines a string containing valid hexadecimal values
  68134. * @returns a new Color3 object
  68135. */
  68136. Color3.FromHexString = function (hex) {
  68137. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  68138. return new Color3(0, 0, 0);
  68139. }
  68140. var r = parseInt(hex.substring(1, 3), 16);
  68141. var g = parseInt(hex.substring(3, 5), 16);
  68142. var b = parseInt(hex.substring(5, 7), 16);
  68143. return Color3.FromInts(r, g, b);
  68144. };
  68145. /**
  68146. * Creates a new Vector3 from the starting index of the given array
  68147. * @param array defines the source array
  68148. * @param offset defines an offset in the source array
  68149. * @returns a new Color3 object
  68150. */
  68151. Color3.FromArray = function (array, offset) {
  68152. if (offset === void 0) { offset = 0; }
  68153. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  68154. };
  68155. /**
  68156. * Creates a new Color3 from integer values (< 256)
  68157. * @param r defines the red component to read from (value between 0 and 255)
  68158. * @param g defines the green component to read from (value between 0 and 255)
  68159. * @param b defines the blue component to read from (value between 0 and 255)
  68160. * @returns a new Color3 object
  68161. */
  68162. Color3.FromInts = function (r, g, b) {
  68163. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  68164. };
  68165. /**
  68166. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68167. * @param start defines the start Color3 value
  68168. * @param end defines the end Color3 value
  68169. * @param amount defines the gradient value between start and end
  68170. * @returns a new Color3 object
  68171. */
  68172. Color3.Lerp = function (start, end, amount) {
  68173. var result = new Color3(0.0, 0.0, 0.0);
  68174. Color3.LerpToRef(start, end, amount, result);
  68175. return result;
  68176. };
  68177. /**
  68178. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68179. * @param left defines the start value
  68180. * @param right defines the end value
  68181. * @param amount defines the gradient factor
  68182. * @param result defines the Color3 object where to store the result
  68183. */
  68184. Color3.LerpToRef = function (left, right, amount, result) {
  68185. result.r = left.r + ((right.r - left.r) * amount);
  68186. result.g = left.g + ((right.g - left.g) * amount);
  68187. result.b = left.b + ((right.b - left.b) * amount);
  68188. };
  68189. /**
  68190. * Returns a Color3 value containing a red color
  68191. * @returns a new Color3 object
  68192. */
  68193. Color3.Red = function () { return new Color3(1, 0, 0); };
  68194. /**
  68195. * Returns a Color3 value containing a green color
  68196. * @returns a new Color3 object
  68197. */
  68198. Color3.Green = function () { return new Color3(0, 1, 0); };
  68199. /**
  68200. * Returns a Color3 value containing a blue color
  68201. * @returns a new Color3 object
  68202. */
  68203. Color3.Blue = function () { return new Color3(0, 0, 1); };
  68204. /**
  68205. * Returns a Color3 value containing a black color
  68206. * @returns a new Color3 object
  68207. */
  68208. Color3.Black = function () { return new Color3(0, 0, 0); };
  68209. Object.defineProperty(Color3, "BlackReadOnly", {
  68210. /**
  68211. * Gets a Color3 value containing a black color that must not be updated
  68212. */
  68213. get: function () {
  68214. return Color3._BlackReadOnly;
  68215. },
  68216. enumerable: true,
  68217. configurable: true
  68218. });
  68219. /**
  68220. * Returns a Color3 value containing a white color
  68221. * @returns a new Color3 object
  68222. */
  68223. Color3.White = function () { return new Color3(1, 1, 1); };
  68224. /**
  68225. * Returns a Color3 value containing a purple color
  68226. * @returns a new Color3 object
  68227. */
  68228. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  68229. /**
  68230. * Returns a Color3 value containing a magenta color
  68231. * @returns a new Color3 object
  68232. */
  68233. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  68234. /**
  68235. * Returns a Color3 value containing a yellow color
  68236. * @returns a new Color3 object
  68237. */
  68238. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  68239. /**
  68240. * Returns a Color3 value containing a gray color
  68241. * @returns a new Color3 object
  68242. */
  68243. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  68244. /**
  68245. * Returns a Color3 value containing a teal color
  68246. * @returns a new Color3 object
  68247. */
  68248. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  68249. /**
  68250. * Returns a Color3 value containing a random color
  68251. * @returns a new Color3 object
  68252. */
  68253. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  68254. // Statics
  68255. Color3._BlackReadOnly = Color3.Black();
  68256. return Color3;
  68257. }());
  68258. /**
  68259. * Class used to hold a RBGA color
  68260. */
  68261. var Color4 = /** @class */ (function () {
  68262. /**
  68263. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68264. * @param r defines the red component (between 0 and 1, default is 0)
  68265. * @param g defines the green component (between 0 and 1, default is 0)
  68266. * @param b defines the blue component (between 0 and 1, default is 0)
  68267. * @param a defines the alpha component (between 0 and 1, default is 1)
  68268. */
  68269. function Color4(
  68270. /**
  68271. * Defines the red component (between 0 and 1, default is 0)
  68272. */
  68273. r,
  68274. /**
  68275. * Defines the green component (between 0 and 1, default is 0)
  68276. */
  68277. g,
  68278. /**
  68279. * Defines the blue component (between 0 and 1, default is 0)
  68280. */
  68281. b,
  68282. /**
  68283. * Defines the alpha component (between 0 and 1, default is 1)
  68284. */
  68285. a) {
  68286. if (r === void 0) { r = 0; }
  68287. if (g === void 0) { g = 0; }
  68288. if (b === void 0) { b = 0; }
  68289. if (a === void 0) { a = 1; }
  68290. this.r = r;
  68291. this.g = g;
  68292. this.b = b;
  68293. this.a = a;
  68294. }
  68295. // Operators
  68296. /**
  68297. * Adds in place the given Color4 values to the current Color4 object
  68298. * @param right defines the second operand
  68299. * @returns the current updated Color4 object
  68300. */
  68301. Color4.prototype.addInPlace = function (right) {
  68302. this.r += right.r;
  68303. this.g += right.g;
  68304. this.b += right.b;
  68305. this.a += right.a;
  68306. return this;
  68307. };
  68308. /**
  68309. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68310. * @returns the new array
  68311. */
  68312. Color4.prototype.asArray = function () {
  68313. var result = new Array();
  68314. this.toArray(result, 0);
  68315. return result;
  68316. };
  68317. /**
  68318. * Stores from the starting index in the given array the Color4 successive values
  68319. * @param array defines the array where to store the r,g,b components
  68320. * @param index defines an optional index in the target array to define where to start storing values
  68321. * @returns the current Color4 object
  68322. */
  68323. Color4.prototype.toArray = function (array, index) {
  68324. if (index === void 0) { index = 0; }
  68325. array[index] = this.r;
  68326. array[index + 1] = this.g;
  68327. array[index + 2] = this.b;
  68328. array[index + 3] = this.a;
  68329. return this;
  68330. };
  68331. /**
  68332. * Determines equality between Color4 objects
  68333. * @param otherColor defines the second operand
  68334. * @returns true if the rgba values are equal to the given ones
  68335. */
  68336. Color4.prototype.equals = function (otherColor) {
  68337. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  68338. };
  68339. /**
  68340. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68341. * @param right defines the second operand
  68342. * @returns a new Color4 object
  68343. */
  68344. Color4.prototype.add = function (right) {
  68345. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  68346. };
  68347. /**
  68348. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68349. * @param right defines the second operand
  68350. * @returns a new Color4 object
  68351. */
  68352. Color4.prototype.subtract = function (right) {
  68353. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  68354. };
  68355. /**
  68356. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68357. * @param right defines the second operand
  68358. * @param result defines the Color4 object where to store the result
  68359. * @returns the current Color4 object
  68360. */
  68361. Color4.prototype.subtractToRef = function (right, result) {
  68362. result.r = this.r - right.r;
  68363. result.g = this.g - right.g;
  68364. result.b = this.b - right.b;
  68365. result.a = this.a - right.a;
  68366. return this;
  68367. };
  68368. /**
  68369. * Creates a new Color4 with the current Color4 values multiplied by scale
  68370. * @param scale defines the scaling factor to apply
  68371. * @returns a new Color4 object
  68372. */
  68373. Color4.prototype.scale = function (scale) {
  68374. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  68375. };
  68376. /**
  68377. * Multiplies the current Color4 values by scale and stores the result in "result"
  68378. * @param scale defines the scaling factor to apply
  68379. * @param result defines the Color4 object where to store the result
  68380. * @returns the current unmodified Color4
  68381. */
  68382. Color4.prototype.scaleToRef = function (scale, result) {
  68383. result.r = this.r * scale;
  68384. result.g = this.g * scale;
  68385. result.b = this.b * scale;
  68386. result.a = this.a * scale;
  68387. return this;
  68388. };
  68389. /**
  68390. * Scale the current Color4 values by a factor and add the result to a given Color4
  68391. * @param scale defines the scale factor
  68392. * @param result defines the Color4 object where to store the result
  68393. * @returns the unmodified current Color4
  68394. */
  68395. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  68396. result.r += this.r * scale;
  68397. result.g += this.g * scale;
  68398. result.b += this.b * scale;
  68399. result.a += this.a * scale;
  68400. return this;
  68401. };
  68402. /**
  68403. * Clamps the rgb values by the min and max values and stores the result into "result"
  68404. * @param min defines minimum clamping value (default is 0)
  68405. * @param max defines maximum clamping value (default is 1)
  68406. * @param result defines color to store the result into.
  68407. * @returns the cuurent Color4
  68408. */
  68409. Color4.prototype.clampToRef = function (min, max, result) {
  68410. if (min === void 0) { min = 0; }
  68411. if (max === void 0) { max = 1; }
  68412. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  68413. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  68414. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  68415. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  68416. return this;
  68417. };
  68418. /**
  68419. * Multipy an Color4 value by another and return a new Color4 object
  68420. * @param color defines the Color4 value to multiply by
  68421. * @returns a new Color4 object
  68422. */
  68423. Color4.prototype.multiply = function (color) {
  68424. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  68425. };
  68426. /**
  68427. * Multipy a Color4 value by another and push the result in a reference value
  68428. * @param color defines the Color4 value to multiply by
  68429. * @param result defines the Color4 to fill the result in
  68430. * @returns the result Color4
  68431. */
  68432. Color4.prototype.multiplyToRef = function (color, result) {
  68433. result.r = this.r * color.r;
  68434. result.g = this.g * color.g;
  68435. result.b = this.b * color.b;
  68436. result.a = this.a * color.a;
  68437. return result;
  68438. };
  68439. /**
  68440. * Creates a string with the Color4 current values
  68441. * @returns the string representation of the Color4 object
  68442. */
  68443. Color4.prototype.toString = function () {
  68444. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  68445. };
  68446. /**
  68447. * Returns the string "Color4"
  68448. * @returns "Color4"
  68449. */
  68450. Color4.prototype.getClassName = function () {
  68451. return "Color4";
  68452. };
  68453. /**
  68454. * Compute the Color4 hash code
  68455. * @returns an unique number that can be used to hash Color4 objects
  68456. */
  68457. Color4.prototype.getHashCode = function () {
  68458. var hash = this.r || 0;
  68459. hash = (hash * 397) ^ (this.g || 0);
  68460. hash = (hash * 397) ^ (this.b || 0);
  68461. hash = (hash * 397) ^ (this.a || 0);
  68462. return hash;
  68463. };
  68464. /**
  68465. * Creates a new Color4 copied from the current one
  68466. * @returns a new Color4 object
  68467. */
  68468. Color4.prototype.clone = function () {
  68469. return new Color4(this.r, this.g, this.b, this.a);
  68470. };
  68471. /**
  68472. * Copies the given Color4 values into the current one
  68473. * @param source defines the source Color4 object
  68474. * @returns the current updated Color4 object
  68475. */
  68476. Color4.prototype.copyFrom = function (source) {
  68477. this.r = source.r;
  68478. this.g = source.g;
  68479. this.b = source.b;
  68480. this.a = source.a;
  68481. return this;
  68482. };
  68483. /**
  68484. * Copies the given float values into the current one
  68485. * @param r defines the red component to read from
  68486. * @param g defines the green component to read from
  68487. * @param b defines the blue component to read from
  68488. * @param a defines the alpha component to read from
  68489. * @returns the current updated Color4 object
  68490. */
  68491. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  68492. this.r = r;
  68493. this.g = g;
  68494. this.b = b;
  68495. this.a = a;
  68496. return this;
  68497. };
  68498. /**
  68499. * Copies the given float values into the current one
  68500. * @param r defines the red component to read from
  68501. * @param g defines the green component to read from
  68502. * @param b defines the blue component to read from
  68503. * @param a defines the alpha component to read from
  68504. * @returns the current updated Color4 object
  68505. */
  68506. Color4.prototype.set = function (r, g, b, a) {
  68507. return this.copyFromFloats(r, g, b, a);
  68508. };
  68509. /**
  68510. * Compute the Color4 hexadecimal code as a string
  68511. * @returns a string containing the hexadecimal representation of the Color4 object
  68512. */
  68513. Color4.prototype.toHexString = function () {
  68514. var intR = (this.r * 255) | 0;
  68515. var intG = (this.g * 255) | 0;
  68516. var intB = (this.b * 255) | 0;
  68517. var intA = (this.a * 255) | 0;
  68518. 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);
  68519. };
  68520. /**
  68521. * Computes a new Color4 converted from the current one to linear space
  68522. * @returns a new Color4 object
  68523. */
  68524. Color4.prototype.toLinearSpace = function () {
  68525. var convertedColor = new Color4();
  68526. this.toLinearSpaceToRef(convertedColor);
  68527. return convertedColor;
  68528. };
  68529. /**
  68530. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  68531. * @param convertedColor defines the Color4 object where to store the linear space version
  68532. * @returns the unmodified Color4
  68533. */
  68534. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  68535. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68536. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68537. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68538. convertedColor.a = this.a;
  68539. return this;
  68540. };
  68541. /**
  68542. * Computes a new Color4 converted from the current one to gamma space
  68543. * @returns a new Color4 object
  68544. */
  68545. Color4.prototype.toGammaSpace = function () {
  68546. var convertedColor = new Color4();
  68547. this.toGammaSpaceToRef(convertedColor);
  68548. return convertedColor;
  68549. };
  68550. /**
  68551. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  68552. * @param convertedColor defines the Color4 object where to store the gamma space version
  68553. * @returns the unmodified Color4
  68554. */
  68555. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  68556. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68557. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68558. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68559. convertedColor.a = this.a;
  68560. return this;
  68561. };
  68562. // Statics
  68563. /**
  68564. * Creates a new Color4 from the string containing valid hexadecimal values
  68565. * @param hex defines a string containing valid hexadecimal values
  68566. * @returns a new Color4 object
  68567. */
  68568. Color4.FromHexString = function (hex) {
  68569. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  68570. return new Color4(0.0, 0.0, 0.0, 0.0);
  68571. }
  68572. var r = parseInt(hex.substring(1, 3), 16);
  68573. var g = parseInt(hex.substring(3, 5), 16);
  68574. var b = parseInt(hex.substring(5, 7), 16);
  68575. var a = parseInt(hex.substring(7, 9), 16);
  68576. return Color4.FromInts(r, g, b, a);
  68577. };
  68578. /**
  68579. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68580. * @param left defines the start value
  68581. * @param right defines the end value
  68582. * @param amount defines the gradient factor
  68583. * @returns a new Color4 object
  68584. */
  68585. Color4.Lerp = function (left, right, amount) {
  68586. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  68587. Color4.LerpToRef(left, right, amount, result);
  68588. return result;
  68589. };
  68590. /**
  68591. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68592. * @param left defines the start value
  68593. * @param right defines the end value
  68594. * @param amount defines the gradient factor
  68595. * @param result defines the Color4 object where to store data
  68596. */
  68597. Color4.LerpToRef = function (left, right, amount, result) {
  68598. result.r = left.r + (right.r - left.r) * amount;
  68599. result.g = left.g + (right.g - left.g) * amount;
  68600. result.b = left.b + (right.b - left.b) * amount;
  68601. result.a = left.a + (right.a - left.a) * amount;
  68602. };
  68603. /**
  68604. * Creates a new Color4 from a Color3 and an alpha value
  68605. * @param color3 defines the source Color3 to read from
  68606. * @param alpha defines the alpha component (1.0 by default)
  68607. * @returns a new Color4 object
  68608. */
  68609. Color4.FromColor3 = function (color3, alpha) {
  68610. if (alpha === void 0) { alpha = 1.0; }
  68611. return new Color4(color3.r, color3.g, color3.b, alpha);
  68612. };
  68613. /**
  68614. * Creates a new Color4 from the starting index element of the given array
  68615. * @param array defines the source array to read from
  68616. * @param offset defines the offset in the source array
  68617. * @returns a new Color4 object
  68618. */
  68619. Color4.FromArray = function (array, offset) {
  68620. if (offset === void 0) { offset = 0; }
  68621. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  68622. };
  68623. /**
  68624. * Creates a new Color3 from integer values (< 256)
  68625. * @param r defines the red component to read from (value between 0 and 255)
  68626. * @param g defines the green component to read from (value between 0 and 255)
  68627. * @param b defines the blue component to read from (value between 0 and 255)
  68628. * @param a defines the alpha component to read from (value between 0 and 255)
  68629. * @returns a new Color3 object
  68630. */
  68631. Color4.FromInts = function (r, g, b, a) {
  68632. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  68633. };
  68634. /**
  68635. * Check the content of a given array and convert it to an array containing RGBA data
  68636. * If the original array was already containing count * 4 values then it is returned directly
  68637. * @param colors defines the array to check
  68638. * @param count defines the number of RGBA data to expect
  68639. * @returns an array containing count * 4 values (RGBA)
  68640. */
  68641. Color4.CheckColors4 = function (colors, count) {
  68642. // Check if color3 was used
  68643. if (colors.length === count * 3) {
  68644. var colors4 = [];
  68645. for (var index = 0; index < colors.length; index += 3) {
  68646. var newIndex = (index / 3) * 4;
  68647. colors4[newIndex] = colors[index];
  68648. colors4[newIndex + 1] = colors[index + 1];
  68649. colors4[newIndex + 2] = colors[index + 2];
  68650. colors4[newIndex + 3] = 1.0;
  68651. }
  68652. return colors4;
  68653. }
  68654. return colors;
  68655. };
  68656. return Color4;
  68657. }());
  68658. /**
  68659. * Class representing a vector containing 2 coordinates
  68660. */
  68661. var Vector2 = /** @class */ (function () {
  68662. /**
  68663. * Creates a new Vector2 from the given x and y coordinates
  68664. * @param x defines the first coordinate
  68665. * @param y defines the second coordinate
  68666. */
  68667. function Vector2(
  68668. /** defines the first coordinate */
  68669. x,
  68670. /** defines the second coordinate */
  68671. y) {
  68672. if (x === void 0) { x = 0; }
  68673. if (y === void 0) { y = 0; }
  68674. this.x = x;
  68675. this.y = y;
  68676. }
  68677. /**
  68678. * Gets a string with the Vector2 coordinates
  68679. * @returns a string with the Vector2 coordinates
  68680. */
  68681. Vector2.prototype.toString = function () {
  68682. return "{X: " + this.x + " Y:" + this.y + "}";
  68683. };
  68684. /**
  68685. * Gets class name
  68686. * @returns the string "Vector2"
  68687. */
  68688. Vector2.prototype.getClassName = function () {
  68689. return "Vector2";
  68690. };
  68691. /**
  68692. * Gets current vector hash code
  68693. * @returns the Vector2 hash code as a number
  68694. */
  68695. Vector2.prototype.getHashCode = function () {
  68696. var hash = this.x || 0;
  68697. hash = (hash * 397) ^ (this.y || 0);
  68698. return hash;
  68699. };
  68700. // Operators
  68701. /**
  68702. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68703. * @param array defines the source array
  68704. * @param index defines the offset in source array
  68705. * @returns the current Vector2
  68706. */
  68707. Vector2.prototype.toArray = function (array, index) {
  68708. if (index === void 0) { index = 0; }
  68709. array[index] = this.x;
  68710. array[index + 1] = this.y;
  68711. return this;
  68712. };
  68713. /**
  68714. * Copy the current vector to an array
  68715. * @returns a new array with 2 elements: the Vector2 coordinates.
  68716. */
  68717. Vector2.prototype.asArray = function () {
  68718. var result = new Array();
  68719. this.toArray(result, 0);
  68720. return result;
  68721. };
  68722. /**
  68723. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68724. * @param source defines the source Vector2
  68725. * @returns the current updated Vector2
  68726. */
  68727. Vector2.prototype.copyFrom = function (source) {
  68728. this.x = source.x;
  68729. this.y = source.y;
  68730. return this;
  68731. };
  68732. /**
  68733. * Sets the Vector2 coordinates with the given floats
  68734. * @param x defines the first coordinate
  68735. * @param y defines the second coordinate
  68736. * @returns the current updated Vector2
  68737. */
  68738. Vector2.prototype.copyFromFloats = function (x, y) {
  68739. this.x = x;
  68740. this.y = y;
  68741. return this;
  68742. };
  68743. /**
  68744. * Sets the Vector2 coordinates with the given floats
  68745. * @param x defines the first coordinate
  68746. * @param y defines the second coordinate
  68747. * @returns the current updated Vector2
  68748. */
  68749. Vector2.prototype.set = function (x, y) {
  68750. return this.copyFromFloats(x, y);
  68751. };
  68752. /**
  68753. * Add another vector with the current one
  68754. * @param otherVector defines the other vector
  68755. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68756. */
  68757. Vector2.prototype.add = function (otherVector) {
  68758. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68759. };
  68760. /**
  68761. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68762. * @param otherVector defines the other vector
  68763. * @param result defines the target vector
  68764. * @returns the unmodified current Vector2
  68765. */
  68766. Vector2.prototype.addToRef = function (otherVector, result) {
  68767. result.x = this.x + otherVector.x;
  68768. result.y = this.y + otherVector.y;
  68769. return this;
  68770. };
  68771. /**
  68772. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68773. * @param otherVector defines the other vector
  68774. * @returns the current updated Vector2
  68775. */
  68776. Vector2.prototype.addInPlace = function (otherVector) {
  68777. this.x += otherVector.x;
  68778. this.y += otherVector.y;
  68779. return this;
  68780. };
  68781. /**
  68782. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68783. * @param otherVector defines the other vector
  68784. * @returns a new Vector2
  68785. */
  68786. Vector2.prototype.addVector3 = function (otherVector) {
  68787. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68788. };
  68789. /**
  68790. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68791. * @param otherVector defines the other vector
  68792. * @returns a new Vector2
  68793. */
  68794. Vector2.prototype.subtract = function (otherVector) {
  68795. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  68796. };
  68797. /**
  68798. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68799. * @param otherVector defines the other vector
  68800. * @param result defines the target vector
  68801. * @returns the unmodified current Vector2
  68802. */
  68803. Vector2.prototype.subtractToRef = function (otherVector, result) {
  68804. result.x = this.x - otherVector.x;
  68805. result.y = this.y - otherVector.y;
  68806. return this;
  68807. };
  68808. /**
  68809. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68810. * @param otherVector defines the other vector
  68811. * @returns the current updated Vector2
  68812. */
  68813. Vector2.prototype.subtractInPlace = function (otherVector) {
  68814. this.x -= otherVector.x;
  68815. this.y -= otherVector.y;
  68816. return this;
  68817. };
  68818. /**
  68819. * Multiplies in place the current Vector2 coordinates by the given ones
  68820. * @param otherVector defines the other vector
  68821. * @returns the current updated Vector2
  68822. */
  68823. Vector2.prototype.multiplyInPlace = function (otherVector) {
  68824. this.x *= otherVector.x;
  68825. this.y *= otherVector.y;
  68826. return this;
  68827. };
  68828. /**
  68829. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68830. * @param otherVector defines the other vector
  68831. * @returns a new Vector2
  68832. */
  68833. Vector2.prototype.multiply = function (otherVector) {
  68834. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  68835. };
  68836. /**
  68837. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68838. * @param otherVector defines the other vector
  68839. * @param result defines the target vector
  68840. * @returns the unmodified current Vector2
  68841. */
  68842. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  68843. result.x = this.x * otherVector.x;
  68844. result.y = this.y * otherVector.y;
  68845. return this;
  68846. };
  68847. /**
  68848. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68849. * @param x defines the first coordinate
  68850. * @param y defines the second coordinate
  68851. * @returns a new Vector2
  68852. */
  68853. Vector2.prototype.multiplyByFloats = function (x, y) {
  68854. return new Vector2(this.x * x, this.y * y);
  68855. };
  68856. /**
  68857. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68858. * @param otherVector defines the other vector
  68859. * @returns a new Vector2
  68860. */
  68861. Vector2.prototype.divide = function (otherVector) {
  68862. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  68863. };
  68864. /**
  68865. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68866. * @param otherVector defines the other vector
  68867. * @param result defines the target vector
  68868. * @returns the unmodified current Vector2
  68869. */
  68870. Vector2.prototype.divideToRef = function (otherVector, result) {
  68871. result.x = this.x / otherVector.x;
  68872. result.y = this.y / otherVector.y;
  68873. return this;
  68874. };
  68875. /**
  68876. * Divides the current Vector2 coordinates by the given ones
  68877. * @param otherVector defines the other vector
  68878. * @returns the current updated Vector2
  68879. */
  68880. Vector2.prototype.divideInPlace = function (otherVector) {
  68881. return this.divideToRef(otherVector, this);
  68882. };
  68883. /**
  68884. * Gets a new Vector2 with current Vector2 negated coordinates
  68885. * @returns a new Vector2
  68886. */
  68887. Vector2.prototype.negate = function () {
  68888. return new Vector2(-this.x, -this.y);
  68889. };
  68890. /**
  68891. * Multiply the Vector2 coordinates by scale
  68892. * @param scale defines the scaling factor
  68893. * @returns the current updated Vector2
  68894. */
  68895. Vector2.prototype.scaleInPlace = function (scale) {
  68896. this.x *= scale;
  68897. this.y *= scale;
  68898. return this;
  68899. };
  68900. /**
  68901. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68902. * @param scale defines the scaling factor
  68903. * @returns a new Vector2
  68904. */
  68905. Vector2.prototype.scale = function (scale) {
  68906. var result = new Vector2(0, 0);
  68907. this.scaleToRef(scale, result);
  68908. return result;
  68909. };
  68910. /**
  68911. * Scale the current Vector2 values by a factor to a given Vector2
  68912. * @param scale defines the scale factor
  68913. * @param result defines the Vector2 object where to store the result
  68914. * @returns the unmodified current Vector2
  68915. */
  68916. Vector2.prototype.scaleToRef = function (scale, result) {
  68917. result.x = this.x * scale;
  68918. result.y = this.y * scale;
  68919. return this;
  68920. };
  68921. /**
  68922. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68923. * @param scale defines the scale factor
  68924. * @param result defines the Vector2 object where to store the result
  68925. * @returns the unmodified current Vector2
  68926. */
  68927. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  68928. result.x += this.x * scale;
  68929. result.y += this.y * scale;
  68930. return this;
  68931. };
  68932. /**
  68933. * Gets a boolean if two vectors are equals
  68934. * @param otherVector defines the other vector
  68935. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68936. */
  68937. Vector2.prototype.equals = function (otherVector) {
  68938. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  68939. };
  68940. /**
  68941. * Gets a boolean if two vectors are equals (using an epsilon value)
  68942. * @param otherVector defines the other vector
  68943. * @param epsilon defines the minimal distance to consider equality
  68944. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68945. */
  68946. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68947. if (epsilon === void 0) { epsilon = Epsilon; }
  68948. 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);
  68949. };
  68950. /**
  68951. * Gets a new Vector2 from current Vector2 floored values
  68952. * @returns a new Vector2
  68953. */
  68954. Vector2.prototype.floor = function () {
  68955. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  68956. };
  68957. /**
  68958. * Gets a new Vector2 from current Vector2 floored values
  68959. * @returns a new Vector2
  68960. */
  68961. Vector2.prototype.fract = function () {
  68962. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  68963. };
  68964. // Properties
  68965. /**
  68966. * Gets the length of the vector
  68967. * @returns the vector length (float)
  68968. */
  68969. Vector2.prototype.length = function () {
  68970. return Math.sqrt(this.x * this.x + this.y * this.y);
  68971. };
  68972. /**
  68973. * Gets the vector squared length
  68974. * @returns the vector squared length (float)
  68975. */
  68976. Vector2.prototype.lengthSquared = function () {
  68977. return (this.x * this.x + this.y * this.y);
  68978. };
  68979. // Methods
  68980. /**
  68981. * Normalize the vector
  68982. * @returns the current updated Vector2
  68983. */
  68984. Vector2.prototype.normalize = function () {
  68985. var len = this.length();
  68986. if (len === 0) {
  68987. return this;
  68988. }
  68989. var num = 1.0 / len;
  68990. this.x *= num;
  68991. this.y *= num;
  68992. return this;
  68993. };
  68994. /**
  68995. * Gets a new Vector2 copied from the Vector2
  68996. * @returns a new Vector2
  68997. */
  68998. Vector2.prototype.clone = function () {
  68999. return new Vector2(this.x, this.y);
  69000. };
  69001. // Statics
  69002. /**
  69003. * Gets a new Vector2(0, 0)
  69004. * @returns a new Vector2
  69005. */
  69006. Vector2.Zero = function () {
  69007. return new Vector2(0, 0);
  69008. };
  69009. /**
  69010. * Gets a new Vector2(1, 1)
  69011. * @returns a new Vector2
  69012. */
  69013. Vector2.One = function () {
  69014. return new Vector2(1, 1);
  69015. };
  69016. /**
  69017. * Gets a new Vector2 set from the given index element of the given array
  69018. * @param array defines the data source
  69019. * @param offset defines the offset in the data source
  69020. * @returns a new Vector2
  69021. */
  69022. Vector2.FromArray = function (array, offset) {
  69023. if (offset === void 0) { offset = 0; }
  69024. return new Vector2(array[offset], array[offset + 1]);
  69025. };
  69026. /**
  69027. * Sets "result" from the given index element of the given array
  69028. * @param array defines the data source
  69029. * @param offset defines the offset in the data source
  69030. * @param result defines the target vector
  69031. */
  69032. Vector2.FromArrayToRef = function (array, offset, result) {
  69033. result.x = array[offset];
  69034. result.y = array[offset + 1];
  69035. };
  69036. /**
  69037. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69038. * @param value1 defines 1st point of control
  69039. * @param value2 defines 2nd point of control
  69040. * @param value3 defines 3rd point of control
  69041. * @param value4 defines 4th point of control
  69042. * @param amount defines the interpolation factor
  69043. * @returns a new Vector2
  69044. */
  69045. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  69046. var squared = amount * amount;
  69047. var cubed = amount * squared;
  69048. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69049. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69050. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69051. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69052. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69053. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69054. return new Vector2(x, y);
  69055. };
  69056. /**
  69057. * 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".
  69058. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69059. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69060. * @param value defines the value to clamp
  69061. * @param min defines the lower limit
  69062. * @param max defines the upper limit
  69063. * @returns a new Vector2
  69064. */
  69065. Vector2.Clamp = function (value, min, max) {
  69066. var x = value.x;
  69067. x = (x > max.x) ? max.x : x;
  69068. x = (x < min.x) ? min.x : x;
  69069. var y = value.y;
  69070. y = (y > max.y) ? max.y : y;
  69071. y = (y < min.y) ? min.y : y;
  69072. return new Vector2(x, y);
  69073. };
  69074. /**
  69075. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69076. * @param value1 defines the 1st control point
  69077. * @param tangent1 defines the outgoing tangent
  69078. * @param value2 defines the 2nd control point
  69079. * @param tangent2 defines the incoming tangent
  69080. * @param amount defines the interpolation factor
  69081. * @returns a new Vector2
  69082. */
  69083. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69084. var squared = amount * amount;
  69085. var cubed = amount * squared;
  69086. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69087. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69088. var part3 = (cubed - (2.0 * squared)) + amount;
  69089. var part4 = cubed - squared;
  69090. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69091. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69092. return new Vector2(x, y);
  69093. };
  69094. /**
  69095. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69096. * @param start defines the start vector
  69097. * @param end defines the end vector
  69098. * @param amount defines the interpolation factor
  69099. * @returns a new Vector2
  69100. */
  69101. Vector2.Lerp = function (start, end, amount) {
  69102. var x = start.x + ((end.x - start.x) * amount);
  69103. var y = start.y + ((end.y - start.y) * amount);
  69104. return new Vector2(x, y);
  69105. };
  69106. /**
  69107. * Gets the dot product of the vector "left" and the vector "right"
  69108. * @param left defines first vector
  69109. * @param right defines second vector
  69110. * @returns the dot product (float)
  69111. */
  69112. Vector2.Dot = function (left, right) {
  69113. return left.x * right.x + left.y * right.y;
  69114. };
  69115. /**
  69116. * Returns a new Vector2 equal to the normalized given vector
  69117. * @param vector defines the vector to normalize
  69118. * @returns a new Vector2
  69119. */
  69120. Vector2.Normalize = function (vector) {
  69121. var newVector = vector.clone();
  69122. newVector.normalize();
  69123. return newVector;
  69124. };
  69125. /**
  69126. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69127. * @param left defines 1st vector
  69128. * @param right defines 2nd vector
  69129. * @returns a new Vector2
  69130. */
  69131. Vector2.Minimize = function (left, right) {
  69132. var x = (left.x < right.x) ? left.x : right.x;
  69133. var y = (left.y < right.y) ? left.y : right.y;
  69134. return new Vector2(x, y);
  69135. };
  69136. /**
  69137. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69138. * @param left defines 1st vector
  69139. * @param right defines 2nd vector
  69140. * @returns a new Vector2
  69141. */
  69142. Vector2.Maximize = function (left, right) {
  69143. var x = (left.x > right.x) ? left.x : right.x;
  69144. var y = (left.y > right.y) ? left.y : right.y;
  69145. return new Vector2(x, y);
  69146. };
  69147. /**
  69148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69149. * @param vector defines the vector to transform
  69150. * @param transformation defines the matrix to apply
  69151. * @returns a new Vector2
  69152. */
  69153. Vector2.Transform = function (vector, transformation) {
  69154. var r = Vector2.Zero();
  69155. Vector2.TransformToRef(vector, transformation, r);
  69156. return r;
  69157. };
  69158. /**
  69159. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69160. * @param vector defines the vector to transform
  69161. * @param transformation defines the matrix to apply
  69162. * @param result defines the target vector
  69163. */
  69164. Vector2.TransformToRef = function (vector, transformation, result) {
  69165. var m = transformation.m;
  69166. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  69167. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  69168. result.x = x;
  69169. result.y = y;
  69170. };
  69171. /**
  69172. * Determines if a given vector is included in a triangle
  69173. * @param p defines the vector to test
  69174. * @param p0 defines 1st triangle point
  69175. * @param p1 defines 2nd triangle point
  69176. * @param p2 defines 3rd triangle point
  69177. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69178. */
  69179. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  69180. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  69181. var sign = a < 0 ? -1 : 1;
  69182. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  69183. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  69184. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  69185. };
  69186. /**
  69187. * Gets the distance between the vectors "value1" and "value2"
  69188. * @param value1 defines first vector
  69189. * @param value2 defines second vector
  69190. * @returns the distance between vectors
  69191. */
  69192. Vector2.Distance = function (value1, value2) {
  69193. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  69194. };
  69195. /**
  69196. * Returns the squared distance between the vectors "value1" and "value2"
  69197. * @param value1 defines first vector
  69198. * @param value2 defines second vector
  69199. * @returns the squared distance between vectors
  69200. */
  69201. Vector2.DistanceSquared = function (value1, value2) {
  69202. var x = value1.x - value2.x;
  69203. var y = value1.y - value2.y;
  69204. return (x * x) + (y * y);
  69205. };
  69206. /**
  69207. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69208. * @param value1 defines first vector
  69209. * @param value2 defines second vector
  69210. * @returns a new Vector2
  69211. */
  69212. Vector2.Center = function (value1, value2) {
  69213. var center = value1.add(value2);
  69214. center.scaleInPlace(0.5);
  69215. return center;
  69216. };
  69217. /**
  69218. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69219. * @param p defines the middle point
  69220. * @param segA defines one point of the segment
  69221. * @param segB defines the other point of the segment
  69222. * @returns the shortest distance
  69223. */
  69224. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  69225. var l2 = Vector2.DistanceSquared(segA, segB);
  69226. if (l2 === 0.0) {
  69227. return Vector2.Distance(p, segA);
  69228. }
  69229. var v = segB.subtract(segA);
  69230. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  69231. var proj = segA.add(v.multiplyByFloats(t, t));
  69232. return Vector2.Distance(p, proj);
  69233. };
  69234. return Vector2;
  69235. }());
  69236. /**
  69237. * Classed used to store (x,y,z) vector representation
  69238. * A Vector3 is the main object used in 3D geometry
  69239. * It can represent etiher the coordinates of a point the space, either a direction
  69240. * Reminder: js uses a left handed forward facing system
  69241. */
  69242. var Vector3 = /** @class */ (function () {
  69243. /**
  69244. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69245. * @param x defines the first coordinates (on X axis)
  69246. * @param y defines the second coordinates (on Y axis)
  69247. * @param z defines the third coordinates (on Z axis)
  69248. */
  69249. function Vector3(
  69250. /**
  69251. * Defines the first coordinates (on X axis)
  69252. */
  69253. x,
  69254. /**
  69255. * Defines the second coordinates (on Y axis)
  69256. */
  69257. y,
  69258. /**
  69259. * Defines the third coordinates (on Z axis)
  69260. */
  69261. z) {
  69262. if (x === void 0) { x = 0; }
  69263. if (y === void 0) { y = 0; }
  69264. if (z === void 0) { z = 0; }
  69265. this.x = x;
  69266. this.y = y;
  69267. this.z = z;
  69268. }
  69269. /**
  69270. * Creates a string representation of the Vector3
  69271. * @returns a string with the Vector3 coordinates.
  69272. */
  69273. Vector3.prototype.toString = function () {
  69274. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  69275. };
  69276. /**
  69277. * Gets the class name
  69278. * @returns the string "Vector3"
  69279. */
  69280. Vector3.prototype.getClassName = function () {
  69281. return "Vector3";
  69282. };
  69283. /**
  69284. * Creates the Vector3 hash code
  69285. * @returns a number which tends to be unique between Vector3 instances
  69286. */
  69287. Vector3.prototype.getHashCode = function () {
  69288. var hash = this.x || 0;
  69289. hash = (hash * 397) ^ (this.y || 0);
  69290. hash = (hash * 397) ^ (this.z || 0);
  69291. return hash;
  69292. };
  69293. // Operators
  69294. /**
  69295. * Creates an array containing three elements : the coordinates of the Vector3
  69296. * @returns a new array of numbers
  69297. */
  69298. Vector3.prototype.asArray = function () {
  69299. var result = [];
  69300. this.toArray(result, 0);
  69301. return result;
  69302. };
  69303. /**
  69304. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69305. * @param array defines the destination array
  69306. * @param index defines the offset in the destination array
  69307. * @returns the current Vector3
  69308. */
  69309. Vector3.prototype.toArray = function (array, index) {
  69310. if (index === void 0) { index = 0; }
  69311. array[index] = this.x;
  69312. array[index + 1] = this.y;
  69313. array[index + 2] = this.z;
  69314. return this;
  69315. };
  69316. /**
  69317. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69318. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69319. */
  69320. Vector3.prototype.toQuaternion = function () {
  69321. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  69322. };
  69323. /**
  69324. * Adds the given vector to the current Vector3
  69325. * @param otherVector defines the second operand
  69326. * @returns the current updated Vector3
  69327. */
  69328. Vector3.prototype.addInPlace = function (otherVector) {
  69329. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  69330. };
  69331. /**
  69332. * Adds the given coordinates to the current Vector3
  69333. * @param x defines the x coordinate of the operand
  69334. * @param y defines the y coordinate of the operand
  69335. * @param z defines the z coordinate of the operand
  69336. * @returns the current updated Vector3
  69337. */
  69338. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  69339. this.x += x;
  69340. this.y += y;
  69341. this.z += z;
  69342. return this;
  69343. };
  69344. /**
  69345. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69346. * @param otherVector defines the second operand
  69347. * @returns the resulting Vector3
  69348. */
  69349. Vector3.prototype.add = function (otherVector) {
  69350. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69351. };
  69352. /**
  69353. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69354. * @param otherVector defines the second operand
  69355. * @param result defines the Vector3 object where to store the result
  69356. * @returns the current Vector3
  69357. */
  69358. Vector3.prototype.addToRef = function (otherVector, result) {
  69359. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69360. };
  69361. /**
  69362. * Subtract the given vector from the current Vector3
  69363. * @param otherVector defines the second operand
  69364. * @returns the current updated Vector3
  69365. */
  69366. Vector3.prototype.subtractInPlace = function (otherVector) {
  69367. this.x -= otherVector.x;
  69368. this.y -= otherVector.y;
  69369. this.z -= otherVector.z;
  69370. return this;
  69371. };
  69372. /**
  69373. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69374. * @param otherVector defines the second operand
  69375. * @returns the resulting Vector3
  69376. */
  69377. Vector3.prototype.subtract = function (otherVector) {
  69378. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  69379. };
  69380. /**
  69381. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69382. * @param otherVector defines the second operand
  69383. * @param result defines the Vector3 object where to store the result
  69384. * @returns the current Vector3
  69385. */
  69386. Vector3.prototype.subtractToRef = function (otherVector, result) {
  69387. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  69388. };
  69389. /**
  69390. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69391. * @param x defines the x coordinate of the operand
  69392. * @param y defines the y coordinate of the operand
  69393. * @param z defines the z coordinate of the operand
  69394. * @returns the resulting Vector3
  69395. */
  69396. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  69397. return new Vector3(this.x - x, this.y - y, this.z - z);
  69398. };
  69399. /**
  69400. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69401. * @param x defines the x coordinate of the operand
  69402. * @param y defines the y coordinate of the operand
  69403. * @param z defines the z coordinate of the operand
  69404. * @param result defines the Vector3 object where to store the result
  69405. * @returns the current Vector3
  69406. */
  69407. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  69408. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  69409. };
  69410. /**
  69411. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69412. * @returns a new Vector3
  69413. */
  69414. Vector3.prototype.negate = function () {
  69415. return new Vector3(-this.x, -this.y, -this.z);
  69416. };
  69417. /**
  69418. * Multiplies the Vector3 coordinates by the float "scale"
  69419. * @param scale defines the multiplier factor
  69420. * @returns the current updated Vector3
  69421. */
  69422. Vector3.prototype.scaleInPlace = function (scale) {
  69423. this.x *= scale;
  69424. this.y *= scale;
  69425. this.z *= scale;
  69426. return this;
  69427. };
  69428. /**
  69429. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69430. * @param scale defines the multiplier factor
  69431. * @returns a new Vector3
  69432. */
  69433. Vector3.prototype.scale = function (scale) {
  69434. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  69435. };
  69436. /**
  69437. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69438. * @param scale defines the multiplier factor
  69439. * @param result defines the Vector3 object where to store the result
  69440. * @returns the current Vector3
  69441. */
  69442. Vector3.prototype.scaleToRef = function (scale, result) {
  69443. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69444. };
  69445. /**
  69446. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69447. * @param scale defines the scale factor
  69448. * @param result defines the Vector3 object where to store the result
  69449. * @returns the unmodified current Vector3
  69450. */
  69451. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  69452. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69453. };
  69454. /**
  69455. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69456. * @param otherVector defines the second operand
  69457. * @returns true if both vectors are equals
  69458. */
  69459. Vector3.prototype.equals = function (otherVector) {
  69460. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  69461. };
  69462. /**
  69463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69464. * @param otherVector defines the second operand
  69465. * @param epsilon defines the minimal distance to define values as equals
  69466. * @returns true if both vectors are distant less than epsilon
  69467. */
  69468. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69469. if (epsilon === void 0) { epsilon = Epsilon; }
  69470. 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);
  69471. };
  69472. /**
  69473. * Returns true if the current Vector3 coordinates equals the given floats
  69474. * @param x defines the x coordinate of the operand
  69475. * @param y defines the y coordinate of the operand
  69476. * @param z defines the z coordinate of the operand
  69477. * @returns true if both vectors are equals
  69478. */
  69479. Vector3.prototype.equalsToFloats = function (x, y, z) {
  69480. return this.x === x && this.y === y && this.z === z;
  69481. };
  69482. /**
  69483. * Multiplies the current Vector3 coordinates by the given ones
  69484. * @param otherVector defines the second operand
  69485. * @returns the current updated Vector3
  69486. */
  69487. Vector3.prototype.multiplyInPlace = function (otherVector) {
  69488. this.x *= otherVector.x;
  69489. this.y *= otherVector.y;
  69490. this.z *= otherVector.z;
  69491. return this;
  69492. };
  69493. /**
  69494. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69495. * @param otherVector defines the second operand
  69496. * @returns the new Vector3
  69497. */
  69498. Vector3.prototype.multiply = function (otherVector) {
  69499. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  69500. };
  69501. /**
  69502. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69503. * @param otherVector defines the second operand
  69504. * @param result defines the Vector3 object where to store the result
  69505. * @returns the current Vector3
  69506. */
  69507. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  69508. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  69509. };
  69510. /**
  69511. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69512. * @param x defines the x coordinate of the operand
  69513. * @param y defines the y coordinate of the operand
  69514. * @param z defines the z coordinate of the operand
  69515. * @returns the new Vector3
  69516. */
  69517. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  69518. return new Vector3(this.x * x, this.y * y, this.z * z);
  69519. };
  69520. /**
  69521. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69522. * @param otherVector defines the second operand
  69523. * @returns the new Vector3
  69524. */
  69525. Vector3.prototype.divide = function (otherVector) {
  69526. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69527. };
  69528. /**
  69529. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69530. * @param otherVector defines the second operand
  69531. * @param result defines the Vector3 object where to store the result
  69532. * @returns the current Vector3
  69533. */
  69534. Vector3.prototype.divideToRef = function (otherVector, result) {
  69535. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69536. };
  69537. /**
  69538. * Divides the current Vector3 coordinates by the given ones.
  69539. * @param otherVector defines the second operand
  69540. * @returns the current updated Vector3
  69541. */
  69542. Vector3.prototype.divideInPlace = function (otherVector) {
  69543. return this.divideToRef(otherVector, this);
  69544. };
  69545. /**
  69546. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69547. * @param other defines the second operand
  69548. * @returns the current updated Vector3
  69549. */
  69550. Vector3.prototype.minimizeInPlace = function (other) {
  69551. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  69552. };
  69553. /**
  69554. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69555. * @param other defines the second operand
  69556. * @returns the current updated Vector3
  69557. */
  69558. Vector3.prototype.maximizeInPlace = function (other) {
  69559. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  69560. };
  69561. /**
  69562. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69563. * @param x defines the x coordinate of the operand
  69564. * @param y defines the y coordinate of the operand
  69565. * @param z defines the z coordinate of the operand
  69566. * @returns the current updated Vector3
  69567. */
  69568. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  69569. if (x < this.x) {
  69570. this.x = x;
  69571. }
  69572. if (y < this.y) {
  69573. this.y = y;
  69574. }
  69575. if (z < this.z) {
  69576. this.z = z;
  69577. }
  69578. return this;
  69579. };
  69580. /**
  69581. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69582. * @param x defines the x coordinate of the operand
  69583. * @param y defines the y coordinate of the operand
  69584. * @param z defines the z coordinate of the operand
  69585. * @returns the current updated Vector3
  69586. */
  69587. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  69588. if (x > this.x) {
  69589. this.x = x;
  69590. }
  69591. if (y > this.y) {
  69592. this.y = y;
  69593. }
  69594. if (z > this.z) {
  69595. this.z = z;
  69596. }
  69597. return this;
  69598. };
  69599. /**
  69600. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69601. * Check if is non uniform within a certain amount of decimal places to account for this
  69602. * @param epsilon the amount the values can differ
  69603. * @returns if the the vector is non uniform to a certain number of decimal places
  69604. */
  69605. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  69606. var absX = Math.abs(this.x);
  69607. var absY = Math.abs(this.y);
  69608. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  69609. return true;
  69610. }
  69611. var absZ = Math.abs(this.z);
  69612. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  69613. return true;
  69614. }
  69615. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  69616. return true;
  69617. }
  69618. return false;
  69619. };
  69620. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  69621. /**
  69622. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69623. */
  69624. get: function () {
  69625. var absX = Math.abs(this.x);
  69626. var absY = Math.abs(this.y);
  69627. if (absX !== absY) {
  69628. return true;
  69629. }
  69630. var absZ = Math.abs(this.z);
  69631. if (absX !== absZ) {
  69632. return true;
  69633. }
  69634. if (absY !== absZ) {
  69635. return true;
  69636. }
  69637. return false;
  69638. },
  69639. enumerable: true,
  69640. configurable: true
  69641. });
  69642. /**
  69643. * Gets a new Vector3 from current Vector3 floored values
  69644. * @returns a new Vector3
  69645. */
  69646. Vector3.prototype.floor = function () {
  69647. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  69648. };
  69649. /**
  69650. * Gets a new Vector3 from current Vector3 floored values
  69651. * @returns a new Vector3
  69652. */
  69653. Vector3.prototype.fract = function () {
  69654. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  69655. };
  69656. // Properties
  69657. /**
  69658. * Gets the length of the Vector3
  69659. * @returns the length of the Vecto3
  69660. */
  69661. Vector3.prototype.length = function () {
  69662. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  69663. };
  69664. /**
  69665. * Gets the squared length of the Vector3
  69666. * @returns squared length of the Vector3
  69667. */
  69668. Vector3.prototype.lengthSquared = function () {
  69669. return (this.x * this.x + this.y * this.y + this.z * this.z);
  69670. };
  69671. /**
  69672. * Normalize the current Vector3.
  69673. * Please note that this is an in place operation.
  69674. * @returns the current updated Vector3
  69675. */
  69676. Vector3.prototype.normalize = function () {
  69677. return this.normalizeFromLength(this.length());
  69678. };
  69679. /**
  69680. * Reorders the x y z properties of the vector in place
  69681. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69682. * @returns the current updated vector
  69683. */
  69684. Vector3.prototype.reorderInPlace = function (order) {
  69685. var _this = this;
  69686. order = order.toLowerCase();
  69687. if (order === "xyz") {
  69688. return this;
  69689. }
  69690. MathTmp.Vector3[0].copyFrom(this);
  69691. ["x", "y", "z"].forEach(function (val, i) {
  69692. _this[val] = MathTmp.Vector3[0][order[i]];
  69693. });
  69694. return this;
  69695. };
  69696. /**
  69697. * Rotates the vector around 0,0,0 by a quaternion
  69698. * @param quaternion the rotation quaternion
  69699. * @param result vector to store the result
  69700. * @returns the resulting vector
  69701. */
  69702. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  69703. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  69704. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  69705. return result;
  69706. };
  69707. /**
  69708. * Rotates a vector around a given point
  69709. * @param quaternion the rotation quaternion
  69710. * @param point the point to rotate around
  69711. * @param result vector to store the result
  69712. * @returns the resulting vector
  69713. */
  69714. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  69715. this.subtractToRef(point, MathTmp.Vector3[0]);
  69716. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  69717. point.addToRef(MathTmp.Vector3[0], result);
  69718. return result;
  69719. };
  69720. /**
  69721. * Normalize the current Vector3 with the given input length.
  69722. * Please note that this is an in place operation.
  69723. * @param len the length of the vector
  69724. * @returns the current updated Vector3
  69725. */
  69726. Vector3.prototype.normalizeFromLength = function (len) {
  69727. if (len === 0 || len === 1.0) {
  69728. return this;
  69729. }
  69730. return this.scaleInPlace(1.0 / len);
  69731. };
  69732. /**
  69733. * Normalize the current Vector3 to a new vector
  69734. * @returns the new Vector3
  69735. */
  69736. Vector3.prototype.normalizeToNew = function () {
  69737. var normalized = new Vector3(0, 0, 0);
  69738. this.normalizeToRef(normalized);
  69739. return normalized;
  69740. };
  69741. /**
  69742. * Normalize the current Vector3 to the reference
  69743. * @param reference define the Vector3 to update
  69744. * @returns the updated Vector3
  69745. */
  69746. Vector3.prototype.normalizeToRef = function (reference) {
  69747. var len = this.length();
  69748. if (len === 0 || len === 1.0) {
  69749. return reference.copyFromFloats(this.x, this.y, this.z);
  69750. }
  69751. return this.scaleToRef(1.0 / len, reference);
  69752. };
  69753. /**
  69754. * Creates a new Vector3 copied from the current Vector3
  69755. * @returns the new Vector3
  69756. */
  69757. Vector3.prototype.clone = function () {
  69758. return new Vector3(this.x, this.y, this.z);
  69759. };
  69760. /**
  69761. * Copies the given vector coordinates to the current Vector3 ones
  69762. * @param source defines the source Vector3
  69763. * @returns the current updated Vector3
  69764. */
  69765. Vector3.prototype.copyFrom = function (source) {
  69766. return this.copyFromFloats(source.x, source.y, source.z);
  69767. };
  69768. /**
  69769. * Copies the given floats to the current Vector3 coordinates
  69770. * @param x defines the x coordinate of the operand
  69771. * @param y defines the y coordinate of the operand
  69772. * @param z defines the z coordinate of the operand
  69773. * @returns the current updated Vector3
  69774. */
  69775. Vector3.prototype.copyFromFloats = function (x, y, z) {
  69776. this.x = x;
  69777. this.y = y;
  69778. this.z = z;
  69779. return this;
  69780. };
  69781. /**
  69782. * Copies the given floats to the current Vector3 coordinates
  69783. * @param x defines the x coordinate of the operand
  69784. * @param y defines the y coordinate of the operand
  69785. * @param z defines the z coordinate of the operand
  69786. * @returns the current updated Vector3
  69787. */
  69788. Vector3.prototype.set = function (x, y, z) {
  69789. return this.copyFromFloats(x, y, z);
  69790. };
  69791. /**
  69792. * Copies the given float to the current Vector3 coordinates
  69793. * @param v defines the x, y and z coordinates of the operand
  69794. * @returns the current updated Vector3
  69795. */
  69796. Vector3.prototype.setAll = function (v) {
  69797. this.x = this.y = this.z = v;
  69798. return this;
  69799. };
  69800. // Statics
  69801. /**
  69802. * Get the clip factor between two vectors
  69803. * @param vector0 defines the first operand
  69804. * @param vector1 defines the second operand
  69805. * @param axis defines the axis to use
  69806. * @param size defines the size along the axis
  69807. * @returns the clip factor
  69808. */
  69809. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  69810. var d0 = Vector3.Dot(vector0, axis) - size;
  69811. var d1 = Vector3.Dot(vector1, axis) - size;
  69812. var s = d0 / (d0 - d1);
  69813. return s;
  69814. };
  69815. /**
  69816. * Get angle between two vectors
  69817. * @param vector0 angle between vector0 and vector1
  69818. * @param vector1 angle between vector0 and vector1
  69819. * @param normal direction of the normal
  69820. * @return the angle between vector0 and vector1
  69821. */
  69822. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  69823. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  69824. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  69825. var dot = Vector3.Dot(v0, v1);
  69826. var n = MathTmp.Vector3[3];
  69827. Vector3.CrossToRef(v0, v1, n);
  69828. if (Vector3.Dot(n, normal) > 0) {
  69829. return Math.acos(dot);
  69830. }
  69831. return -Math.acos(dot);
  69832. };
  69833. /**
  69834. * Returns a new Vector3 set from the index "offset" of the given array
  69835. * @param array defines the source array
  69836. * @param offset defines the offset in the source array
  69837. * @returns the new Vector3
  69838. */
  69839. Vector3.FromArray = function (array, offset) {
  69840. if (offset === void 0) { offset = 0; }
  69841. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  69842. };
  69843. /**
  69844. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69845. * This function is deprecated. Use FromArray instead
  69846. * @param array defines the source array
  69847. * @param offset defines the offset in the source array
  69848. * @returns the new Vector3
  69849. */
  69850. Vector3.FromFloatArray = function (array, offset) {
  69851. return Vector3.FromArray(array, offset);
  69852. };
  69853. /**
  69854. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69855. * @param array defines the source array
  69856. * @param offset defines the offset in the source array
  69857. * @param result defines the Vector3 where to store the result
  69858. */
  69859. Vector3.FromArrayToRef = function (array, offset, result) {
  69860. result.x = array[offset];
  69861. result.y = array[offset + 1];
  69862. result.z = array[offset + 2];
  69863. };
  69864. /**
  69865. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69866. * This function is deprecated. Use FromArrayToRef instead.
  69867. * @param array defines the source array
  69868. * @param offset defines the offset in the source array
  69869. * @param result defines the Vector3 where to store the result
  69870. */
  69871. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  69872. return Vector3.FromArrayToRef(array, offset, result);
  69873. };
  69874. /**
  69875. * Sets the given vector "result" with the given floats.
  69876. * @param x defines the x coordinate of the source
  69877. * @param y defines the y coordinate of the source
  69878. * @param z defines the z coordinate of the source
  69879. * @param result defines the Vector3 where to store the result
  69880. */
  69881. Vector3.FromFloatsToRef = function (x, y, z, result) {
  69882. result.copyFromFloats(x, y, z);
  69883. };
  69884. /**
  69885. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69886. * @returns a new empty Vector3
  69887. */
  69888. Vector3.Zero = function () {
  69889. return new Vector3(0.0, 0.0, 0.0);
  69890. };
  69891. /**
  69892. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69893. * @returns a new unit Vector3
  69894. */
  69895. Vector3.One = function () {
  69896. return new Vector3(1.0, 1.0, 1.0);
  69897. };
  69898. /**
  69899. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69900. * @returns a new up Vector3
  69901. */
  69902. Vector3.Up = function () {
  69903. return new Vector3(0.0, 1.0, 0.0);
  69904. };
  69905. Object.defineProperty(Vector3, "UpReadOnly", {
  69906. /**
  69907. * Gets a up Vector3 that must not be updated
  69908. */
  69909. get: function () {
  69910. return Vector3._UpReadOnly;
  69911. },
  69912. enumerable: true,
  69913. configurable: true
  69914. });
  69915. /**
  69916. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69917. * @returns a new down Vector3
  69918. */
  69919. Vector3.Down = function () {
  69920. return new Vector3(0.0, -1.0, 0.0);
  69921. };
  69922. /**
  69923. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69924. * @returns a new forward Vector3
  69925. */
  69926. Vector3.Forward = function () {
  69927. return new Vector3(0.0, 0.0, 1.0);
  69928. };
  69929. /**
  69930. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69931. * @returns a new forward Vector3
  69932. */
  69933. Vector3.Backward = function () {
  69934. return new Vector3(0.0, 0.0, -1.0);
  69935. };
  69936. /**
  69937. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69938. * @returns a new right Vector3
  69939. */
  69940. Vector3.Right = function () {
  69941. return new Vector3(1.0, 0.0, 0.0);
  69942. };
  69943. /**
  69944. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69945. * @returns a new left Vector3
  69946. */
  69947. Vector3.Left = function () {
  69948. return new Vector3(-1.0, 0.0, 0.0);
  69949. };
  69950. /**
  69951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69953. * @param vector defines the Vector3 to transform
  69954. * @param transformation defines the transformation matrix
  69955. * @returns the transformed Vector3
  69956. */
  69957. Vector3.TransformCoordinates = function (vector, transformation) {
  69958. var result = Vector3.Zero();
  69959. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  69960. return result;
  69961. };
  69962. /**
  69963. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69964. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69965. * @param vector defines the Vector3 to transform
  69966. * @param transformation defines the transformation matrix
  69967. * @param result defines the Vector3 where to store the result
  69968. */
  69969. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  69970. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69971. };
  69972. /**
  69973. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69974. * This method computes tranformed coordinates only, not transformed direction vectors
  69975. * @param x define the x coordinate of the source vector
  69976. * @param y define the y coordinate of the source vector
  69977. * @param z define the z coordinate of the source vector
  69978. * @param transformation defines the transformation matrix
  69979. * @param result defines the Vector3 where to store the result
  69980. */
  69981. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  69982. var m = transformation.m;
  69983. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  69984. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  69985. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  69986. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  69987. result.x = rx * rw;
  69988. result.y = ry * rw;
  69989. result.z = rz * rw;
  69990. };
  69991. /**
  69992. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69993. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69994. * @param vector defines the Vector3 to transform
  69995. * @param transformation defines the transformation matrix
  69996. * @returns the new Vector3
  69997. */
  69998. Vector3.TransformNormal = function (vector, transformation) {
  69999. var result = Vector3.Zero();
  70000. Vector3.TransformNormalToRef(vector, transformation, result);
  70001. return result;
  70002. };
  70003. /**
  70004. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70005. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70006. * @param vector defines the Vector3 to transform
  70007. * @param transformation defines the transformation matrix
  70008. * @param result defines the Vector3 where to store the result
  70009. */
  70010. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  70011. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  70012. };
  70013. /**
  70014. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70015. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70016. * @param x define the x coordinate of the source vector
  70017. * @param y define the y coordinate of the source vector
  70018. * @param z define the z coordinate of the source vector
  70019. * @param transformation defines the transformation matrix
  70020. * @param result defines the Vector3 where to store the result
  70021. */
  70022. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  70023. var m = transformation.m;
  70024. result.x = x * m[0] + y * m[4] + z * m[8];
  70025. result.y = x * m[1] + y * m[5] + z * m[9];
  70026. result.z = x * m[2] + y * m[6] + z * m[10];
  70027. };
  70028. /**
  70029. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70030. * @param value1 defines the first control point
  70031. * @param value2 defines the second control point
  70032. * @param value3 defines the third control point
  70033. * @param value4 defines the fourth control point
  70034. * @param amount defines the amount on the spline to use
  70035. * @returns the new Vector3
  70036. */
  70037. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  70038. var squared = amount * amount;
  70039. var cubed = amount * squared;
  70040. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  70041. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  70042. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  70043. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  70044. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  70045. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  70046. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  70047. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  70048. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  70049. return new Vector3(x, y, z);
  70050. };
  70051. /**
  70052. * 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"
  70053. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70054. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70055. * @param value defines the current value
  70056. * @param min defines the lower range value
  70057. * @param max defines the upper range value
  70058. * @returns the new Vector3
  70059. */
  70060. Vector3.Clamp = function (value, min, max) {
  70061. var v = new Vector3();
  70062. Vector3.ClampToRef(value, min, max, v);
  70063. return v;
  70064. };
  70065. /**
  70066. * 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"
  70067. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70068. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70069. * @param value defines the current value
  70070. * @param min defines the lower range value
  70071. * @param max defines the upper range value
  70072. * @param result defines the Vector3 where to store the result
  70073. */
  70074. Vector3.ClampToRef = function (value, min, max, result) {
  70075. var x = value.x;
  70076. x = (x > max.x) ? max.x : x;
  70077. x = (x < min.x) ? min.x : x;
  70078. var y = value.y;
  70079. y = (y > max.y) ? max.y : y;
  70080. y = (y < min.y) ? min.y : y;
  70081. var z = value.z;
  70082. z = (z > max.z) ? max.z : z;
  70083. z = (z < min.z) ? min.z : z;
  70084. result.copyFromFloats(x, y, z);
  70085. };
  70086. /**
  70087. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70088. * @param value1 defines the first control point
  70089. * @param tangent1 defines the first tangent vector
  70090. * @param value2 defines the second control point
  70091. * @param tangent2 defines the second tangent vector
  70092. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70093. * @returns the new Vector3
  70094. */
  70095. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70096. var squared = amount * amount;
  70097. var cubed = amount * squared;
  70098. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70099. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70100. var part3 = (cubed - (2.0 * squared)) + amount;
  70101. var part4 = cubed - squared;
  70102. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  70103. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  70104. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  70105. return new Vector3(x, y, z);
  70106. };
  70107. /**
  70108. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70109. * @param start defines the start value
  70110. * @param end defines the end value
  70111. * @param amount max defines amount between both (between 0 and 1)
  70112. * @returns the new Vector3
  70113. */
  70114. Vector3.Lerp = function (start, end, amount) {
  70115. var result = new Vector3(0, 0, 0);
  70116. Vector3.LerpToRef(start, end, amount, result);
  70117. return result;
  70118. };
  70119. /**
  70120. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70121. * @param start defines the start value
  70122. * @param end defines the end value
  70123. * @param amount max defines amount between both (between 0 and 1)
  70124. * @param result defines the Vector3 where to store the result
  70125. */
  70126. Vector3.LerpToRef = function (start, end, amount, result) {
  70127. result.x = start.x + ((end.x - start.x) * amount);
  70128. result.y = start.y + ((end.y - start.y) * amount);
  70129. result.z = start.z + ((end.z - start.z) * amount);
  70130. };
  70131. /**
  70132. * Returns the dot product (float) between the vectors "left" and "right"
  70133. * @param left defines the left operand
  70134. * @param right defines the right operand
  70135. * @returns the dot product
  70136. */
  70137. Vector3.Dot = function (left, right) {
  70138. return (left.x * right.x + left.y * right.y + left.z * right.z);
  70139. };
  70140. /**
  70141. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70142. * The cross product is then orthogonal to both "left" and "right"
  70143. * @param left defines the left operand
  70144. * @param right defines the right operand
  70145. * @returns the cross product
  70146. */
  70147. Vector3.Cross = function (left, right) {
  70148. var result = Vector3.Zero();
  70149. Vector3.CrossToRef(left, right, result);
  70150. return result;
  70151. };
  70152. /**
  70153. * Sets the given vector "result" with the cross product of "left" and "right"
  70154. * The cross product is then orthogonal to both "left" and "right"
  70155. * @param left defines the left operand
  70156. * @param right defines the right operand
  70157. * @param result defines the Vector3 where to store the result
  70158. */
  70159. Vector3.CrossToRef = function (left, right, result) {
  70160. var x = left.y * right.z - left.z * right.y;
  70161. var y = left.z * right.x - left.x * right.z;
  70162. var z = left.x * right.y - left.y * right.x;
  70163. result.copyFromFloats(x, y, z);
  70164. };
  70165. /**
  70166. * Returns a new Vector3 as the normalization of the given vector
  70167. * @param vector defines the Vector3 to normalize
  70168. * @returns the new Vector3
  70169. */
  70170. Vector3.Normalize = function (vector) {
  70171. var result = Vector3.Zero();
  70172. Vector3.NormalizeToRef(vector, result);
  70173. return result;
  70174. };
  70175. /**
  70176. * Sets the given vector "result" with the normalization of the given first vector
  70177. * @param vector defines the Vector3 to normalize
  70178. * @param result defines the Vector3 where to store the result
  70179. */
  70180. Vector3.NormalizeToRef = function (vector, result) {
  70181. vector.normalizeToRef(result);
  70182. };
  70183. /**
  70184. * Project a Vector3 onto screen space
  70185. * @param vector defines the Vector3 to project
  70186. * @param world defines the world matrix to use
  70187. * @param transform defines the transform (view x projection) matrix to use
  70188. * @param viewport defines the screen viewport to use
  70189. * @returns the new Vector3
  70190. */
  70191. Vector3.Project = function (vector, world, transform, viewport) {
  70192. var cw = viewport.width;
  70193. var ch = viewport.height;
  70194. var cx = viewport.x;
  70195. var cy = viewport.y;
  70196. var viewportMatrix = MathTmp.Matrix[1];
  70197. 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);
  70198. var matrix = MathTmp.Matrix[0];
  70199. world.multiplyToRef(transform, matrix);
  70200. matrix.multiplyToRef(viewportMatrix, matrix);
  70201. return Vector3.TransformCoordinates(vector, matrix);
  70202. };
  70203. /** @hidden */
  70204. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  70205. Vector3.TransformCoordinatesToRef(source, matrix, result);
  70206. var m = matrix.m;
  70207. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  70208. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  70209. result.scaleInPlace(1.0 / num);
  70210. }
  70211. };
  70212. /**
  70213. * Unproject from screen space to object space
  70214. * @param source defines the screen space Vector3 to use
  70215. * @param viewportWidth defines the current width of the viewport
  70216. * @param viewportHeight defines the current height of the viewport
  70217. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70218. * @param transform defines the transform (view x projection) matrix to use
  70219. * @returns the new Vector3
  70220. */
  70221. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  70222. var matrix = MathTmp.Matrix[0];
  70223. world.multiplyToRef(transform, matrix);
  70224. matrix.invert();
  70225. source.x = source.x / viewportWidth * 2 - 1;
  70226. source.y = -(source.y / viewportHeight * 2 - 1);
  70227. var vector = new Vector3();
  70228. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  70229. return vector;
  70230. };
  70231. /**
  70232. * Unproject from screen space to object space
  70233. * @param source defines the screen space Vector3 to use
  70234. * @param viewportWidth defines the current width of the viewport
  70235. * @param viewportHeight defines the current height of the viewport
  70236. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70237. * @param view defines the view matrix to use
  70238. * @param projection defines the projection matrix to use
  70239. * @returns the new Vector3
  70240. */
  70241. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  70242. var result = Vector3.Zero();
  70243. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  70244. return result;
  70245. };
  70246. /**
  70247. * Unproject from screen space to object space
  70248. * @param source defines the screen space Vector3 to use
  70249. * @param viewportWidth defines the current width of the viewport
  70250. * @param viewportHeight defines the current height of the viewport
  70251. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70252. * @param view defines the view matrix to use
  70253. * @param projection defines the projection matrix to use
  70254. * @param result defines the Vector3 where to store the result
  70255. */
  70256. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  70257. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  70258. };
  70259. /**
  70260. * Unproject from screen space to object space
  70261. * @param sourceX defines the screen space x coordinate to use
  70262. * @param sourceY defines the screen space y coordinate to use
  70263. * @param sourceZ defines the screen space z coordinate to use
  70264. * @param viewportWidth defines the current width of the viewport
  70265. * @param viewportHeight defines the current height of the viewport
  70266. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70267. * @param view defines the view matrix to use
  70268. * @param projection defines the projection matrix to use
  70269. * @param result defines the Vector3 where to store the result
  70270. */
  70271. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  70272. var matrix = MathTmp.Matrix[0];
  70273. world.multiplyToRef(view, matrix);
  70274. matrix.multiplyToRef(projection, matrix);
  70275. matrix.invert();
  70276. var screenSource = MathTmp.Vector3[0];
  70277. screenSource.x = sourceX / viewportWidth * 2 - 1;
  70278. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  70279. screenSource.z = 2 * sourceZ - 1.0;
  70280. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  70281. };
  70282. /**
  70283. * Gets the minimal coordinate values between two Vector3
  70284. * @param left defines the first operand
  70285. * @param right defines the second operand
  70286. * @returns the new Vector3
  70287. */
  70288. Vector3.Minimize = function (left, right) {
  70289. var min = left.clone();
  70290. min.minimizeInPlace(right);
  70291. return min;
  70292. };
  70293. /**
  70294. * Gets the maximal coordinate values between two Vector3
  70295. * @param left defines the first operand
  70296. * @param right defines the second operand
  70297. * @returns the new Vector3
  70298. */
  70299. Vector3.Maximize = function (left, right) {
  70300. var max = left.clone();
  70301. max.maximizeInPlace(right);
  70302. return max;
  70303. };
  70304. /**
  70305. * Returns the distance between the vectors "value1" and "value2"
  70306. * @param value1 defines the first operand
  70307. * @param value2 defines the second operand
  70308. * @returns the distance
  70309. */
  70310. Vector3.Distance = function (value1, value2) {
  70311. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  70312. };
  70313. /**
  70314. * Returns the squared distance between the vectors "value1" and "value2"
  70315. * @param value1 defines the first operand
  70316. * @param value2 defines the second operand
  70317. * @returns the squared distance
  70318. */
  70319. Vector3.DistanceSquared = function (value1, value2) {
  70320. var x = value1.x - value2.x;
  70321. var y = value1.y - value2.y;
  70322. var z = value1.z - value2.z;
  70323. return (x * x) + (y * y) + (z * z);
  70324. };
  70325. /**
  70326. * Returns a new Vector3 located at the center between "value1" and "value2"
  70327. * @param value1 defines the first operand
  70328. * @param value2 defines the second operand
  70329. * @returns the new Vector3
  70330. */
  70331. Vector3.Center = function (value1, value2) {
  70332. var center = value1.add(value2);
  70333. center.scaleInPlace(0.5);
  70334. return center;
  70335. };
  70336. /**
  70337. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70338. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70339. * to something in order to rotate it from its local system to the given target system
  70340. * Note: axis1, axis2 and axis3 are normalized during this operation
  70341. * @param axis1 defines the first axis
  70342. * @param axis2 defines the second axis
  70343. * @param axis3 defines the third axis
  70344. * @returns a new Vector3
  70345. */
  70346. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  70347. var rotation = Vector3.Zero();
  70348. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  70349. return rotation;
  70350. };
  70351. /**
  70352. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70353. * @param axis1 defines the first axis
  70354. * @param axis2 defines the second axis
  70355. * @param axis3 defines the third axis
  70356. * @param ref defines the Vector3 where to store the result
  70357. */
  70358. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  70359. var quat = MathTmp.Quaternion[0];
  70360. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  70361. quat.toEulerAnglesToRef(ref);
  70362. };
  70363. Vector3._UpReadOnly = Vector3.Up();
  70364. return Vector3;
  70365. }());
  70366. /**
  70367. * Vector4 class created for EulerAngle class conversion to Quaternion
  70368. */
  70369. var Vector4 = /** @class */ (function () {
  70370. /**
  70371. * Creates a Vector4 object from the given floats.
  70372. * @param x x value of the vector
  70373. * @param y y value of the vector
  70374. * @param z z value of the vector
  70375. * @param w w value of the vector
  70376. */
  70377. function Vector4(
  70378. /** x value of the vector */
  70379. x,
  70380. /** y value of the vector */
  70381. y,
  70382. /** z value of the vector */
  70383. z,
  70384. /** w value of the vector */
  70385. w) {
  70386. this.x = x;
  70387. this.y = y;
  70388. this.z = z;
  70389. this.w = w;
  70390. }
  70391. /**
  70392. * Returns the string with the Vector4 coordinates.
  70393. * @returns a string containing all the vector values
  70394. */
  70395. Vector4.prototype.toString = function () {
  70396. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70397. };
  70398. /**
  70399. * Returns the string "Vector4".
  70400. * @returns "Vector4"
  70401. */
  70402. Vector4.prototype.getClassName = function () {
  70403. return "Vector4";
  70404. };
  70405. /**
  70406. * Returns the Vector4 hash code.
  70407. * @returns a unique hash code
  70408. */
  70409. Vector4.prototype.getHashCode = function () {
  70410. var hash = this.x || 0;
  70411. hash = (hash * 397) ^ (this.y || 0);
  70412. hash = (hash * 397) ^ (this.z || 0);
  70413. hash = (hash * 397) ^ (this.w || 0);
  70414. return hash;
  70415. };
  70416. // Operators
  70417. /**
  70418. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70419. * @returns the resulting array
  70420. */
  70421. Vector4.prototype.asArray = function () {
  70422. var result = new Array();
  70423. this.toArray(result, 0);
  70424. return result;
  70425. };
  70426. /**
  70427. * Populates the given array from the given index with the Vector4 coordinates.
  70428. * @param array array to populate
  70429. * @param index index of the array to start at (default: 0)
  70430. * @returns the Vector4.
  70431. */
  70432. Vector4.prototype.toArray = function (array, index) {
  70433. if (index === undefined) {
  70434. index = 0;
  70435. }
  70436. array[index] = this.x;
  70437. array[index + 1] = this.y;
  70438. array[index + 2] = this.z;
  70439. array[index + 3] = this.w;
  70440. return this;
  70441. };
  70442. /**
  70443. * Adds the given vector to the current Vector4.
  70444. * @param otherVector the vector to add
  70445. * @returns the updated Vector4.
  70446. */
  70447. Vector4.prototype.addInPlace = function (otherVector) {
  70448. this.x += otherVector.x;
  70449. this.y += otherVector.y;
  70450. this.z += otherVector.z;
  70451. this.w += otherVector.w;
  70452. return this;
  70453. };
  70454. /**
  70455. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70456. * @param otherVector the vector to add
  70457. * @returns the resulting vector
  70458. */
  70459. Vector4.prototype.add = function (otherVector) {
  70460. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  70461. };
  70462. /**
  70463. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70464. * @param otherVector the vector to add
  70465. * @param result the vector to store the result
  70466. * @returns the current Vector4.
  70467. */
  70468. Vector4.prototype.addToRef = function (otherVector, result) {
  70469. result.x = this.x + otherVector.x;
  70470. result.y = this.y + otherVector.y;
  70471. result.z = this.z + otherVector.z;
  70472. result.w = this.w + otherVector.w;
  70473. return this;
  70474. };
  70475. /**
  70476. * Subtract in place the given vector from the current Vector4.
  70477. * @param otherVector the vector to subtract
  70478. * @returns the updated Vector4.
  70479. */
  70480. Vector4.prototype.subtractInPlace = function (otherVector) {
  70481. this.x -= otherVector.x;
  70482. this.y -= otherVector.y;
  70483. this.z -= otherVector.z;
  70484. this.w -= otherVector.w;
  70485. return this;
  70486. };
  70487. /**
  70488. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70489. * @param otherVector the vector to add
  70490. * @returns the new vector with the result
  70491. */
  70492. Vector4.prototype.subtract = function (otherVector) {
  70493. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  70494. };
  70495. /**
  70496. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70497. * @param otherVector the vector to subtract
  70498. * @param result the vector to store the result
  70499. * @returns the current Vector4.
  70500. */
  70501. Vector4.prototype.subtractToRef = function (otherVector, result) {
  70502. result.x = this.x - otherVector.x;
  70503. result.y = this.y - otherVector.y;
  70504. result.z = this.z - otherVector.z;
  70505. result.w = this.w - otherVector.w;
  70506. return this;
  70507. };
  70508. /**
  70509. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70510. */
  70511. /**
  70512. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70513. * @param x value to subtract
  70514. * @param y value to subtract
  70515. * @param z value to subtract
  70516. * @param w value to subtract
  70517. * @returns new vector containing the result
  70518. */
  70519. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  70520. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  70521. };
  70522. /**
  70523. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70524. * @param x value to subtract
  70525. * @param y value to subtract
  70526. * @param z value to subtract
  70527. * @param w value to subtract
  70528. * @param result the vector to store the result in
  70529. * @returns the current Vector4.
  70530. */
  70531. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  70532. result.x = this.x - x;
  70533. result.y = this.y - y;
  70534. result.z = this.z - z;
  70535. result.w = this.w - w;
  70536. return this;
  70537. };
  70538. /**
  70539. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70540. * @returns a new vector with the negated values
  70541. */
  70542. Vector4.prototype.negate = function () {
  70543. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  70544. };
  70545. /**
  70546. * Multiplies the current Vector4 coordinates by scale (float).
  70547. * @param scale the number to scale with
  70548. * @returns the updated Vector4.
  70549. */
  70550. Vector4.prototype.scaleInPlace = function (scale) {
  70551. this.x *= scale;
  70552. this.y *= scale;
  70553. this.z *= scale;
  70554. this.w *= scale;
  70555. return this;
  70556. };
  70557. /**
  70558. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70559. * @param scale the number to scale with
  70560. * @returns a new vector with the result
  70561. */
  70562. Vector4.prototype.scale = function (scale) {
  70563. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  70564. };
  70565. /**
  70566. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70567. * @param scale the number to scale with
  70568. * @param result a vector to store the result in
  70569. * @returns the current Vector4.
  70570. */
  70571. Vector4.prototype.scaleToRef = function (scale, result) {
  70572. result.x = this.x * scale;
  70573. result.y = this.y * scale;
  70574. result.z = this.z * scale;
  70575. result.w = this.w * scale;
  70576. return this;
  70577. };
  70578. /**
  70579. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70580. * @param scale defines the scale factor
  70581. * @param result defines the Vector4 object where to store the result
  70582. * @returns the unmodified current Vector4
  70583. */
  70584. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  70585. result.x += this.x * scale;
  70586. result.y += this.y * scale;
  70587. result.z += this.z * scale;
  70588. result.w += this.w * scale;
  70589. return this;
  70590. };
  70591. /**
  70592. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70593. * @param otherVector the vector to compare against
  70594. * @returns true if they are equal
  70595. */
  70596. Vector4.prototype.equals = function (otherVector) {
  70597. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  70598. };
  70599. /**
  70600. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70601. * @param otherVector vector to compare against
  70602. * @param epsilon (Default: very small number)
  70603. * @returns true if they are equal
  70604. */
  70605. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  70606. if (epsilon === void 0) { epsilon = Epsilon; }
  70607. return otherVector
  70608. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  70609. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  70610. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  70611. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  70612. };
  70613. /**
  70614. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70615. * @param x x value to compare against
  70616. * @param y y value to compare against
  70617. * @param z z value to compare against
  70618. * @param w w value to compare against
  70619. * @returns true if equal
  70620. */
  70621. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  70622. return this.x === x && this.y === y && this.z === z && this.w === w;
  70623. };
  70624. /**
  70625. * Multiplies in place the current Vector4 by the given one.
  70626. * @param otherVector vector to multiple with
  70627. * @returns the updated Vector4.
  70628. */
  70629. Vector4.prototype.multiplyInPlace = function (otherVector) {
  70630. this.x *= otherVector.x;
  70631. this.y *= otherVector.y;
  70632. this.z *= otherVector.z;
  70633. this.w *= otherVector.w;
  70634. return this;
  70635. };
  70636. /**
  70637. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70638. * @param otherVector vector to multiple with
  70639. * @returns resulting new vector
  70640. */
  70641. Vector4.prototype.multiply = function (otherVector) {
  70642. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  70643. };
  70644. /**
  70645. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70646. * @param otherVector vector to multiple with
  70647. * @param result vector to store the result
  70648. * @returns the current Vector4.
  70649. */
  70650. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  70651. result.x = this.x * otherVector.x;
  70652. result.y = this.y * otherVector.y;
  70653. result.z = this.z * otherVector.z;
  70654. result.w = this.w * otherVector.w;
  70655. return this;
  70656. };
  70657. /**
  70658. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70659. * @param x x value multiply with
  70660. * @param y y value multiply with
  70661. * @param z z value multiply with
  70662. * @param w w value multiply with
  70663. * @returns resulting new vector
  70664. */
  70665. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  70666. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  70667. };
  70668. /**
  70669. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70670. * @param otherVector vector to devide with
  70671. * @returns resulting new vector
  70672. */
  70673. Vector4.prototype.divide = function (otherVector) {
  70674. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  70675. };
  70676. /**
  70677. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70678. * @param otherVector vector to devide with
  70679. * @param result vector to store the result
  70680. * @returns the current Vector4.
  70681. */
  70682. Vector4.prototype.divideToRef = function (otherVector, result) {
  70683. result.x = this.x / otherVector.x;
  70684. result.y = this.y / otherVector.y;
  70685. result.z = this.z / otherVector.z;
  70686. result.w = this.w / otherVector.w;
  70687. return this;
  70688. };
  70689. /**
  70690. * Divides the current Vector3 coordinates by the given ones.
  70691. * @param otherVector vector to devide with
  70692. * @returns the updated Vector3.
  70693. */
  70694. Vector4.prototype.divideInPlace = function (otherVector) {
  70695. return this.divideToRef(otherVector, this);
  70696. };
  70697. /**
  70698. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70699. * @param other defines the second operand
  70700. * @returns the current updated Vector4
  70701. */
  70702. Vector4.prototype.minimizeInPlace = function (other) {
  70703. if (other.x < this.x) {
  70704. this.x = other.x;
  70705. }
  70706. if (other.y < this.y) {
  70707. this.y = other.y;
  70708. }
  70709. if (other.z < this.z) {
  70710. this.z = other.z;
  70711. }
  70712. if (other.w < this.w) {
  70713. this.w = other.w;
  70714. }
  70715. return this;
  70716. };
  70717. /**
  70718. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70719. * @param other defines the second operand
  70720. * @returns the current updated Vector4
  70721. */
  70722. Vector4.prototype.maximizeInPlace = function (other) {
  70723. if (other.x > this.x) {
  70724. this.x = other.x;
  70725. }
  70726. if (other.y > this.y) {
  70727. this.y = other.y;
  70728. }
  70729. if (other.z > this.z) {
  70730. this.z = other.z;
  70731. }
  70732. if (other.w > this.w) {
  70733. this.w = other.w;
  70734. }
  70735. return this;
  70736. };
  70737. /**
  70738. * Gets a new Vector4 from current Vector4 floored values
  70739. * @returns a new Vector4
  70740. */
  70741. Vector4.prototype.floor = function () {
  70742. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  70743. };
  70744. /**
  70745. * Gets a new Vector4 from current Vector3 floored values
  70746. * @returns a new Vector4
  70747. */
  70748. Vector4.prototype.fract = function () {
  70749. 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));
  70750. };
  70751. // Properties
  70752. /**
  70753. * Returns the Vector4 length (float).
  70754. * @returns the length
  70755. */
  70756. Vector4.prototype.length = function () {
  70757. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70758. };
  70759. /**
  70760. * Returns the Vector4 squared length (float).
  70761. * @returns the length squared
  70762. */
  70763. Vector4.prototype.lengthSquared = function () {
  70764. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70765. };
  70766. // Methods
  70767. /**
  70768. * Normalizes in place the Vector4.
  70769. * @returns the updated Vector4.
  70770. */
  70771. Vector4.prototype.normalize = function () {
  70772. var len = this.length();
  70773. if (len === 0) {
  70774. return this;
  70775. }
  70776. return this.scaleInPlace(1.0 / len);
  70777. };
  70778. /**
  70779. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70780. * @returns this converted to a new vector3
  70781. */
  70782. Vector4.prototype.toVector3 = function () {
  70783. return new Vector3(this.x, this.y, this.z);
  70784. };
  70785. /**
  70786. * Returns a new Vector4 copied from the current one.
  70787. * @returns the new cloned vector
  70788. */
  70789. Vector4.prototype.clone = function () {
  70790. return new Vector4(this.x, this.y, this.z, this.w);
  70791. };
  70792. /**
  70793. * Updates the current Vector4 with the given one coordinates.
  70794. * @param source the source vector to copy from
  70795. * @returns the updated Vector4.
  70796. */
  70797. Vector4.prototype.copyFrom = function (source) {
  70798. this.x = source.x;
  70799. this.y = source.y;
  70800. this.z = source.z;
  70801. this.w = source.w;
  70802. return this;
  70803. };
  70804. /**
  70805. * Updates the current Vector4 coordinates with the given floats.
  70806. * @param x float to copy from
  70807. * @param y float to copy from
  70808. * @param z float to copy from
  70809. * @param w float to copy from
  70810. * @returns the updated Vector4.
  70811. */
  70812. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  70813. this.x = x;
  70814. this.y = y;
  70815. this.z = z;
  70816. this.w = w;
  70817. return this;
  70818. };
  70819. /**
  70820. * Updates the current Vector4 coordinates with the given floats.
  70821. * @param x float to set from
  70822. * @param y float to set from
  70823. * @param z float to set from
  70824. * @param w float to set from
  70825. * @returns the updated Vector4.
  70826. */
  70827. Vector4.prototype.set = function (x, y, z, w) {
  70828. return this.copyFromFloats(x, y, z, w);
  70829. };
  70830. /**
  70831. * Copies the given float to the current Vector3 coordinates
  70832. * @param v defines the x, y, z and w coordinates of the operand
  70833. * @returns the current updated Vector3
  70834. */
  70835. Vector4.prototype.setAll = function (v) {
  70836. this.x = this.y = this.z = this.w = v;
  70837. return this;
  70838. };
  70839. // Statics
  70840. /**
  70841. * Returns a new Vector4 set from the starting index of the given array.
  70842. * @param array the array to pull values from
  70843. * @param offset the offset into the array to start at
  70844. * @returns the new vector
  70845. */
  70846. Vector4.FromArray = function (array, offset) {
  70847. if (!offset) {
  70848. offset = 0;
  70849. }
  70850. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70851. };
  70852. /**
  70853. * Updates the given vector "result" from the starting index of the given array.
  70854. * @param array the array to pull values from
  70855. * @param offset the offset into the array to start at
  70856. * @param result the vector to store the result in
  70857. */
  70858. Vector4.FromArrayToRef = function (array, offset, result) {
  70859. result.x = array[offset];
  70860. result.y = array[offset + 1];
  70861. result.z = array[offset + 2];
  70862. result.w = array[offset + 3];
  70863. };
  70864. /**
  70865. * Updates the given vector "result" from the starting index of the given Float32Array.
  70866. * @param array the array to pull values from
  70867. * @param offset the offset into the array to start at
  70868. * @param result the vector to store the result in
  70869. */
  70870. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  70871. Vector4.FromArrayToRef(array, offset, result);
  70872. };
  70873. /**
  70874. * Updates the given vector "result" coordinates from the given floats.
  70875. * @param x float to set from
  70876. * @param y float to set from
  70877. * @param z float to set from
  70878. * @param w float to set from
  70879. * @param result the vector to the floats in
  70880. */
  70881. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  70882. result.x = x;
  70883. result.y = y;
  70884. result.z = z;
  70885. result.w = w;
  70886. };
  70887. /**
  70888. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70889. * @returns the new vector
  70890. */
  70891. Vector4.Zero = function () {
  70892. return new Vector4(0.0, 0.0, 0.0, 0.0);
  70893. };
  70894. /**
  70895. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70896. * @returns the new vector
  70897. */
  70898. Vector4.One = function () {
  70899. return new Vector4(1.0, 1.0, 1.0, 1.0);
  70900. };
  70901. /**
  70902. * Returns a new normalized Vector4 from the given one.
  70903. * @param vector the vector to normalize
  70904. * @returns the vector
  70905. */
  70906. Vector4.Normalize = function (vector) {
  70907. var result = Vector4.Zero();
  70908. Vector4.NormalizeToRef(vector, result);
  70909. return result;
  70910. };
  70911. /**
  70912. * Updates the given vector "result" from the normalization of the given one.
  70913. * @param vector the vector to normalize
  70914. * @param result the vector to store the result in
  70915. */
  70916. Vector4.NormalizeToRef = function (vector, result) {
  70917. result.copyFrom(vector);
  70918. result.normalize();
  70919. };
  70920. /**
  70921. * Returns a vector with the minimum values from the left and right vectors
  70922. * @param left left vector to minimize
  70923. * @param right right vector to minimize
  70924. * @returns a new vector with the minimum of the left and right vector values
  70925. */
  70926. Vector4.Minimize = function (left, right) {
  70927. var min = left.clone();
  70928. min.minimizeInPlace(right);
  70929. return min;
  70930. };
  70931. /**
  70932. * Returns a vector with the maximum values from the left and right vectors
  70933. * @param left left vector to maximize
  70934. * @param right right vector to maximize
  70935. * @returns a new vector with the maximum of the left and right vector values
  70936. */
  70937. Vector4.Maximize = function (left, right) {
  70938. var max = left.clone();
  70939. max.maximizeInPlace(right);
  70940. return max;
  70941. };
  70942. /**
  70943. * Returns the distance (float) between the vectors "value1" and "value2".
  70944. * @param value1 value to calulate the distance between
  70945. * @param value2 value to calulate the distance between
  70946. * @return the distance between the two vectors
  70947. */
  70948. Vector4.Distance = function (value1, value2) {
  70949. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  70950. };
  70951. /**
  70952. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70953. * @param value1 value to calulate the distance between
  70954. * @param value2 value to calulate the distance between
  70955. * @return the distance between the two vectors squared
  70956. */
  70957. Vector4.DistanceSquared = function (value1, value2) {
  70958. var x = value1.x - value2.x;
  70959. var y = value1.y - value2.y;
  70960. var z = value1.z - value2.z;
  70961. var w = value1.w - value2.w;
  70962. return (x * x) + (y * y) + (z * z) + (w * w);
  70963. };
  70964. /**
  70965. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70966. * @param value1 value to calulate the center between
  70967. * @param value2 value to calulate the center between
  70968. * @return the center between the two vectors
  70969. */
  70970. Vector4.Center = function (value1, value2) {
  70971. var center = value1.add(value2);
  70972. center.scaleInPlace(0.5);
  70973. return center;
  70974. };
  70975. /**
  70976. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70977. * This methods computes transformed normalized direction vectors only.
  70978. * @param vector the vector to transform
  70979. * @param transformation the transformation matrix to apply
  70980. * @returns the new vector
  70981. */
  70982. Vector4.TransformNormal = function (vector, transformation) {
  70983. var result = Vector4.Zero();
  70984. Vector4.TransformNormalToRef(vector, transformation, result);
  70985. return result;
  70986. };
  70987. /**
  70988. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70989. * This methods computes transformed normalized direction vectors only.
  70990. * @param vector the vector to transform
  70991. * @param transformation the transformation matrix to apply
  70992. * @param result the vector to store the result in
  70993. */
  70994. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  70995. var m = transformation.m;
  70996. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  70997. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  70998. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  70999. result.x = x;
  71000. result.y = y;
  71001. result.z = z;
  71002. result.w = vector.w;
  71003. };
  71004. /**
  71005. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71006. * This methods computes transformed normalized direction vectors only.
  71007. * @param x value to transform
  71008. * @param y value to transform
  71009. * @param z value to transform
  71010. * @param w value to transform
  71011. * @param transformation the transformation matrix to apply
  71012. * @param result the vector to store the results in
  71013. */
  71014. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  71015. var m = transformation.m;
  71016. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  71017. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  71018. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  71019. result.w = w;
  71020. };
  71021. /**
  71022. * Creates a new Vector4 from a Vector3
  71023. * @param source defines the source data
  71024. * @param w defines the 4th component (default is 0)
  71025. * @returns a new Vector4
  71026. */
  71027. Vector4.FromVector3 = function (source, w) {
  71028. if (w === void 0) { w = 0; }
  71029. return new Vector4(source.x, source.y, source.z, w);
  71030. };
  71031. return Vector4;
  71032. }());
  71033. /**
  71034. * Size containing widht and height
  71035. */
  71036. var Size = /** @class */ (function () {
  71037. /**
  71038. * Creates a Size object from the given width and height (floats).
  71039. * @param width width of the new size
  71040. * @param height height of the new size
  71041. */
  71042. function Size(width, height) {
  71043. this.width = width;
  71044. this.height = height;
  71045. }
  71046. /**
  71047. * Returns a string with the Size width and height
  71048. * @returns a string with the Size width and height
  71049. */
  71050. Size.prototype.toString = function () {
  71051. return "{W: " + this.width + ", H: " + this.height + "}";
  71052. };
  71053. /**
  71054. * "Size"
  71055. * @returns the string "Size"
  71056. */
  71057. Size.prototype.getClassName = function () {
  71058. return "Size";
  71059. };
  71060. /**
  71061. * Returns the Size hash code.
  71062. * @returns a hash code for a unique width and height
  71063. */
  71064. Size.prototype.getHashCode = function () {
  71065. var hash = this.width || 0;
  71066. hash = (hash * 397) ^ (this.height || 0);
  71067. return hash;
  71068. };
  71069. /**
  71070. * Updates the current size from the given one.
  71071. * @param src the given size
  71072. */
  71073. Size.prototype.copyFrom = function (src) {
  71074. this.width = src.width;
  71075. this.height = src.height;
  71076. };
  71077. /**
  71078. * Updates in place the current Size from the given floats.
  71079. * @param width width of the new size
  71080. * @param height height of the new size
  71081. * @returns the updated Size.
  71082. */
  71083. Size.prototype.copyFromFloats = function (width, height) {
  71084. this.width = width;
  71085. this.height = height;
  71086. return this;
  71087. };
  71088. /**
  71089. * Updates in place the current Size from the given floats.
  71090. * @param width width to set
  71091. * @param height height to set
  71092. * @returns the updated Size.
  71093. */
  71094. Size.prototype.set = function (width, height) {
  71095. return this.copyFromFloats(width, height);
  71096. };
  71097. /**
  71098. * Multiplies the width and height by numbers
  71099. * @param w factor to multiple the width by
  71100. * @param h factor to multiple the height by
  71101. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  71102. */
  71103. Size.prototype.multiplyByFloats = function (w, h) {
  71104. return new Size(this.width * w, this.height * h);
  71105. };
  71106. /**
  71107. * Clones the size
  71108. * @returns a new Size copied from the given one.
  71109. */
  71110. Size.prototype.clone = function () {
  71111. return new Size(this.width, this.height);
  71112. };
  71113. /**
  71114. * True if the current Size and the given one width and height are strictly equal.
  71115. * @param other the other size to compare against
  71116. * @returns True if the current Size and the given one width and height are strictly equal.
  71117. */
  71118. Size.prototype.equals = function (other) {
  71119. if (!other) {
  71120. return false;
  71121. }
  71122. return (this.width === other.width) && (this.height === other.height);
  71123. };
  71124. Object.defineProperty(Size.prototype, "surface", {
  71125. /**
  71126. * The surface of the Size : width * height (float).
  71127. */
  71128. get: function () {
  71129. return this.width * this.height;
  71130. },
  71131. enumerable: true,
  71132. configurable: true
  71133. });
  71134. /**
  71135. * Create a new size of zero
  71136. * @returns a new Size set to (0.0, 0.0)
  71137. */
  71138. Size.Zero = function () {
  71139. return new Size(0.0, 0.0);
  71140. };
  71141. /**
  71142. * Sums the width and height of two sizes
  71143. * @param otherSize size to add to this size
  71144. * @returns a new Size set as the addition result of the current Size and the given one.
  71145. */
  71146. Size.prototype.add = function (otherSize) {
  71147. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  71148. return r;
  71149. };
  71150. /**
  71151. * Subtracts the width and height of two
  71152. * @param otherSize size to subtract to this size
  71153. * @returns a new Size set as the subtraction result of the given one from the current Size.
  71154. */
  71155. Size.prototype.subtract = function (otherSize) {
  71156. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  71157. return r;
  71158. };
  71159. /**
  71160. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  71161. * @param start starting size to lerp between
  71162. * @param end end size to lerp between
  71163. * @param amount amount to lerp between the start and end values
  71164. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  71165. */
  71166. Size.Lerp = function (start, end, amount) {
  71167. var w = start.width + ((end.width - start.width) * amount);
  71168. var h = start.height + ((end.height - start.height) * amount);
  71169. return new Size(w, h);
  71170. };
  71171. return Size;
  71172. }());
  71173. /**
  71174. * Class used to store quaternion data
  71175. * @see https://en.wikipedia.org/wiki/Quaternion
  71176. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71177. */
  71178. var Quaternion = /** @class */ (function () {
  71179. /**
  71180. * Creates a new Quaternion from the given floats
  71181. * @param x defines the first component (0 by default)
  71182. * @param y defines the second component (0 by default)
  71183. * @param z defines the third component (0 by default)
  71184. * @param w defines the fourth component (1.0 by default)
  71185. */
  71186. function Quaternion(
  71187. /** defines the first component (0 by default) */
  71188. x,
  71189. /** defines the second component (0 by default) */
  71190. y,
  71191. /** defines the third component (0 by default) */
  71192. z,
  71193. /** defines the fourth component (1.0 by default) */
  71194. w) {
  71195. if (x === void 0) { x = 0.0; }
  71196. if (y === void 0) { y = 0.0; }
  71197. if (z === void 0) { z = 0.0; }
  71198. if (w === void 0) { w = 1.0; }
  71199. this.x = x;
  71200. this.y = y;
  71201. this.z = z;
  71202. this.w = w;
  71203. }
  71204. /**
  71205. * Gets a string representation for the current quaternion
  71206. * @returns a string with the Quaternion coordinates
  71207. */
  71208. Quaternion.prototype.toString = function () {
  71209. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  71210. };
  71211. /**
  71212. * Gets the class name of the quaternion
  71213. * @returns the string "Quaternion"
  71214. */
  71215. Quaternion.prototype.getClassName = function () {
  71216. return "Quaternion";
  71217. };
  71218. /**
  71219. * Gets a hash code for this quaternion
  71220. * @returns the quaternion hash code
  71221. */
  71222. Quaternion.prototype.getHashCode = function () {
  71223. var hash = this.x || 0;
  71224. hash = (hash * 397) ^ (this.y || 0);
  71225. hash = (hash * 397) ^ (this.z || 0);
  71226. hash = (hash * 397) ^ (this.w || 0);
  71227. return hash;
  71228. };
  71229. /**
  71230. * Copy the quaternion to an array
  71231. * @returns a new array populated with 4 elements from the quaternion coordinates
  71232. */
  71233. Quaternion.prototype.asArray = function () {
  71234. return [this.x, this.y, this.z, this.w];
  71235. };
  71236. /**
  71237. * Check if two quaternions are equals
  71238. * @param otherQuaternion defines the second operand
  71239. * @return true if the current quaternion and the given one coordinates are strictly equals
  71240. */
  71241. Quaternion.prototype.equals = function (otherQuaternion) {
  71242. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  71243. };
  71244. /**
  71245. * Clone the current quaternion
  71246. * @returns a new quaternion copied from the current one
  71247. */
  71248. Quaternion.prototype.clone = function () {
  71249. return new Quaternion(this.x, this.y, this.z, this.w);
  71250. };
  71251. /**
  71252. * Copy a quaternion to the current one
  71253. * @param other defines the other quaternion
  71254. * @returns the updated current quaternion
  71255. */
  71256. Quaternion.prototype.copyFrom = function (other) {
  71257. this.x = other.x;
  71258. this.y = other.y;
  71259. this.z = other.z;
  71260. this.w = other.w;
  71261. return this;
  71262. };
  71263. /**
  71264. * Updates the current quaternion with the given float coordinates
  71265. * @param x defines the x coordinate
  71266. * @param y defines the y coordinate
  71267. * @param z defines the z coordinate
  71268. * @param w defines the w coordinate
  71269. * @returns the updated current quaternion
  71270. */
  71271. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  71272. this.x = x;
  71273. this.y = y;
  71274. this.z = z;
  71275. this.w = w;
  71276. return this;
  71277. };
  71278. /**
  71279. * Updates the current quaternion from the given float coordinates
  71280. * @param x defines the x coordinate
  71281. * @param y defines the y coordinate
  71282. * @param z defines the z coordinate
  71283. * @param w defines the w coordinate
  71284. * @returns the updated current quaternion
  71285. */
  71286. Quaternion.prototype.set = function (x, y, z, w) {
  71287. return this.copyFromFloats(x, y, z, w);
  71288. };
  71289. /**
  71290. * Adds two quaternions
  71291. * @param other defines the second operand
  71292. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71293. */
  71294. Quaternion.prototype.add = function (other) {
  71295. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  71296. };
  71297. /**
  71298. * Add a quaternion to the current one
  71299. * @param other defines the quaternion to add
  71300. * @returns the current quaternion
  71301. */
  71302. Quaternion.prototype.addInPlace = function (other) {
  71303. this.x += other.x;
  71304. this.y += other.y;
  71305. this.z += other.z;
  71306. this.w += other.w;
  71307. return this;
  71308. };
  71309. /**
  71310. * Subtract two quaternions
  71311. * @param other defines the second operand
  71312. * @returns a new quaternion as the subtraction result of the given one from the current one
  71313. */
  71314. Quaternion.prototype.subtract = function (other) {
  71315. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  71316. };
  71317. /**
  71318. * Multiplies the current quaternion by a scale factor
  71319. * @param value defines the scale factor
  71320. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71321. */
  71322. Quaternion.prototype.scale = function (value) {
  71323. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  71324. };
  71325. /**
  71326. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71327. * @param scale defines the scale factor
  71328. * @param result defines the Quaternion object where to store the result
  71329. * @returns the unmodified current quaternion
  71330. */
  71331. Quaternion.prototype.scaleToRef = function (scale, result) {
  71332. result.x = this.x * scale;
  71333. result.y = this.y * scale;
  71334. result.z = this.z * scale;
  71335. result.w = this.w * scale;
  71336. return this;
  71337. };
  71338. /**
  71339. * Multiplies in place the current quaternion by a scale factor
  71340. * @param value defines the scale factor
  71341. * @returns the current modified quaternion
  71342. */
  71343. Quaternion.prototype.scaleInPlace = function (value) {
  71344. this.x *= value;
  71345. this.y *= value;
  71346. this.z *= value;
  71347. this.w *= value;
  71348. return this;
  71349. };
  71350. /**
  71351. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71352. * @param scale defines the scale factor
  71353. * @param result defines the Quaternion object where to store the result
  71354. * @returns the unmodified current quaternion
  71355. */
  71356. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  71357. result.x += this.x * scale;
  71358. result.y += this.y * scale;
  71359. result.z += this.z * scale;
  71360. result.w += this.w * scale;
  71361. return this;
  71362. };
  71363. /**
  71364. * Multiplies two quaternions
  71365. * @param q1 defines the second operand
  71366. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71367. */
  71368. Quaternion.prototype.multiply = function (q1) {
  71369. var result = new Quaternion(0, 0, 0, 1.0);
  71370. this.multiplyToRef(q1, result);
  71371. return result;
  71372. };
  71373. /**
  71374. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71375. * @param q1 defines the second operand
  71376. * @param result defines the target quaternion
  71377. * @returns the current quaternion
  71378. */
  71379. Quaternion.prototype.multiplyToRef = function (q1, result) {
  71380. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  71381. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  71382. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  71383. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  71384. result.copyFromFloats(x, y, z, w);
  71385. return this;
  71386. };
  71387. /**
  71388. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71389. * @param q1 defines the second operand
  71390. * @returns the currentupdated quaternion
  71391. */
  71392. Quaternion.prototype.multiplyInPlace = function (q1) {
  71393. this.multiplyToRef(q1, this);
  71394. return this;
  71395. };
  71396. /**
  71397. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71398. * @param ref defines the target quaternion
  71399. * @returns the current quaternion
  71400. */
  71401. Quaternion.prototype.conjugateToRef = function (ref) {
  71402. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  71403. return this;
  71404. };
  71405. /**
  71406. * Conjugates in place (1-q) the current quaternion
  71407. * @returns the current updated quaternion
  71408. */
  71409. Quaternion.prototype.conjugateInPlace = function () {
  71410. this.x *= -1;
  71411. this.y *= -1;
  71412. this.z *= -1;
  71413. return this;
  71414. };
  71415. /**
  71416. * Conjugates in place (1-q) the current quaternion
  71417. * @returns a new quaternion
  71418. */
  71419. Quaternion.prototype.conjugate = function () {
  71420. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  71421. return result;
  71422. };
  71423. /**
  71424. * Gets length of current quaternion
  71425. * @returns the quaternion length (float)
  71426. */
  71427. Quaternion.prototype.length = function () {
  71428. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  71429. };
  71430. /**
  71431. * Normalize in place the current quaternion
  71432. * @returns the current updated quaternion
  71433. */
  71434. Quaternion.prototype.normalize = function () {
  71435. var length = 1.0 / this.length();
  71436. this.x *= length;
  71437. this.y *= length;
  71438. this.z *= length;
  71439. this.w *= length;
  71440. return this;
  71441. };
  71442. /**
  71443. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71444. * @param order is a reserved parameter and is ignore for now
  71445. * @returns a new Vector3 containing the Euler angles
  71446. */
  71447. Quaternion.prototype.toEulerAngles = function (order) {
  71448. if (order === void 0) { order = "YZX"; }
  71449. var result = Vector3.Zero();
  71450. this.toEulerAnglesToRef(result);
  71451. return result;
  71452. };
  71453. /**
  71454. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71455. * @param result defines the vector which will be filled with the Euler angles
  71456. * @param order is a reserved parameter and is ignore for now
  71457. * @returns the current unchanged quaternion
  71458. */
  71459. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  71460. var qz = this.z;
  71461. var qx = this.x;
  71462. var qy = this.y;
  71463. var qw = this.w;
  71464. var sqw = qw * qw;
  71465. var sqz = qz * qz;
  71466. var sqx = qx * qx;
  71467. var sqy = qy * qy;
  71468. var zAxisY = qy * qz - qx * qw;
  71469. var limit = .4999999;
  71470. if (zAxisY < -limit) {
  71471. result.y = 2 * Math.atan2(qy, qw);
  71472. result.x = Math.PI / 2;
  71473. result.z = 0;
  71474. }
  71475. else if (zAxisY > limit) {
  71476. result.y = 2 * Math.atan2(qy, qw);
  71477. result.x = -Math.PI / 2;
  71478. result.z = 0;
  71479. }
  71480. else {
  71481. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  71482. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  71483. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  71484. }
  71485. return this;
  71486. };
  71487. /**
  71488. * Updates the given rotation matrix with the current quaternion values
  71489. * @param result defines the target matrix
  71490. * @returns the current unchanged quaternion
  71491. */
  71492. Quaternion.prototype.toRotationMatrix = function (result) {
  71493. Matrix.FromQuaternionToRef(this, result);
  71494. return this;
  71495. };
  71496. /**
  71497. * Updates the current quaternion from the given rotation matrix values
  71498. * @param matrix defines the source matrix
  71499. * @returns the current updated quaternion
  71500. */
  71501. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  71502. Quaternion.FromRotationMatrixToRef(matrix, this);
  71503. return this;
  71504. };
  71505. // Statics
  71506. /**
  71507. * Creates a new quaternion from a rotation matrix
  71508. * @param matrix defines the source matrix
  71509. * @returns a new quaternion created from the given rotation matrix values
  71510. */
  71511. Quaternion.FromRotationMatrix = function (matrix) {
  71512. var result = new Quaternion();
  71513. Quaternion.FromRotationMatrixToRef(matrix, result);
  71514. return result;
  71515. };
  71516. /**
  71517. * Updates the given quaternion with the given rotation matrix values
  71518. * @param matrix defines the source matrix
  71519. * @param result defines the target quaternion
  71520. */
  71521. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  71522. var data = matrix.m;
  71523. var m11 = data[0], m12 = data[4], m13 = data[8];
  71524. var m21 = data[1], m22 = data[5], m23 = data[9];
  71525. var m31 = data[2], m32 = data[6], m33 = data[10];
  71526. var trace = m11 + m22 + m33;
  71527. var s;
  71528. if (trace > 0) {
  71529. s = 0.5 / Math.sqrt(trace + 1.0);
  71530. result.w = 0.25 / s;
  71531. result.x = (m32 - m23) * s;
  71532. result.y = (m13 - m31) * s;
  71533. result.z = (m21 - m12) * s;
  71534. }
  71535. else if (m11 > m22 && m11 > m33) {
  71536. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  71537. result.w = (m32 - m23) / s;
  71538. result.x = 0.25 * s;
  71539. result.y = (m12 + m21) / s;
  71540. result.z = (m13 + m31) / s;
  71541. }
  71542. else if (m22 > m33) {
  71543. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  71544. result.w = (m13 - m31) / s;
  71545. result.x = (m12 + m21) / s;
  71546. result.y = 0.25 * s;
  71547. result.z = (m23 + m32) / s;
  71548. }
  71549. else {
  71550. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  71551. result.w = (m21 - m12) / s;
  71552. result.x = (m13 + m31) / s;
  71553. result.y = (m23 + m32) / s;
  71554. result.z = 0.25 * s;
  71555. }
  71556. };
  71557. /**
  71558. * Returns the dot product (float) between the quaternions "left" and "right"
  71559. * @param left defines the left operand
  71560. * @param right defines the right operand
  71561. * @returns the dot product
  71562. */
  71563. Quaternion.Dot = function (left, right) {
  71564. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  71565. };
  71566. /**
  71567. * Checks if the two quaternions are close to each other
  71568. * @param quat0 defines the first quaternion to check
  71569. * @param quat1 defines the second quaternion to check
  71570. * @returns true if the two quaternions are close to each other
  71571. */
  71572. Quaternion.AreClose = function (quat0, quat1) {
  71573. var dot = Quaternion.Dot(quat0, quat1);
  71574. return dot >= 0;
  71575. };
  71576. /**
  71577. * Creates an empty quaternion
  71578. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71579. */
  71580. Quaternion.Zero = function () {
  71581. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  71582. };
  71583. /**
  71584. * Inverse a given quaternion
  71585. * @param q defines the source quaternion
  71586. * @returns a new quaternion as the inverted current quaternion
  71587. */
  71588. Quaternion.Inverse = function (q) {
  71589. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  71590. };
  71591. /**
  71592. * Inverse a given quaternion
  71593. * @param q defines the source quaternion
  71594. * @param result the quaternion the result will be stored in
  71595. * @returns the result quaternion
  71596. */
  71597. Quaternion.InverseToRef = function (q, result) {
  71598. result.set(-q.x, -q.y, -q.z, q.w);
  71599. return result;
  71600. };
  71601. /**
  71602. * Creates an identity quaternion
  71603. * @returns the identity quaternion
  71604. */
  71605. Quaternion.Identity = function () {
  71606. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  71607. };
  71608. /**
  71609. * Gets a boolean indicating if the given quaternion is identity
  71610. * @param quaternion defines the quaternion to check
  71611. * @returns true if the quaternion is identity
  71612. */
  71613. Quaternion.IsIdentity = function (quaternion) {
  71614. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  71615. };
  71616. /**
  71617. * Creates a quaternion from a rotation around an axis
  71618. * @param axis defines the axis to use
  71619. * @param angle defines the angle to use
  71620. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71621. */
  71622. Quaternion.RotationAxis = function (axis, angle) {
  71623. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  71624. };
  71625. /**
  71626. * Creates a rotation around an axis and stores it into the given quaternion
  71627. * @param axis defines the axis to use
  71628. * @param angle defines the angle to use
  71629. * @param result defines the target quaternion
  71630. * @returns the target quaternion
  71631. */
  71632. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  71633. var sin = Math.sin(angle / 2);
  71634. axis.normalize();
  71635. result.w = Math.cos(angle / 2);
  71636. result.x = axis.x * sin;
  71637. result.y = axis.y * sin;
  71638. result.z = axis.z * sin;
  71639. return result;
  71640. };
  71641. /**
  71642. * Creates a new quaternion from data stored into an array
  71643. * @param array defines the data source
  71644. * @param offset defines the offset in the source array where the data starts
  71645. * @returns a new quaternion
  71646. */
  71647. Quaternion.FromArray = function (array, offset) {
  71648. if (!offset) {
  71649. offset = 0;
  71650. }
  71651. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71652. };
  71653. /**
  71654. * Create a quaternion from Euler rotation angles
  71655. * @param x Pitch
  71656. * @param y Yaw
  71657. * @param z Roll
  71658. * @returns the new Quaternion
  71659. */
  71660. Quaternion.FromEulerAngles = function (x, y, z) {
  71661. var q = new Quaternion();
  71662. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  71663. return q;
  71664. };
  71665. /**
  71666. * Updates a quaternion from Euler rotation angles
  71667. * @param x Pitch
  71668. * @param y Yaw
  71669. * @param z Roll
  71670. * @param result the quaternion to store the result
  71671. * @returns the updated quaternion
  71672. */
  71673. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  71674. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  71675. return result;
  71676. };
  71677. /**
  71678. * Create a quaternion from Euler rotation vector
  71679. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71680. * @returns the new Quaternion
  71681. */
  71682. Quaternion.FromEulerVector = function (vec) {
  71683. var q = new Quaternion();
  71684. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  71685. return q;
  71686. };
  71687. /**
  71688. * Updates a quaternion from Euler rotation vector
  71689. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71690. * @param result the quaternion to store the result
  71691. * @returns the updated quaternion
  71692. */
  71693. Quaternion.FromEulerVectorToRef = function (vec, result) {
  71694. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  71695. return result;
  71696. };
  71697. /**
  71698. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71699. * @param yaw defines the rotation around Y axis
  71700. * @param pitch defines the rotation around X axis
  71701. * @param roll defines the rotation around Z axis
  71702. * @returns the new quaternion
  71703. */
  71704. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  71705. var q = new Quaternion();
  71706. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  71707. return q;
  71708. };
  71709. /**
  71710. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71711. * @param yaw defines the rotation around Y axis
  71712. * @param pitch defines the rotation around X axis
  71713. * @param roll defines the rotation around Z axis
  71714. * @param result defines the target quaternion
  71715. */
  71716. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  71717. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  71718. var halfRoll = roll * 0.5;
  71719. var halfPitch = pitch * 0.5;
  71720. var halfYaw = yaw * 0.5;
  71721. var sinRoll = Math.sin(halfRoll);
  71722. var cosRoll = Math.cos(halfRoll);
  71723. var sinPitch = Math.sin(halfPitch);
  71724. var cosPitch = Math.cos(halfPitch);
  71725. var sinYaw = Math.sin(halfYaw);
  71726. var cosYaw = Math.cos(halfYaw);
  71727. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  71728. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  71729. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  71730. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  71731. };
  71732. /**
  71733. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71734. * @param alpha defines the rotation around first axis
  71735. * @param beta defines the rotation around second axis
  71736. * @param gamma defines the rotation around third axis
  71737. * @returns the new quaternion
  71738. */
  71739. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  71740. var result = new Quaternion();
  71741. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  71742. return result;
  71743. };
  71744. /**
  71745. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71746. * @param alpha defines the rotation around first axis
  71747. * @param beta defines the rotation around second axis
  71748. * @param gamma defines the rotation around third axis
  71749. * @param result defines the target quaternion
  71750. */
  71751. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  71752. // Produces a quaternion from Euler angles in the z-x-z orientation
  71753. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  71754. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  71755. var halfBeta = beta * 0.5;
  71756. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71757. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71758. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71759. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71760. };
  71761. /**
  71762. * 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)
  71763. * @param axis1 defines the first axis
  71764. * @param axis2 defines the second axis
  71765. * @param axis3 defines the third axis
  71766. * @returns the new quaternion
  71767. */
  71768. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  71769. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  71770. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  71771. return quat;
  71772. };
  71773. /**
  71774. * 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
  71775. * @param axis1 defines the first axis
  71776. * @param axis2 defines the second axis
  71777. * @param axis3 defines the third axis
  71778. * @param ref defines the target quaternion
  71779. */
  71780. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  71781. var rotMat = MathTmp.Matrix[0];
  71782. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  71783. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  71784. };
  71785. /**
  71786. * Interpolates between two quaternions
  71787. * @param left defines first quaternion
  71788. * @param right defines second quaternion
  71789. * @param amount defines the gradient to use
  71790. * @returns the new interpolated quaternion
  71791. */
  71792. Quaternion.Slerp = function (left, right, amount) {
  71793. var result = Quaternion.Identity();
  71794. Quaternion.SlerpToRef(left, right, amount, result);
  71795. return result;
  71796. };
  71797. /**
  71798. * Interpolates between two quaternions and stores it into a target quaternion
  71799. * @param left defines first quaternion
  71800. * @param right defines second quaternion
  71801. * @param amount defines the gradient to use
  71802. * @param result defines the target quaternion
  71803. */
  71804. Quaternion.SlerpToRef = function (left, right, amount, result) {
  71805. var num2;
  71806. var num3;
  71807. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  71808. var flag = false;
  71809. if (num4 < 0) {
  71810. flag = true;
  71811. num4 = -num4;
  71812. }
  71813. if (num4 > 0.999999) {
  71814. num3 = 1 - amount;
  71815. num2 = flag ? -amount : amount;
  71816. }
  71817. else {
  71818. var num5 = Math.acos(num4);
  71819. var num6 = (1.0 / Math.sin(num5));
  71820. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  71821. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  71822. }
  71823. result.x = (num3 * left.x) + (num2 * right.x);
  71824. result.y = (num3 * left.y) + (num2 * right.y);
  71825. result.z = (num3 * left.z) + (num2 * right.z);
  71826. result.w = (num3 * left.w) + (num2 * right.w);
  71827. };
  71828. /**
  71829. * Interpolate between two quaternions using Hermite interpolation
  71830. * @param value1 defines first quaternion
  71831. * @param tangent1 defines the incoming tangent
  71832. * @param value2 defines second quaternion
  71833. * @param tangent2 defines the outgoing tangent
  71834. * @param amount defines the target quaternion
  71835. * @returns the new interpolated quaternion
  71836. */
  71837. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71838. var squared = amount * amount;
  71839. var cubed = amount * squared;
  71840. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71841. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71842. var part3 = (cubed - (2.0 * squared)) + amount;
  71843. var part4 = cubed - squared;
  71844. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71845. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71846. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  71847. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  71848. return new Quaternion(x, y, z, w);
  71849. };
  71850. return Quaternion;
  71851. }());
  71852. /**
  71853. * Class used to store matrix data (4x4)
  71854. */
  71855. var Matrix = /** @class */ (function () {
  71856. /**
  71857. * Creates an empty matrix (filled with zeros)
  71858. */
  71859. function Matrix() {
  71860. this._isIdentity = false;
  71861. this._isIdentityDirty = true;
  71862. this._isIdentity3x2 = true;
  71863. this._isIdentity3x2Dirty = true;
  71864. this._m = new Float32Array(16);
  71865. this._updateIdentityStatus(false);
  71866. }
  71867. Object.defineProperty(Matrix.prototype, "m", {
  71868. /**
  71869. * Gets the internal data of the matrix
  71870. */
  71871. get: function () { return this._m; },
  71872. enumerable: true,
  71873. configurable: true
  71874. });
  71875. /** @hidden */
  71876. Matrix.prototype._markAsUpdated = function () {
  71877. this.updateFlag = Matrix._updateFlagSeed++;
  71878. this._isIdentity = false;
  71879. this._isIdentity3x2 = false;
  71880. this._isIdentityDirty = true;
  71881. this._isIdentity3x2Dirty = true;
  71882. };
  71883. /** @hidden */
  71884. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  71885. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  71886. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  71887. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  71888. this.updateFlag = Matrix._updateFlagSeed++;
  71889. this._isIdentity = isIdentity;
  71890. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  71891. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  71892. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  71893. };
  71894. // Properties
  71895. /**
  71896. * Check if the current matrix is identity
  71897. * @returns true is the matrix is the identity matrix
  71898. */
  71899. Matrix.prototype.isIdentity = function () {
  71900. if (this._isIdentityDirty) {
  71901. this._isIdentityDirty = false;
  71902. var m = this._m;
  71903. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  71904. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  71905. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  71906. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  71907. }
  71908. return this._isIdentity;
  71909. };
  71910. /**
  71911. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71912. * @returns true is the matrix is the identity matrix
  71913. */
  71914. Matrix.prototype.isIdentityAs3x2 = function () {
  71915. if (this._isIdentity3x2Dirty) {
  71916. this._isIdentity3x2Dirty = false;
  71917. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  71918. this._isIdentity3x2 = false;
  71919. }
  71920. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  71921. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  71922. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  71923. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  71924. this._isIdentity3x2 = false;
  71925. }
  71926. else {
  71927. this._isIdentity3x2 = true;
  71928. }
  71929. }
  71930. return this._isIdentity3x2;
  71931. };
  71932. /**
  71933. * Gets the determinant of the matrix
  71934. * @returns the matrix determinant
  71935. */
  71936. Matrix.prototype.determinant = function () {
  71937. if (this._isIdentity === true) {
  71938. return 1;
  71939. }
  71940. var m = this._m;
  71941. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71942. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71943. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71944. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71945. // https://en.wikipedia.org/wiki/Laplace_expansion
  71946. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  71947. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  71948. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  71949. // where
  71950. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  71951. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  71952. //
  71953. // Here we do that for the 1st row.
  71954. var det_22_33 = m22 * m33 - m32 * m23;
  71955. var det_21_33 = m21 * m33 - m31 * m23;
  71956. var det_21_32 = m21 * m32 - m31 * m22;
  71957. var det_20_33 = m20 * m33 - m30 * m23;
  71958. var det_20_32 = m20 * m32 - m22 * m30;
  71959. var det_20_31 = m20 * m31 - m30 * m21;
  71960. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71961. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71962. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71963. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71964. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71965. };
  71966. // Methods
  71967. /**
  71968. * Returns the matrix as a Float32Array
  71969. * @returns the matrix underlying array
  71970. */
  71971. Matrix.prototype.toArray = function () {
  71972. return this._m;
  71973. };
  71974. /**
  71975. * Returns the matrix as a Float32Array
  71976. * @returns the matrix underlying array.
  71977. */
  71978. Matrix.prototype.asArray = function () {
  71979. return this._m;
  71980. };
  71981. /**
  71982. * Inverts the current matrix in place
  71983. * @returns the current inverted matrix
  71984. */
  71985. Matrix.prototype.invert = function () {
  71986. this.invertToRef(this);
  71987. return this;
  71988. };
  71989. /**
  71990. * Sets all the matrix elements to zero
  71991. * @returns the current matrix
  71992. */
  71993. Matrix.prototype.reset = function () {
  71994. 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);
  71995. this._updateIdentityStatus(false);
  71996. return this;
  71997. };
  71998. /**
  71999. * Adds the current matrix with a second one
  72000. * @param other defines the matrix to add
  72001. * @returns a new matrix as the addition of the current matrix and the given one
  72002. */
  72003. Matrix.prototype.add = function (other) {
  72004. var result = new Matrix();
  72005. this.addToRef(other, result);
  72006. return result;
  72007. };
  72008. /**
  72009. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72010. * @param other defines the matrix to add
  72011. * @param result defines the target matrix
  72012. * @returns the current matrix
  72013. */
  72014. Matrix.prototype.addToRef = function (other, result) {
  72015. var m = this._m;
  72016. var resultM = result._m;
  72017. var otherM = other.m;
  72018. for (var index = 0; index < 16; index++) {
  72019. resultM[index] = m[index] + otherM[index];
  72020. }
  72021. result._markAsUpdated();
  72022. return this;
  72023. };
  72024. /**
  72025. * Adds in place the given matrix to the current matrix
  72026. * @param other defines the second operand
  72027. * @returns the current updated matrix
  72028. */
  72029. Matrix.prototype.addToSelf = function (other) {
  72030. var m = this._m;
  72031. var otherM = other.m;
  72032. for (var index = 0; index < 16; index++) {
  72033. m[index] += otherM[index];
  72034. }
  72035. this._markAsUpdated();
  72036. return this;
  72037. };
  72038. /**
  72039. * Sets the given matrix to the current inverted Matrix
  72040. * @param other defines the target matrix
  72041. * @returns the unmodified current matrix
  72042. */
  72043. Matrix.prototype.invertToRef = function (other) {
  72044. if (this._isIdentity === true) {
  72045. Matrix.IdentityToRef(other);
  72046. return this;
  72047. }
  72048. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  72049. var m = this._m;
  72050. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  72051. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  72052. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  72053. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  72054. var det_22_33 = m22 * m33 - m32 * m23;
  72055. var det_21_33 = m21 * m33 - m31 * m23;
  72056. var det_21_32 = m21 * m32 - m31 * m22;
  72057. var det_20_33 = m20 * m33 - m30 * m23;
  72058. var det_20_32 = m20 * m32 - m22 * m30;
  72059. var det_20_31 = m20 * m31 - m30 * m21;
  72060. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  72061. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  72062. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  72063. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  72064. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  72065. if (det === 0) {
  72066. // not invertible
  72067. other.copyFrom(this);
  72068. return this;
  72069. }
  72070. var detInv = 1 / det;
  72071. var det_12_33 = m12 * m33 - m32 * m13;
  72072. var det_11_33 = m11 * m33 - m31 * m13;
  72073. var det_11_32 = m11 * m32 - m31 * m12;
  72074. var det_10_33 = m10 * m33 - m30 * m13;
  72075. var det_10_32 = m10 * m32 - m30 * m12;
  72076. var det_10_31 = m10 * m31 - m30 * m11;
  72077. var det_12_23 = m12 * m23 - m22 * m13;
  72078. var det_11_23 = m11 * m23 - m21 * m13;
  72079. var det_11_22 = m11 * m22 - m21 * m12;
  72080. var det_10_23 = m10 * m23 - m20 * m13;
  72081. var det_10_22 = m10 * m22 - m20 * m12;
  72082. var det_10_21 = m10 * m21 - m20 * m11;
  72083. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  72084. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  72085. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  72086. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  72087. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  72088. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  72089. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  72090. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  72091. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  72092. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  72093. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  72094. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  72095. 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);
  72096. return this;
  72097. };
  72098. /**
  72099. * add a value at the specified position in the current Matrix
  72100. * @param index the index of the value within the matrix. between 0 and 15.
  72101. * @param value the value to be added
  72102. * @returns the current updated matrix
  72103. */
  72104. Matrix.prototype.addAtIndex = function (index, value) {
  72105. this._m[index] += value;
  72106. this._markAsUpdated();
  72107. return this;
  72108. };
  72109. /**
  72110. * mutiply the specified position in the current Matrix by a value
  72111. * @param index the index of the value within the matrix. between 0 and 15.
  72112. * @param value the value to be added
  72113. * @returns the current updated matrix
  72114. */
  72115. Matrix.prototype.multiplyAtIndex = function (index, value) {
  72116. this._m[index] *= value;
  72117. this._markAsUpdated();
  72118. return this;
  72119. };
  72120. /**
  72121. * Inserts the translation vector (using 3 floats) in the current matrix
  72122. * @param x defines the 1st component of the translation
  72123. * @param y defines the 2nd component of the translation
  72124. * @param z defines the 3rd component of the translation
  72125. * @returns the current updated matrix
  72126. */
  72127. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  72128. this._m[12] = x;
  72129. this._m[13] = y;
  72130. this._m[14] = z;
  72131. this._markAsUpdated();
  72132. return this;
  72133. };
  72134. /**
  72135. * Inserts the translation vector in the current matrix
  72136. * @param vector3 defines the translation to insert
  72137. * @returns the current updated matrix
  72138. */
  72139. Matrix.prototype.setTranslation = function (vector3) {
  72140. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  72141. };
  72142. /**
  72143. * Gets the translation value of the current matrix
  72144. * @returns a new Vector3 as the extracted translation from the matrix
  72145. */
  72146. Matrix.prototype.getTranslation = function () {
  72147. return new Vector3(this._m[12], this._m[13], this._m[14]);
  72148. };
  72149. /**
  72150. * Fill a Vector3 with the extracted translation from the matrix
  72151. * @param result defines the Vector3 where to store the translation
  72152. * @returns the current matrix
  72153. */
  72154. Matrix.prototype.getTranslationToRef = function (result) {
  72155. result.x = this._m[12];
  72156. result.y = this._m[13];
  72157. result.z = this._m[14];
  72158. return this;
  72159. };
  72160. /**
  72161. * Remove rotation and scaling part from the matrix
  72162. * @returns the updated matrix
  72163. */
  72164. Matrix.prototype.removeRotationAndScaling = function () {
  72165. var m = this.m;
  72166. 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);
  72167. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  72168. return this;
  72169. };
  72170. /**
  72171. * Multiply two matrices
  72172. * @param other defines the second operand
  72173. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72174. */
  72175. Matrix.prototype.multiply = function (other) {
  72176. var result = new Matrix();
  72177. this.multiplyToRef(other, result);
  72178. return result;
  72179. };
  72180. /**
  72181. * Copy the current matrix from the given one
  72182. * @param other defines the source matrix
  72183. * @returns the current updated matrix
  72184. */
  72185. Matrix.prototype.copyFrom = function (other) {
  72186. other.copyToArray(this._m);
  72187. var o = other;
  72188. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  72189. return this;
  72190. };
  72191. /**
  72192. * Populates the given array from the starting index with the current matrix values
  72193. * @param array defines the target array
  72194. * @param offset defines the offset in the target array where to start storing values
  72195. * @returns the current matrix
  72196. */
  72197. Matrix.prototype.copyToArray = function (array, offset) {
  72198. if (offset === void 0) { offset = 0; }
  72199. for (var index = 0; index < 16; index++) {
  72200. array[offset + index] = this._m[index];
  72201. }
  72202. return this;
  72203. };
  72204. /**
  72205. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72206. * @param other defines the second operand
  72207. * @param result defines the matrix where to store the multiplication
  72208. * @returns the current matrix
  72209. */
  72210. Matrix.prototype.multiplyToRef = function (other, result) {
  72211. if (this._isIdentity) {
  72212. result.copyFrom(other);
  72213. return this;
  72214. }
  72215. if (other._isIdentity) {
  72216. result.copyFrom(this);
  72217. return this;
  72218. }
  72219. this.multiplyToArray(other, result._m, 0);
  72220. result._markAsUpdated();
  72221. return this;
  72222. };
  72223. /**
  72224. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72225. * @param other defines the second operand
  72226. * @param result defines the array where to store the multiplication
  72227. * @param offset defines the offset in the target array where to start storing values
  72228. * @returns the current matrix
  72229. */
  72230. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  72231. var m = this._m;
  72232. var otherM = other.m;
  72233. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  72234. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  72235. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  72236. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  72237. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  72238. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  72239. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  72240. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  72241. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  72242. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  72243. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  72244. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  72245. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  72246. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  72247. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  72248. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  72249. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  72250. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  72251. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  72252. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  72253. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  72254. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  72255. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  72256. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  72257. return this;
  72258. };
  72259. /**
  72260. * Check equality between this matrix and a second one
  72261. * @param value defines the second matrix to compare
  72262. * @returns true is the current matrix and the given one values are strictly equal
  72263. */
  72264. Matrix.prototype.equals = function (value) {
  72265. var other = value;
  72266. if (!other) {
  72267. return false;
  72268. }
  72269. if (this._isIdentity || other._isIdentity) {
  72270. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  72271. return this._isIdentity && other._isIdentity;
  72272. }
  72273. }
  72274. var m = this.m;
  72275. var om = other.m;
  72276. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  72277. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  72278. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  72279. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  72280. };
  72281. /**
  72282. * Clone the current matrix
  72283. * @returns a new matrix from the current matrix
  72284. */
  72285. Matrix.prototype.clone = function () {
  72286. var matrix = new Matrix();
  72287. matrix.copyFrom(this);
  72288. return matrix;
  72289. };
  72290. /**
  72291. * Returns the name of the current matrix class
  72292. * @returns the string "Matrix"
  72293. */
  72294. Matrix.prototype.getClassName = function () {
  72295. return "Matrix";
  72296. };
  72297. /**
  72298. * Gets the hash code of the current matrix
  72299. * @returns the hash code
  72300. */
  72301. Matrix.prototype.getHashCode = function () {
  72302. var hash = this._m[0] || 0;
  72303. for (var i = 1; i < 16; i++) {
  72304. hash = (hash * 397) ^ (this._m[i] || 0);
  72305. }
  72306. return hash;
  72307. };
  72308. /**
  72309. * Decomposes the current Matrix into a translation, rotation and scaling components
  72310. * @param scale defines the scale vector3 given as a reference to update
  72311. * @param rotation defines the rotation quaternion given as a reference to update
  72312. * @param translation defines the translation vector3 given as a reference to update
  72313. * @returns true if operation was successful
  72314. */
  72315. Matrix.prototype.decompose = function (scale, rotation, translation) {
  72316. if (this._isIdentity) {
  72317. if (translation) {
  72318. translation.setAll(0);
  72319. }
  72320. if (scale) {
  72321. scale.setAll(1);
  72322. }
  72323. if (rotation) {
  72324. rotation.copyFromFloats(0, 0, 0, 1);
  72325. }
  72326. return true;
  72327. }
  72328. var m = this._m;
  72329. if (translation) {
  72330. translation.copyFromFloats(m[12], m[13], m[14]);
  72331. }
  72332. scale = scale || MathTmp.Vector3[0];
  72333. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  72334. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  72335. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  72336. if (this.determinant() <= 0) {
  72337. scale.y *= -1;
  72338. }
  72339. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  72340. if (rotation) {
  72341. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  72342. }
  72343. return false;
  72344. }
  72345. if (rotation) {
  72346. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72347. 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]);
  72348. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  72349. }
  72350. return true;
  72351. };
  72352. /**
  72353. * Gets specific row of the matrix
  72354. * @param index defines the number of the row to get
  72355. * @returns the index-th row of the current matrix as a new Vector4
  72356. */
  72357. Matrix.prototype.getRow = function (index) {
  72358. if (index < 0 || index > 3) {
  72359. return null;
  72360. }
  72361. var i = index * 4;
  72362. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  72363. };
  72364. /**
  72365. * Sets the index-th row of the current matrix to the vector4 values
  72366. * @param index defines the number of the row to set
  72367. * @param row defines the target vector4
  72368. * @returns the updated current matrix
  72369. */
  72370. Matrix.prototype.setRow = function (index, row) {
  72371. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  72372. };
  72373. /**
  72374. * Compute the transpose of the matrix
  72375. * @returns the new transposed matrix
  72376. */
  72377. Matrix.prototype.transpose = function () {
  72378. return Matrix.Transpose(this);
  72379. };
  72380. /**
  72381. * Compute the transpose of the matrix and store it in a given matrix
  72382. * @param result defines the target matrix
  72383. * @returns the current matrix
  72384. */
  72385. Matrix.prototype.transposeToRef = function (result) {
  72386. Matrix.TransposeToRef(this, result);
  72387. return this;
  72388. };
  72389. /**
  72390. * Sets the index-th row of the current matrix with the given 4 x float values
  72391. * @param index defines the row index
  72392. * @param x defines the x component to set
  72393. * @param y defines the y component to set
  72394. * @param z defines the z component to set
  72395. * @param w defines the w component to set
  72396. * @returns the updated current matrix
  72397. */
  72398. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  72399. if (index < 0 || index > 3) {
  72400. return this;
  72401. }
  72402. var i = index * 4;
  72403. this._m[i + 0] = x;
  72404. this._m[i + 1] = y;
  72405. this._m[i + 2] = z;
  72406. this._m[i + 3] = w;
  72407. this._markAsUpdated();
  72408. return this;
  72409. };
  72410. /**
  72411. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72412. * @param scale defines the scale factor
  72413. * @returns a new matrix
  72414. */
  72415. Matrix.prototype.scale = function (scale) {
  72416. var result = new Matrix();
  72417. this.scaleToRef(scale, result);
  72418. return result;
  72419. };
  72420. /**
  72421. * Scale the current matrix values by a factor to a given result matrix
  72422. * @param scale defines the scale factor
  72423. * @param result defines the matrix to store the result
  72424. * @returns the current matrix
  72425. */
  72426. Matrix.prototype.scaleToRef = function (scale, result) {
  72427. for (var index = 0; index < 16; index++) {
  72428. result._m[index] = this._m[index] * scale;
  72429. }
  72430. result._markAsUpdated();
  72431. return this;
  72432. };
  72433. /**
  72434. * Scale the current matrix values by a factor and add the result to a given matrix
  72435. * @param scale defines the scale factor
  72436. * @param result defines the Matrix to store the result
  72437. * @returns the current matrix
  72438. */
  72439. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  72440. for (var index = 0; index < 16; index++) {
  72441. result._m[index] += this._m[index] * scale;
  72442. }
  72443. result._markAsUpdated();
  72444. return this;
  72445. };
  72446. /**
  72447. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72448. * @param ref matrix to store the result
  72449. */
  72450. Matrix.prototype.toNormalMatrix = function (ref) {
  72451. var tmp = MathTmp.Matrix[0];
  72452. this.invertToRef(tmp);
  72453. tmp.transposeToRef(ref);
  72454. var m = ref._m;
  72455. 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);
  72456. };
  72457. /**
  72458. * Gets only rotation part of the current matrix
  72459. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72460. */
  72461. Matrix.prototype.getRotationMatrix = function () {
  72462. var result = new Matrix();
  72463. this.getRotationMatrixToRef(result);
  72464. return result;
  72465. };
  72466. /**
  72467. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72468. * @param result defines the target matrix to store data to
  72469. * @returns the current matrix
  72470. */
  72471. Matrix.prototype.getRotationMatrixToRef = function (result) {
  72472. var scale = MathTmp.Vector3[0];
  72473. if (!this.decompose(scale)) {
  72474. Matrix.IdentityToRef(result);
  72475. return this;
  72476. }
  72477. var m = this._m;
  72478. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72479. 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);
  72480. return this;
  72481. };
  72482. /**
  72483. * Toggles model matrix from being right handed to left handed in place and vice versa
  72484. */
  72485. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  72486. var m = this._m;
  72487. m[2] *= -1;
  72488. m[6] *= -1;
  72489. m[8] *= -1;
  72490. m[9] *= -1;
  72491. m[14] *= -1;
  72492. this._markAsUpdated();
  72493. };
  72494. /**
  72495. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72496. */
  72497. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  72498. var m = this._m;
  72499. m[8] *= -1;
  72500. m[9] *= -1;
  72501. m[10] *= -1;
  72502. m[11] *= -1;
  72503. this._markAsUpdated();
  72504. };
  72505. // Statics
  72506. /**
  72507. * Creates a matrix from an array
  72508. * @param array defines the source array
  72509. * @param offset defines an offset in the source array
  72510. * @returns a new Matrix set from the starting index of the given array
  72511. */
  72512. Matrix.FromArray = function (array, offset) {
  72513. if (offset === void 0) { offset = 0; }
  72514. var result = new Matrix();
  72515. Matrix.FromArrayToRef(array, offset, result);
  72516. return result;
  72517. };
  72518. /**
  72519. * Copy the content of an array into a given matrix
  72520. * @param array defines the source array
  72521. * @param offset defines an offset in the source array
  72522. * @param result defines the target matrix
  72523. */
  72524. Matrix.FromArrayToRef = function (array, offset, result) {
  72525. for (var index = 0; index < 16; index++) {
  72526. result._m[index] = array[index + offset];
  72527. }
  72528. result._markAsUpdated();
  72529. };
  72530. /**
  72531. * Stores an array into a matrix after having multiplied each component by a given factor
  72532. * @param array defines the source array
  72533. * @param offset defines the offset in the source array
  72534. * @param scale defines the scaling factor
  72535. * @param result defines the target matrix
  72536. */
  72537. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  72538. for (var index = 0; index < 16; index++) {
  72539. result._m[index] = array[index + offset] * scale;
  72540. }
  72541. result._markAsUpdated();
  72542. };
  72543. Object.defineProperty(Matrix, "IdentityReadOnly", {
  72544. /**
  72545. * Gets an identity matrix that must not be updated
  72546. */
  72547. get: function () {
  72548. return Matrix._identityReadOnly;
  72549. },
  72550. enumerable: true,
  72551. configurable: true
  72552. });
  72553. /**
  72554. * Stores a list of values (16) inside a given matrix
  72555. * @param initialM11 defines 1st value of 1st row
  72556. * @param initialM12 defines 2nd value of 1st row
  72557. * @param initialM13 defines 3rd value of 1st row
  72558. * @param initialM14 defines 4th value of 1st row
  72559. * @param initialM21 defines 1st value of 2nd row
  72560. * @param initialM22 defines 2nd value of 2nd row
  72561. * @param initialM23 defines 3rd value of 2nd row
  72562. * @param initialM24 defines 4th value of 2nd row
  72563. * @param initialM31 defines 1st value of 3rd row
  72564. * @param initialM32 defines 2nd value of 3rd row
  72565. * @param initialM33 defines 3rd value of 3rd row
  72566. * @param initialM34 defines 4th value of 3rd row
  72567. * @param initialM41 defines 1st value of 4th row
  72568. * @param initialM42 defines 2nd value of 4th row
  72569. * @param initialM43 defines 3rd value of 4th row
  72570. * @param initialM44 defines 4th value of 4th row
  72571. * @param result defines the target matrix
  72572. */
  72573. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  72574. var m = result._m;
  72575. m[0] = initialM11;
  72576. m[1] = initialM12;
  72577. m[2] = initialM13;
  72578. m[3] = initialM14;
  72579. m[4] = initialM21;
  72580. m[5] = initialM22;
  72581. m[6] = initialM23;
  72582. m[7] = initialM24;
  72583. m[8] = initialM31;
  72584. m[9] = initialM32;
  72585. m[10] = initialM33;
  72586. m[11] = initialM34;
  72587. m[12] = initialM41;
  72588. m[13] = initialM42;
  72589. m[14] = initialM43;
  72590. m[15] = initialM44;
  72591. result._markAsUpdated();
  72592. };
  72593. /**
  72594. * Creates new matrix from a list of values (16)
  72595. * @param initialM11 defines 1st value of 1st row
  72596. * @param initialM12 defines 2nd value of 1st row
  72597. * @param initialM13 defines 3rd value of 1st row
  72598. * @param initialM14 defines 4th value of 1st row
  72599. * @param initialM21 defines 1st value of 2nd row
  72600. * @param initialM22 defines 2nd value of 2nd row
  72601. * @param initialM23 defines 3rd value of 2nd row
  72602. * @param initialM24 defines 4th value of 2nd row
  72603. * @param initialM31 defines 1st value of 3rd row
  72604. * @param initialM32 defines 2nd value of 3rd row
  72605. * @param initialM33 defines 3rd value of 3rd row
  72606. * @param initialM34 defines 4th value of 3rd row
  72607. * @param initialM41 defines 1st value of 4th row
  72608. * @param initialM42 defines 2nd value of 4th row
  72609. * @param initialM43 defines 3rd value of 4th row
  72610. * @param initialM44 defines 4th value of 4th row
  72611. * @returns the new matrix
  72612. */
  72613. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  72614. var result = new Matrix();
  72615. var m = result._m;
  72616. m[0] = initialM11;
  72617. m[1] = initialM12;
  72618. m[2] = initialM13;
  72619. m[3] = initialM14;
  72620. m[4] = initialM21;
  72621. m[5] = initialM22;
  72622. m[6] = initialM23;
  72623. m[7] = initialM24;
  72624. m[8] = initialM31;
  72625. m[9] = initialM32;
  72626. m[10] = initialM33;
  72627. m[11] = initialM34;
  72628. m[12] = initialM41;
  72629. m[13] = initialM42;
  72630. m[14] = initialM43;
  72631. m[15] = initialM44;
  72632. result._markAsUpdated();
  72633. return result;
  72634. };
  72635. /**
  72636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72637. * @param scale defines the scale vector3
  72638. * @param rotation defines the rotation quaternion
  72639. * @param translation defines the translation vector3
  72640. * @returns a new matrix
  72641. */
  72642. Matrix.Compose = function (scale, rotation, translation) {
  72643. var result = new Matrix();
  72644. Matrix.ComposeToRef(scale, rotation, translation, result);
  72645. return result;
  72646. };
  72647. /**
  72648. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72649. * @param scale defines the scale vector3
  72650. * @param rotation defines the rotation quaternion
  72651. * @param translation defines the translation vector3
  72652. * @param result defines the target matrix
  72653. */
  72654. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  72655. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  72656. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  72657. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  72658. result.setTranslation(translation);
  72659. };
  72660. /**
  72661. * Creates a new identity matrix
  72662. * @returns a new identity matrix
  72663. */
  72664. Matrix.Identity = function () {
  72665. 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);
  72666. identity._updateIdentityStatus(true);
  72667. return identity;
  72668. };
  72669. /**
  72670. * Creates a new identity matrix and stores the result in a given matrix
  72671. * @param result defines the target matrix
  72672. */
  72673. Matrix.IdentityToRef = function (result) {
  72674. 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);
  72675. result._updateIdentityStatus(true);
  72676. };
  72677. /**
  72678. * Creates a new zero matrix
  72679. * @returns a new zero matrix
  72680. */
  72681. Matrix.Zero = function () {
  72682. 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);
  72683. zero._updateIdentityStatus(false);
  72684. return zero;
  72685. };
  72686. /**
  72687. * Creates a new rotation matrix for "angle" radians around the X axis
  72688. * @param angle defines the angle (in radians) to use
  72689. * @return the new matrix
  72690. */
  72691. Matrix.RotationX = function (angle) {
  72692. var result = new Matrix();
  72693. Matrix.RotationXToRef(angle, result);
  72694. return result;
  72695. };
  72696. /**
  72697. * Creates a new matrix as the invert of a given matrix
  72698. * @param source defines the source matrix
  72699. * @returns the new matrix
  72700. */
  72701. Matrix.Invert = function (source) {
  72702. var result = new Matrix();
  72703. source.invertToRef(result);
  72704. return result;
  72705. };
  72706. /**
  72707. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72708. * @param angle defines the angle (in radians) to use
  72709. * @param result defines the target matrix
  72710. */
  72711. Matrix.RotationXToRef = function (angle, result) {
  72712. var s = Math.sin(angle);
  72713. var c = Math.cos(angle);
  72714. 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);
  72715. result._updateIdentityStatus(c === 1 && s === 0);
  72716. };
  72717. /**
  72718. * Creates a new rotation matrix for "angle" radians around the Y axis
  72719. * @param angle defines the angle (in radians) to use
  72720. * @return the new matrix
  72721. */
  72722. Matrix.RotationY = function (angle) {
  72723. var result = new Matrix();
  72724. Matrix.RotationYToRef(angle, result);
  72725. return result;
  72726. };
  72727. /**
  72728. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72729. * @param angle defines the angle (in radians) to use
  72730. * @param result defines the target matrix
  72731. */
  72732. Matrix.RotationYToRef = function (angle, result) {
  72733. var s = Math.sin(angle);
  72734. var c = Math.cos(angle);
  72735. 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);
  72736. result._updateIdentityStatus(c === 1 && s === 0);
  72737. };
  72738. /**
  72739. * Creates a new rotation matrix for "angle" radians around the Z axis
  72740. * @param angle defines the angle (in radians) to use
  72741. * @return the new matrix
  72742. */
  72743. Matrix.RotationZ = function (angle) {
  72744. var result = new Matrix();
  72745. Matrix.RotationZToRef(angle, result);
  72746. return result;
  72747. };
  72748. /**
  72749. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72750. * @param angle defines the angle (in radians) to use
  72751. * @param result defines the target matrix
  72752. */
  72753. Matrix.RotationZToRef = function (angle, result) {
  72754. var s = Math.sin(angle);
  72755. var c = Math.cos(angle);
  72756. 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);
  72757. result._updateIdentityStatus(c === 1 && s === 0);
  72758. };
  72759. /**
  72760. * Creates a new rotation matrix for "angle" radians around the given axis
  72761. * @param axis defines the axis to use
  72762. * @param angle defines the angle (in radians) to use
  72763. * @return the new matrix
  72764. */
  72765. Matrix.RotationAxis = function (axis, angle) {
  72766. var result = new Matrix();
  72767. Matrix.RotationAxisToRef(axis, angle, result);
  72768. return result;
  72769. };
  72770. /**
  72771. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72772. * @param axis defines the axis to use
  72773. * @param angle defines the angle (in radians) to use
  72774. * @param result defines the target matrix
  72775. */
  72776. Matrix.RotationAxisToRef = function (axis, angle, result) {
  72777. var s = Math.sin(-angle);
  72778. var c = Math.cos(-angle);
  72779. var c1 = 1 - c;
  72780. axis.normalize();
  72781. var m = result._m;
  72782. m[0] = (axis.x * axis.x) * c1 + c;
  72783. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  72784. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  72785. m[3] = 0.0;
  72786. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  72787. m[5] = (axis.y * axis.y) * c1 + c;
  72788. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  72789. m[7] = 0.0;
  72790. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  72791. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  72792. m[10] = (axis.z * axis.z) * c1 + c;
  72793. m[11] = 0.0;
  72794. m[12] = 0.0;
  72795. m[13] = 0.0;
  72796. m[14] = 0.0;
  72797. m[15] = 1.0;
  72798. result._markAsUpdated();
  72799. };
  72800. /**
  72801. * Creates a rotation matrix
  72802. * @param yaw defines the yaw angle in radians (Y axis)
  72803. * @param pitch defines the pitch angle in radians (X axis)
  72804. * @param roll defines the roll angle in radians (X axis)
  72805. * @returns the new rotation matrix
  72806. */
  72807. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  72808. var result = new Matrix();
  72809. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  72810. return result;
  72811. };
  72812. /**
  72813. * Creates a rotation matrix and stores it in a given matrix
  72814. * @param yaw defines the yaw angle in radians (Y axis)
  72815. * @param pitch defines the pitch angle in radians (X axis)
  72816. * @param roll defines the roll angle in radians (X axis)
  72817. * @param result defines the target matrix
  72818. */
  72819. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  72820. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  72821. MathTmp.Quaternion[0].toRotationMatrix(result);
  72822. };
  72823. /**
  72824. * Creates a scaling matrix
  72825. * @param x defines the scale factor on X axis
  72826. * @param y defines the scale factor on Y axis
  72827. * @param z defines the scale factor on Z axis
  72828. * @returns the new matrix
  72829. */
  72830. Matrix.Scaling = function (x, y, z) {
  72831. var result = new Matrix();
  72832. Matrix.ScalingToRef(x, y, z, result);
  72833. return result;
  72834. };
  72835. /**
  72836. * Creates a scaling matrix and stores it in a given matrix
  72837. * @param x defines the scale factor on X axis
  72838. * @param y defines the scale factor on Y axis
  72839. * @param z defines the scale factor on Z axis
  72840. * @param result defines the target matrix
  72841. */
  72842. Matrix.ScalingToRef = function (x, y, z, result) {
  72843. 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);
  72844. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  72845. };
  72846. /**
  72847. * Creates a translation matrix
  72848. * @param x defines the translation on X axis
  72849. * @param y defines the translation on Y axis
  72850. * @param z defines the translationon Z axis
  72851. * @returns the new matrix
  72852. */
  72853. Matrix.Translation = function (x, y, z) {
  72854. var result = new Matrix();
  72855. Matrix.TranslationToRef(x, y, z, result);
  72856. return result;
  72857. };
  72858. /**
  72859. * Creates a translation matrix and stores it in a given matrix
  72860. * @param x defines the translation on X axis
  72861. * @param y defines the translation on Y axis
  72862. * @param z defines the translationon Z axis
  72863. * @param result defines the target matrix
  72864. */
  72865. Matrix.TranslationToRef = function (x, y, z, result) {
  72866. 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);
  72867. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  72868. };
  72869. /**
  72870. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72871. * @param startValue defines the start value
  72872. * @param endValue defines the end value
  72873. * @param gradient defines the gradient factor
  72874. * @returns the new matrix
  72875. */
  72876. Matrix.Lerp = function (startValue, endValue, gradient) {
  72877. var result = new Matrix();
  72878. Matrix.LerpToRef(startValue, endValue, gradient, result);
  72879. return result;
  72880. };
  72881. /**
  72882. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72883. * @param startValue defines the start value
  72884. * @param endValue defines the end value
  72885. * @param gradient defines the gradient factor
  72886. * @param result defines the Matrix object where to store data
  72887. */
  72888. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  72889. var resultM = result._m;
  72890. var startM = startValue.m;
  72891. var endM = endValue.m;
  72892. for (var index = 0; index < 16; index++) {
  72893. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  72894. }
  72895. result._markAsUpdated();
  72896. };
  72897. /**
  72898. * Builds a new matrix whose values are computed by:
  72899. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72900. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72901. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72902. * @param startValue defines the first matrix
  72903. * @param endValue defines the second matrix
  72904. * @param gradient defines the gradient between the two matrices
  72905. * @returns the new matrix
  72906. */
  72907. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  72908. var result = new Matrix();
  72909. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  72910. return result;
  72911. };
  72912. /**
  72913. * Update a matrix to values which are computed by:
  72914. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72915. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72916. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72917. * @param startValue defines the first matrix
  72918. * @param endValue defines the second matrix
  72919. * @param gradient defines the gradient between the two matrices
  72920. * @param result defines the target matrix
  72921. */
  72922. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  72923. var startScale = MathTmp.Vector3[0];
  72924. var startRotation = MathTmp.Quaternion[0];
  72925. var startTranslation = MathTmp.Vector3[1];
  72926. startValue.decompose(startScale, startRotation, startTranslation);
  72927. var endScale = MathTmp.Vector3[2];
  72928. var endRotation = MathTmp.Quaternion[1];
  72929. var endTranslation = MathTmp.Vector3[3];
  72930. endValue.decompose(endScale, endRotation, endTranslation);
  72931. var resultScale = MathTmp.Vector3[4];
  72932. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  72933. var resultRotation = MathTmp.Quaternion[2];
  72934. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  72935. var resultTranslation = MathTmp.Vector3[5];
  72936. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  72937. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  72938. };
  72939. /**
  72940. * 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"
  72941. * This function works in left handed mode
  72942. * @param eye defines the final position of the entity
  72943. * @param target defines where the entity should look at
  72944. * @param up defines the up vector for the entity
  72945. * @returns the new matrix
  72946. */
  72947. Matrix.LookAtLH = function (eye, target, up) {
  72948. var result = new Matrix();
  72949. Matrix.LookAtLHToRef(eye, target, up, result);
  72950. return result;
  72951. };
  72952. /**
  72953. * 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".
  72954. * This function works in left handed mode
  72955. * @param eye defines the final position of the entity
  72956. * @param target defines where the entity should look at
  72957. * @param up defines the up vector for the entity
  72958. * @param result defines the target matrix
  72959. */
  72960. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  72961. var xAxis = MathTmp.Vector3[0];
  72962. var yAxis = MathTmp.Vector3[1];
  72963. var zAxis = MathTmp.Vector3[2];
  72964. // Z axis
  72965. target.subtractToRef(eye, zAxis);
  72966. zAxis.normalize();
  72967. // X axis
  72968. Vector3.CrossToRef(up, zAxis, xAxis);
  72969. var xSquareLength = xAxis.lengthSquared();
  72970. if (xSquareLength === 0) {
  72971. xAxis.x = 1.0;
  72972. }
  72973. else {
  72974. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72975. }
  72976. // Y axis
  72977. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72978. yAxis.normalize();
  72979. // Eye angles
  72980. var ex = -Vector3.Dot(xAxis, eye);
  72981. var ey = -Vector3.Dot(yAxis, eye);
  72982. var ez = -Vector3.Dot(zAxis, eye);
  72983. 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);
  72984. };
  72985. /**
  72986. * 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"
  72987. * This function works in right handed mode
  72988. * @param eye defines the final position of the entity
  72989. * @param target defines where the entity should look at
  72990. * @param up defines the up vector for the entity
  72991. * @returns the new matrix
  72992. */
  72993. Matrix.LookAtRH = function (eye, target, up) {
  72994. var result = new Matrix();
  72995. Matrix.LookAtRHToRef(eye, target, up, result);
  72996. return result;
  72997. };
  72998. /**
  72999. * 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".
  73000. * This function works in right handed mode
  73001. * @param eye defines the final position of the entity
  73002. * @param target defines where the entity should look at
  73003. * @param up defines the up vector for the entity
  73004. * @param result defines the target matrix
  73005. */
  73006. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  73007. var xAxis = MathTmp.Vector3[0];
  73008. var yAxis = MathTmp.Vector3[1];
  73009. var zAxis = MathTmp.Vector3[2];
  73010. // Z axis
  73011. eye.subtractToRef(target, zAxis);
  73012. zAxis.normalize();
  73013. // X axis
  73014. Vector3.CrossToRef(up, zAxis, xAxis);
  73015. var xSquareLength = xAxis.lengthSquared();
  73016. if (xSquareLength === 0) {
  73017. xAxis.x = 1.0;
  73018. }
  73019. else {
  73020. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  73021. }
  73022. // Y axis
  73023. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  73024. yAxis.normalize();
  73025. // Eye angles
  73026. var ex = -Vector3.Dot(xAxis, eye);
  73027. var ey = -Vector3.Dot(yAxis, eye);
  73028. var ez = -Vector3.Dot(zAxis, eye);
  73029. 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);
  73030. };
  73031. /**
  73032. * Create a left-handed orthographic projection matrix
  73033. * @param width defines the viewport width
  73034. * @param height defines the viewport height
  73035. * @param znear defines the near clip plane
  73036. * @param zfar defines the far clip plane
  73037. * @returns a new matrix as a left-handed orthographic projection matrix
  73038. */
  73039. Matrix.OrthoLH = function (width, height, znear, zfar) {
  73040. var matrix = new Matrix();
  73041. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  73042. return matrix;
  73043. };
  73044. /**
  73045. * Store a left-handed orthographic projection to a given matrix
  73046. * @param width defines the viewport width
  73047. * @param height defines the viewport height
  73048. * @param znear defines the near clip plane
  73049. * @param zfar defines the far clip plane
  73050. * @param result defines the target matrix
  73051. */
  73052. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  73053. var n = znear;
  73054. var f = zfar;
  73055. var a = 2.0 / width;
  73056. var b = 2.0 / height;
  73057. var c = 2.0 / (f - n);
  73058. var d = -(f + n) / (f - n);
  73059. 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);
  73060. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  73061. };
  73062. /**
  73063. * Create a left-handed orthographic projection matrix
  73064. * @param left defines the viewport left coordinate
  73065. * @param right defines the viewport right coordinate
  73066. * @param bottom defines the viewport bottom coordinate
  73067. * @param top defines the viewport top coordinate
  73068. * @param znear defines the near clip plane
  73069. * @param zfar defines the far clip plane
  73070. * @returns a new matrix as a left-handed orthographic projection matrix
  73071. */
  73072. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  73073. var matrix = new Matrix();
  73074. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  73075. return matrix;
  73076. };
  73077. /**
  73078. * Stores a left-handed orthographic projection into a given matrix
  73079. * @param left defines the viewport left coordinate
  73080. * @param right defines the viewport right coordinate
  73081. * @param bottom defines the viewport bottom coordinate
  73082. * @param top defines the viewport top coordinate
  73083. * @param znear defines the near clip plane
  73084. * @param zfar defines the far clip plane
  73085. * @param result defines the target matrix
  73086. */
  73087. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73088. var n = znear;
  73089. var f = zfar;
  73090. var a = 2.0 / (right - left);
  73091. var b = 2.0 / (top - bottom);
  73092. var c = 2.0 / (f - n);
  73093. var d = -(f + n) / (f - n);
  73094. var i0 = (left + right) / (left - right);
  73095. var i1 = (top + bottom) / (bottom - top);
  73096. 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);
  73097. result._markAsUpdated();
  73098. };
  73099. /**
  73100. * Creates a right-handed orthographic projection matrix
  73101. * @param left defines the viewport left coordinate
  73102. * @param right defines the viewport right coordinate
  73103. * @param bottom defines the viewport bottom coordinate
  73104. * @param top defines the viewport top coordinate
  73105. * @param znear defines the near clip plane
  73106. * @param zfar defines the far clip plane
  73107. * @returns a new matrix as a right-handed orthographic projection matrix
  73108. */
  73109. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  73110. var matrix = new Matrix();
  73111. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  73112. return matrix;
  73113. };
  73114. /**
  73115. * Stores a right-handed orthographic projection into a given matrix
  73116. * @param left defines the viewport left coordinate
  73117. * @param right defines the viewport right coordinate
  73118. * @param bottom defines the viewport bottom coordinate
  73119. * @param top defines the viewport top coordinate
  73120. * @param znear defines the near clip plane
  73121. * @param zfar defines the far clip plane
  73122. * @param result defines the target matrix
  73123. */
  73124. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73125. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  73126. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  73127. };
  73128. /**
  73129. * Creates a left-handed perspective projection matrix
  73130. * @param width defines the viewport width
  73131. * @param height defines the viewport height
  73132. * @param znear defines the near clip plane
  73133. * @param zfar defines the far clip plane
  73134. * @returns a new matrix as a left-handed perspective projection matrix
  73135. */
  73136. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  73137. var matrix = new Matrix();
  73138. var n = znear;
  73139. var f = zfar;
  73140. var a = 2.0 * n / width;
  73141. var b = 2.0 * n / height;
  73142. var c = (f + n) / (f - n);
  73143. var d = -2.0 * f * n / (f - n);
  73144. 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);
  73145. matrix._updateIdentityStatus(false);
  73146. return matrix;
  73147. };
  73148. /**
  73149. * Creates a left-handed perspective projection matrix
  73150. * @param fov defines the horizontal field of view
  73151. * @param aspect defines the aspect ratio
  73152. * @param znear defines the near clip plane
  73153. * @param zfar defines the far clip plane
  73154. * @returns a new matrix as a left-handed perspective projection matrix
  73155. */
  73156. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  73157. var matrix = new Matrix();
  73158. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  73159. return matrix;
  73160. };
  73161. /**
  73162. * Stores a left-handed perspective projection into a given matrix
  73163. * @param fov defines the horizontal field of view
  73164. * @param aspect defines the aspect ratio
  73165. * @param znear defines the near clip plane
  73166. * @param zfar defines the far clip plane
  73167. * @param result defines the target matrix
  73168. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73169. */
  73170. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73171. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73172. var n = znear;
  73173. var f = zfar;
  73174. var t = 1.0 / (Math.tan(fov * 0.5));
  73175. var a = isVerticalFovFixed ? (t / aspect) : t;
  73176. var b = isVerticalFovFixed ? t : (t * aspect);
  73177. var c = (f + n) / (f - n);
  73178. var d = -2.0 * f * n / (f - n);
  73179. 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);
  73180. result._updateIdentityStatus(false);
  73181. };
  73182. /**
  73183. * Creates a right-handed perspective projection matrix
  73184. * @param fov defines the horizontal field of view
  73185. * @param aspect defines the aspect ratio
  73186. * @param znear defines the near clip plane
  73187. * @param zfar defines the far clip plane
  73188. * @returns a new matrix as a right-handed perspective projection matrix
  73189. */
  73190. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  73191. var matrix = new Matrix();
  73192. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  73193. return matrix;
  73194. };
  73195. /**
  73196. * Stores a right-handed perspective projection into a given matrix
  73197. * @param fov defines the horizontal field of view
  73198. * @param aspect defines the aspect ratio
  73199. * @param znear defines the near clip plane
  73200. * @param zfar defines the far clip plane
  73201. * @param result defines the target matrix
  73202. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73203. */
  73204. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73205. //alternatively this could be expressed as:
  73206. // m = PerspectiveFovLHToRef
  73207. // m[10] *= -1.0;
  73208. // m[11] *= -1.0;
  73209. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73210. var n = znear;
  73211. var f = zfar;
  73212. var t = 1.0 / (Math.tan(fov * 0.5));
  73213. var a = isVerticalFovFixed ? (t / aspect) : t;
  73214. var b = isVerticalFovFixed ? t : (t * aspect);
  73215. var c = -(f + n) / (f - n);
  73216. var d = -2 * f * n / (f - n);
  73217. 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);
  73218. result._updateIdentityStatus(false);
  73219. };
  73220. /**
  73221. * Stores a perspective projection for WebVR info a given matrix
  73222. * @param fov defines the field of view
  73223. * @param znear defines the near clip plane
  73224. * @param zfar defines the far clip plane
  73225. * @param result defines the target matrix
  73226. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73227. */
  73228. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  73229. if (rightHanded === void 0) { rightHanded = false; }
  73230. var rightHandedFactor = rightHanded ? -1 : 1;
  73231. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  73232. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  73233. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  73234. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  73235. var xScale = 2.0 / (leftTan + rightTan);
  73236. var yScale = 2.0 / (upTan + downTan);
  73237. var m = result._m;
  73238. m[0] = xScale;
  73239. m[1] = m[2] = m[3] = m[4] = 0.0;
  73240. m[5] = yScale;
  73241. m[6] = m[7] = 0.0;
  73242. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  73243. m[9] = -((upTan - downTan) * yScale * 0.5);
  73244. m[10] = -zfar / (znear - zfar);
  73245. m[11] = 1.0 * rightHandedFactor;
  73246. m[12] = m[13] = m[15] = 0.0;
  73247. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  73248. result._markAsUpdated();
  73249. };
  73250. /**
  73251. * Computes a complete transformation matrix
  73252. * @param viewport defines the viewport to use
  73253. * @param world defines the world matrix
  73254. * @param view defines the view matrix
  73255. * @param projection defines the projection matrix
  73256. * @param zmin defines the near clip plane
  73257. * @param zmax defines the far clip plane
  73258. * @returns the transformation matrix
  73259. */
  73260. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  73261. var cw = viewport.width;
  73262. var ch = viewport.height;
  73263. var cx = viewport.x;
  73264. var cy = viewport.y;
  73265. 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);
  73266. var matrix = MathTmp.Matrix[0];
  73267. world.multiplyToRef(view, matrix);
  73268. matrix.multiplyToRef(projection, matrix);
  73269. return matrix.multiply(viewportMatrix);
  73270. };
  73271. /**
  73272. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73273. * @param matrix defines the matrix to use
  73274. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73275. */
  73276. Matrix.GetAsMatrix2x2 = function (matrix) {
  73277. var m = matrix.m;
  73278. return new Float32Array([m[0], m[1], m[4], m[5]]);
  73279. };
  73280. /**
  73281. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73282. * @param matrix defines the matrix to use
  73283. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73284. */
  73285. Matrix.GetAsMatrix3x3 = function (matrix) {
  73286. var m = matrix.m;
  73287. return new Float32Array([
  73288. m[0], m[1], m[2],
  73289. m[4], m[5], m[6],
  73290. m[8], m[9], m[10]
  73291. ]);
  73292. };
  73293. /**
  73294. * Compute the transpose of a given matrix
  73295. * @param matrix defines the matrix to transpose
  73296. * @returns the new matrix
  73297. */
  73298. Matrix.Transpose = function (matrix) {
  73299. var result = new Matrix();
  73300. Matrix.TransposeToRef(matrix, result);
  73301. return result;
  73302. };
  73303. /**
  73304. * Compute the transpose of a matrix and store it in a target matrix
  73305. * @param matrix defines the matrix to transpose
  73306. * @param result defines the target matrix
  73307. */
  73308. Matrix.TransposeToRef = function (matrix, result) {
  73309. var rm = result._m;
  73310. var mm = matrix.m;
  73311. rm[0] = mm[0];
  73312. rm[1] = mm[4];
  73313. rm[2] = mm[8];
  73314. rm[3] = mm[12];
  73315. rm[4] = mm[1];
  73316. rm[5] = mm[5];
  73317. rm[6] = mm[9];
  73318. rm[7] = mm[13];
  73319. rm[8] = mm[2];
  73320. rm[9] = mm[6];
  73321. rm[10] = mm[10];
  73322. rm[11] = mm[14];
  73323. rm[12] = mm[3];
  73324. rm[13] = mm[7];
  73325. rm[14] = mm[11];
  73326. rm[15] = mm[15];
  73327. // identity-ness does not change when transposing
  73328. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  73329. };
  73330. /**
  73331. * Computes a reflection matrix from a plane
  73332. * @param plane defines the reflection plane
  73333. * @returns a new matrix
  73334. */
  73335. Matrix.Reflection = function (plane) {
  73336. var matrix = new Matrix();
  73337. Matrix.ReflectionToRef(plane, matrix);
  73338. return matrix;
  73339. };
  73340. /**
  73341. * Computes a reflection matrix from a plane
  73342. * @param plane defines the reflection plane
  73343. * @param result defines the target matrix
  73344. */
  73345. Matrix.ReflectionToRef = function (plane, result) {
  73346. plane.normalize();
  73347. var x = plane.normal.x;
  73348. var y = plane.normal.y;
  73349. var z = plane.normal.z;
  73350. var temp = -2 * x;
  73351. var temp2 = -2 * y;
  73352. var temp3 = -2 * z;
  73353. 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);
  73354. };
  73355. /**
  73356. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73357. * @param xaxis defines the value of the 1st axis
  73358. * @param yaxis defines the value of the 2nd axis
  73359. * @param zaxis defines the value of the 3rd axis
  73360. * @param result defines the target matrix
  73361. */
  73362. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  73363. 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);
  73364. };
  73365. /**
  73366. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73367. * @param quat defines the quaternion to use
  73368. * @param result defines the target matrix
  73369. */
  73370. Matrix.FromQuaternionToRef = function (quat, result) {
  73371. var xx = quat.x * quat.x;
  73372. var yy = quat.y * quat.y;
  73373. var zz = quat.z * quat.z;
  73374. var xy = quat.x * quat.y;
  73375. var zw = quat.z * quat.w;
  73376. var zx = quat.z * quat.x;
  73377. var yw = quat.y * quat.w;
  73378. var yz = quat.y * quat.z;
  73379. var xw = quat.x * quat.w;
  73380. result._m[0] = 1.0 - (2.0 * (yy + zz));
  73381. result._m[1] = 2.0 * (xy + zw);
  73382. result._m[2] = 2.0 * (zx - yw);
  73383. result._m[3] = 0.0;
  73384. result._m[4] = 2.0 * (xy - zw);
  73385. result._m[5] = 1.0 - (2.0 * (zz + xx));
  73386. result._m[6] = 2.0 * (yz + xw);
  73387. result._m[7] = 0.0;
  73388. result._m[8] = 2.0 * (zx + yw);
  73389. result._m[9] = 2.0 * (yz - xw);
  73390. result._m[10] = 1.0 - (2.0 * (yy + xx));
  73391. result._m[11] = 0.0;
  73392. result._m[12] = 0.0;
  73393. result._m[13] = 0.0;
  73394. result._m[14] = 0.0;
  73395. result._m[15] = 1.0;
  73396. result._markAsUpdated();
  73397. };
  73398. Matrix._updateFlagSeed = 0;
  73399. Matrix._identityReadOnly = Matrix.Identity();
  73400. return Matrix;
  73401. }());
  73402. /**
  73403. * Represens a plane by the equation ax + by + cz + d = 0
  73404. */
  73405. var Plane = /** @class */ (function () {
  73406. /**
  73407. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73408. * @param a a component of the plane
  73409. * @param b b component of the plane
  73410. * @param c c component of the plane
  73411. * @param d d component of the plane
  73412. */
  73413. function Plane(a, b, c, d) {
  73414. this.normal = new Vector3(a, b, c);
  73415. this.d = d;
  73416. }
  73417. /**
  73418. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73419. */
  73420. Plane.prototype.asArray = function () {
  73421. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  73422. };
  73423. // Methods
  73424. /**
  73425. * @returns a new plane copied from the current Plane.
  73426. */
  73427. Plane.prototype.clone = function () {
  73428. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  73429. };
  73430. /**
  73431. * @returns the string "Plane".
  73432. */
  73433. Plane.prototype.getClassName = function () {
  73434. return "Plane";
  73435. };
  73436. /**
  73437. * @returns the Plane hash code.
  73438. */
  73439. Plane.prototype.getHashCode = function () {
  73440. var hash = this.normal.getHashCode();
  73441. hash = (hash * 397) ^ (this.d || 0);
  73442. return hash;
  73443. };
  73444. /**
  73445. * Normalize the current Plane in place.
  73446. * @returns the updated Plane.
  73447. */
  73448. Plane.prototype.normalize = function () {
  73449. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  73450. var magnitude = 0.0;
  73451. if (norm !== 0) {
  73452. magnitude = 1.0 / norm;
  73453. }
  73454. this.normal.x *= magnitude;
  73455. this.normal.y *= magnitude;
  73456. this.normal.z *= magnitude;
  73457. this.d *= magnitude;
  73458. return this;
  73459. };
  73460. /**
  73461. * Applies a transformation the plane and returns the result
  73462. * @param transformation the transformation matrix to be applied to the plane
  73463. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73464. */
  73465. Plane.prototype.transform = function (transformation) {
  73466. var transposedMatrix = MathTmp.Matrix[0];
  73467. Matrix.TransposeToRef(transformation, transposedMatrix);
  73468. var m = transposedMatrix.m;
  73469. var x = this.normal.x;
  73470. var y = this.normal.y;
  73471. var z = this.normal.z;
  73472. var d = this.d;
  73473. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  73474. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  73475. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  73476. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  73477. return new Plane(normalX, normalY, normalZ, finalD);
  73478. };
  73479. /**
  73480. * Calcualtte the dot product between the point and the plane normal
  73481. * @param point point to calculate the dot product with
  73482. * @returns the dot product (float) of the point coordinates and the plane normal.
  73483. */
  73484. Plane.prototype.dotCoordinate = function (point) {
  73485. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  73486. };
  73487. /**
  73488. * Updates the current Plane from the plane defined by the three given points.
  73489. * @param point1 one of the points used to contruct the plane
  73490. * @param point2 one of the points used to contruct the plane
  73491. * @param point3 one of the points used to contruct the plane
  73492. * @returns the updated Plane.
  73493. */
  73494. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  73495. var x1 = point2.x - point1.x;
  73496. var y1 = point2.y - point1.y;
  73497. var z1 = point2.z - point1.z;
  73498. var x2 = point3.x - point1.x;
  73499. var y2 = point3.y - point1.y;
  73500. var z2 = point3.z - point1.z;
  73501. var yz = (y1 * z2) - (z1 * y2);
  73502. var xz = (z1 * x2) - (x1 * z2);
  73503. var xy = (x1 * y2) - (y1 * x2);
  73504. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  73505. var invPyth;
  73506. if (pyth !== 0) {
  73507. invPyth = 1.0 / pyth;
  73508. }
  73509. else {
  73510. invPyth = 0.0;
  73511. }
  73512. this.normal.x = yz * invPyth;
  73513. this.normal.y = xz * invPyth;
  73514. this.normal.z = xy * invPyth;
  73515. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  73516. return this;
  73517. };
  73518. /**
  73519. * Checks if the plane is facing a given direction
  73520. * @param direction the direction to check if the plane is facing
  73521. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73522. * @returns True is the vector "direction" is the same side than the plane normal.
  73523. */
  73524. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  73525. var dot = Vector3.Dot(this.normal, direction);
  73526. return (dot <= epsilon);
  73527. };
  73528. /**
  73529. * Calculates the distance to a point
  73530. * @param point point to calculate distance to
  73531. * @returns the signed distance (float) from the given point to the Plane.
  73532. */
  73533. Plane.prototype.signedDistanceTo = function (point) {
  73534. return Vector3.Dot(point, this.normal) + this.d;
  73535. };
  73536. // Statics
  73537. /**
  73538. * Creates a plane from an array
  73539. * @param array the array to create a plane from
  73540. * @returns a new Plane from the given array.
  73541. */
  73542. Plane.FromArray = function (array) {
  73543. return new Plane(array[0], array[1], array[2], array[3]);
  73544. };
  73545. /**
  73546. * Creates a plane from three points
  73547. * @param point1 point used to create the plane
  73548. * @param point2 point used to create the plane
  73549. * @param point3 point used to create the plane
  73550. * @returns a new Plane defined by the three given points.
  73551. */
  73552. Plane.FromPoints = function (point1, point2, point3) {
  73553. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73554. result.copyFromPoints(point1, point2, point3);
  73555. return result;
  73556. };
  73557. /**
  73558. * Creates a plane from an origin point and a normal
  73559. * @param origin origin of the plane to be constructed
  73560. * @param normal normal of the plane to be constructed
  73561. * @returns a new Plane the normal vector to this plane at the given origin point.
  73562. * Note : the vector "normal" is updated because normalized.
  73563. */
  73564. Plane.FromPositionAndNormal = function (origin, normal) {
  73565. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73566. normal.normalize();
  73567. result.normal = normal;
  73568. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73569. return result;
  73570. };
  73571. /**
  73572. * Calculates the distance from a plane and a point
  73573. * @param origin origin of the plane to be constructed
  73574. * @param normal normal of the plane to be constructed
  73575. * @param point point to calculate distance to
  73576. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73577. */
  73578. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  73579. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73580. return Vector3.Dot(point, normal) + d;
  73581. };
  73582. return Plane;
  73583. }());
  73584. /**
  73585. * Class used to represent a viewport on screen
  73586. */
  73587. var Viewport = /** @class */ (function () {
  73588. /**
  73589. * Creates a Viewport object located at (x, y) and sized (width, height)
  73590. * @param x defines viewport left coordinate
  73591. * @param y defines viewport top coordinate
  73592. * @param width defines the viewport width
  73593. * @param height defines the viewport height
  73594. */
  73595. function Viewport(
  73596. /** viewport left coordinate */
  73597. x,
  73598. /** viewport top coordinate */
  73599. y,
  73600. /**viewport width */
  73601. width,
  73602. /** viewport height */
  73603. height) {
  73604. this.x = x;
  73605. this.y = y;
  73606. this.width = width;
  73607. this.height = height;
  73608. }
  73609. /**
  73610. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  73611. * @param renderWidth defines the rendering width
  73612. * @param renderHeight defines the rendering height
  73613. * @returns a new Viewport
  73614. */
  73615. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  73616. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  73617. };
  73618. /**
  73619. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  73620. * @param renderWidth defines the rendering width
  73621. * @param renderHeight defines the rendering height
  73622. * @param ref defines the target viewport
  73623. * @returns the current viewport
  73624. */
  73625. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  73626. ref.x = this.x * renderWidth;
  73627. ref.y = this.y * renderHeight;
  73628. ref.width = this.width * renderWidth;
  73629. ref.height = this.height * renderHeight;
  73630. return this;
  73631. };
  73632. /**
  73633. * Returns a new Viewport copied from the current one
  73634. * @returns a new Viewport
  73635. */
  73636. Viewport.prototype.clone = function () {
  73637. return new Viewport(this.x, this.y, this.width, this.height);
  73638. };
  73639. return Viewport;
  73640. }());
  73641. /**
  73642. * Reprasents a camera frustum
  73643. */
  73644. var Frustum = /** @class */ (function () {
  73645. function Frustum() {
  73646. }
  73647. /**
  73648. * Gets the planes representing the frustum
  73649. * @param transform matrix to be applied to the returned planes
  73650. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  73651. */
  73652. Frustum.GetPlanes = function (transform) {
  73653. var frustumPlanes = [];
  73654. for (var index = 0; index < 6; index++) {
  73655. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  73656. }
  73657. Frustum.GetPlanesToRef(transform, frustumPlanes);
  73658. return frustumPlanes;
  73659. };
  73660. /**
  73661. * Gets the near frustum plane transformed by the transform matrix
  73662. * @param transform transformation matrix to be applied to the resulting frustum plane
  73663. * @param frustumPlane the resuling frustum plane
  73664. */
  73665. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  73666. var m = transform.m;
  73667. frustumPlane.normal.x = m[3] + m[2];
  73668. frustumPlane.normal.y = m[7] + m[6];
  73669. frustumPlane.normal.z = m[11] + m[10];
  73670. frustumPlane.d = m[15] + m[14];
  73671. frustumPlane.normalize();
  73672. };
  73673. /**
  73674. * Gets the far frustum plane transformed by the transform matrix
  73675. * @param transform transformation matrix to be applied to the resulting frustum plane
  73676. * @param frustumPlane the resuling frustum plane
  73677. */
  73678. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  73679. var m = transform.m;
  73680. frustumPlane.normal.x = m[3] - m[2];
  73681. frustumPlane.normal.y = m[7] - m[6];
  73682. frustumPlane.normal.z = m[11] - m[10];
  73683. frustumPlane.d = m[15] - m[14];
  73684. frustumPlane.normalize();
  73685. };
  73686. /**
  73687. * Gets the left frustum plane transformed by the transform matrix
  73688. * @param transform transformation matrix to be applied to the resulting frustum plane
  73689. * @param frustumPlane the resuling frustum plane
  73690. */
  73691. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  73692. var m = transform.m;
  73693. frustumPlane.normal.x = m[3] + m[0];
  73694. frustumPlane.normal.y = m[7] + m[4];
  73695. frustumPlane.normal.z = m[11] + m[8];
  73696. frustumPlane.d = m[15] + m[12];
  73697. frustumPlane.normalize();
  73698. };
  73699. /**
  73700. * Gets the right frustum plane transformed by the transform matrix
  73701. * @param transform transformation matrix to be applied to the resulting frustum plane
  73702. * @param frustumPlane the resuling frustum plane
  73703. */
  73704. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  73705. var m = transform.m;
  73706. frustumPlane.normal.x = m[3] - m[0];
  73707. frustumPlane.normal.y = m[7] - m[4];
  73708. frustumPlane.normal.z = m[11] - m[8];
  73709. frustumPlane.d = m[15] - m[12];
  73710. frustumPlane.normalize();
  73711. };
  73712. /**
  73713. * Gets the top frustum plane transformed by the transform matrix
  73714. * @param transform transformation matrix to be applied to the resulting frustum plane
  73715. * @param frustumPlane the resuling frustum plane
  73716. */
  73717. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  73718. var m = transform.m;
  73719. frustumPlane.normal.x = m[3] - m[1];
  73720. frustumPlane.normal.y = m[7] - m[5];
  73721. frustumPlane.normal.z = m[11] - m[9];
  73722. frustumPlane.d = m[15] - m[13];
  73723. frustumPlane.normalize();
  73724. };
  73725. /**
  73726. * Gets the bottom frustum plane transformed by the transform matrix
  73727. * @param transform transformation matrix to be applied to the resulting frustum plane
  73728. * @param frustumPlane the resuling frustum plane
  73729. */
  73730. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  73731. var m = transform.m;
  73732. frustumPlane.normal.x = m[3] + m[1];
  73733. frustumPlane.normal.y = m[7] + m[5];
  73734. frustumPlane.normal.z = m[11] + m[9];
  73735. frustumPlane.d = m[15] + m[13];
  73736. frustumPlane.normalize();
  73737. };
  73738. /**
  73739. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  73740. * @param transform transformation matrix to be applied to the resulting frustum planes
  73741. * @param frustumPlanes the resuling frustum planes
  73742. */
  73743. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  73744. // Near
  73745. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  73746. // Far
  73747. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  73748. // Left
  73749. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  73750. // Right
  73751. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  73752. // Top
  73753. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  73754. // Bottom
  73755. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  73756. };
  73757. return Frustum;
  73758. }());
  73759. /** Defines supported spaces */
  73760. var Space;
  73761. (function (Space) {
  73762. /** Local (object) space */
  73763. Space[Space["LOCAL"] = 0] = "LOCAL";
  73764. /** World space */
  73765. Space[Space["WORLD"] = 1] = "WORLD";
  73766. /** Bone space */
  73767. Space[Space["BONE"] = 2] = "BONE";
  73768. })(Space || (Space = {}));
  73769. /** Defines the 3 main axes */
  73770. var Axis = /** @class */ (function () {
  73771. function Axis() {
  73772. }
  73773. /** X axis */
  73774. Axis.X = new Vector3(1.0, 0.0, 0.0);
  73775. /** Y axis */
  73776. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  73777. /** Z axis */
  73778. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  73779. return Axis;
  73780. }());
  73781. /** Class used to represent a Bezier curve */
  73782. var BezierCurve = /** @class */ (function () {
  73783. function BezierCurve() {
  73784. }
  73785. /**
  73786. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73787. * @param t defines the time
  73788. * @param x1 defines the left coordinate on X axis
  73789. * @param y1 defines the left coordinate on Y axis
  73790. * @param x2 defines the right coordinate on X axis
  73791. * @param y2 defines the right coordinate on Y axis
  73792. * @returns the interpolated value
  73793. */
  73794. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  73795. // Extract X (which is equal to time here)
  73796. var f0 = 1 - 3 * x2 + 3 * x1;
  73797. var f1 = 3 * x2 - 6 * x1;
  73798. var f2 = 3 * x1;
  73799. var refinedT = t;
  73800. for (var i = 0; i < 5; i++) {
  73801. var refinedT2 = refinedT * refinedT;
  73802. var refinedT3 = refinedT2 * refinedT;
  73803. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  73804. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  73805. refinedT -= (x - t) * slope;
  73806. refinedT = Math.min(1, Math.max(0, refinedT));
  73807. }
  73808. // Resolve cubic bezier for the given x
  73809. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  73810. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  73811. Math.pow(refinedT, 3);
  73812. };
  73813. return BezierCurve;
  73814. }());
  73815. /**
  73816. * Defines potential orientation for back face culling
  73817. */
  73818. var Orientation;
  73819. (function (Orientation) {
  73820. /**
  73821. * Clockwise
  73822. */
  73823. Orientation[Orientation["CW"] = 0] = "CW";
  73824. /** Counter clockwise */
  73825. Orientation[Orientation["CCW"] = 1] = "CCW";
  73826. })(Orientation || (Orientation = {}));
  73827. /**
  73828. * Defines angle representation
  73829. */
  73830. var Angle = /** @class */ (function () {
  73831. /**
  73832. * Creates an Angle object of "radians" radians (float).
  73833. * @param radians the angle in radians
  73834. */
  73835. function Angle(radians) {
  73836. this._radians = radians;
  73837. if (this._radians < 0.0) {
  73838. this._radians += (2.0 * Math.PI);
  73839. }
  73840. }
  73841. /**
  73842. * Get value in degrees
  73843. * @returns the Angle value in degrees (float)
  73844. */
  73845. Angle.prototype.degrees = function () {
  73846. return this._radians * 180.0 / Math.PI;
  73847. };
  73848. /**
  73849. * Get value in radians
  73850. * @returns the Angle value in radians (float)
  73851. */
  73852. Angle.prototype.radians = function () {
  73853. return this._radians;
  73854. };
  73855. /**
  73856. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73857. * @param a defines first vector
  73858. * @param b defines second vector
  73859. * @returns a new Angle
  73860. */
  73861. Angle.BetweenTwoPoints = function (a, b) {
  73862. var delta = b.subtract(a);
  73863. var theta = Math.atan2(delta.y, delta.x);
  73864. return new Angle(theta);
  73865. };
  73866. /**
  73867. * Gets a new Angle object from the given float in radians
  73868. * @param radians defines the angle value in radians
  73869. * @returns a new Angle
  73870. */
  73871. Angle.FromRadians = function (radians) {
  73872. return new Angle(radians);
  73873. };
  73874. /**
  73875. * Gets a new Angle object from the given float in degrees
  73876. * @param degrees defines the angle value in degrees
  73877. * @returns a new Angle
  73878. */
  73879. Angle.FromDegrees = function (degrees) {
  73880. return new Angle(degrees * Math.PI / 180.0);
  73881. };
  73882. return Angle;
  73883. }());
  73884. /**
  73885. * This represents an arc in a 2d space.
  73886. */
  73887. var Arc2 = /** @class */ (function () {
  73888. /**
  73889. * Creates an Arc object from the three given points : start, middle and end.
  73890. * @param startPoint Defines the start point of the arc
  73891. * @param midPoint Defines the midlle point of the arc
  73892. * @param endPoint Defines the end point of the arc
  73893. */
  73894. function Arc2(
  73895. /** Defines the start point of the arc */
  73896. startPoint,
  73897. /** Defines the mid point of the arc */
  73898. midPoint,
  73899. /** Defines the end point of the arc */
  73900. endPoint) {
  73901. this.startPoint = startPoint;
  73902. this.midPoint = midPoint;
  73903. this.endPoint = endPoint;
  73904. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  73905. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  73906. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  73907. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  73908. 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);
  73909. this.radius = this.centerPoint.subtract(this.startPoint).length();
  73910. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  73911. var a1 = this.startAngle.degrees();
  73912. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  73913. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  73914. // angles correction
  73915. if (a2 - a1 > +180.0) {
  73916. a2 -= 360.0;
  73917. }
  73918. if (a2 - a1 < -180.0) {
  73919. a2 += 360.0;
  73920. }
  73921. if (a3 - a2 > +180.0) {
  73922. a3 -= 360.0;
  73923. }
  73924. if (a3 - a2 < -180.0) {
  73925. a3 += 360.0;
  73926. }
  73927. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  73928. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  73929. }
  73930. return Arc2;
  73931. }());
  73932. /**
  73933. * Represents a 2D path made up of multiple 2D points
  73934. */
  73935. var Path2 = /** @class */ (function () {
  73936. /**
  73937. * Creates a Path2 object from the starting 2D coordinates x and y.
  73938. * @param x the starting points x value
  73939. * @param y the starting points y value
  73940. */
  73941. function Path2(x, y) {
  73942. this._points = new Array();
  73943. this._length = 0.0;
  73944. /**
  73945. * If the path start and end point are the same
  73946. */
  73947. this.closed = false;
  73948. this._points.push(new Vector2(x, y));
  73949. }
  73950. /**
  73951. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73952. * @param x the added points x value
  73953. * @param y the added points y value
  73954. * @returns the updated Path2.
  73955. */
  73956. Path2.prototype.addLineTo = function (x, y) {
  73957. if (this.closed) {
  73958. return this;
  73959. }
  73960. var newPoint = new Vector2(x, y);
  73961. var previousPoint = this._points[this._points.length - 1];
  73962. this._points.push(newPoint);
  73963. this._length += newPoint.subtract(previousPoint).length();
  73964. return this;
  73965. };
  73966. /**
  73967. * 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.
  73968. * @param midX middle point x value
  73969. * @param midY middle point y value
  73970. * @param endX end point x value
  73971. * @param endY end point y value
  73972. * @param numberOfSegments (default: 36)
  73973. * @returns the updated Path2.
  73974. */
  73975. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  73976. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  73977. if (this.closed) {
  73978. return this;
  73979. }
  73980. var startPoint = this._points[this._points.length - 1];
  73981. var midPoint = new Vector2(midX, midY);
  73982. var endPoint = new Vector2(endX, endY);
  73983. var arc = new Arc2(startPoint, midPoint, endPoint);
  73984. var increment = arc.angle.radians() / numberOfSegments;
  73985. if (arc.orientation === Orientation.CW) {
  73986. increment *= -1;
  73987. }
  73988. var currentAngle = arc.startAngle.radians() + increment;
  73989. for (var i = 0; i < numberOfSegments; i++) {
  73990. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  73991. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  73992. this.addLineTo(x, y);
  73993. currentAngle += increment;
  73994. }
  73995. return this;
  73996. };
  73997. /**
  73998. * Closes the Path2.
  73999. * @returns the Path2.
  74000. */
  74001. Path2.prototype.close = function () {
  74002. this.closed = true;
  74003. return this;
  74004. };
  74005. /**
  74006. * Gets the sum of the distance between each sequential point in the path
  74007. * @returns the Path2 total length (float).
  74008. */
  74009. Path2.prototype.length = function () {
  74010. var result = this._length;
  74011. if (!this.closed) {
  74012. var lastPoint = this._points[this._points.length - 1];
  74013. var firstPoint = this._points[0];
  74014. result += (firstPoint.subtract(lastPoint).length());
  74015. }
  74016. return result;
  74017. };
  74018. /**
  74019. * Gets the points which construct the path
  74020. * @returns the Path2 internal array of points.
  74021. */
  74022. Path2.prototype.getPoints = function () {
  74023. return this._points;
  74024. };
  74025. /**
  74026. * Retreives the point at the distance aways from the starting point
  74027. * @param normalizedLengthPosition the length along the path to retreive the point from
  74028. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  74029. */
  74030. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  74031. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  74032. return Vector2.Zero();
  74033. }
  74034. var lengthPosition = normalizedLengthPosition * this.length();
  74035. var previousOffset = 0;
  74036. for (var i = 0; i < this._points.length; i++) {
  74037. var j = (i + 1) % this._points.length;
  74038. var a = this._points[i];
  74039. var b = this._points[j];
  74040. var bToA = b.subtract(a);
  74041. var nextOffset = (bToA.length() + previousOffset);
  74042. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  74043. var dir = bToA.normalize();
  74044. var localOffset = lengthPosition - previousOffset;
  74045. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  74046. }
  74047. previousOffset = nextOffset;
  74048. }
  74049. return Vector2.Zero();
  74050. };
  74051. /**
  74052. * Creates a new path starting from an x and y position
  74053. * @param x starting x value
  74054. * @param y starting y value
  74055. * @returns a new Path2 starting at the coordinates (x, y).
  74056. */
  74057. Path2.StartingAt = function (x, y) {
  74058. return new Path2(x, y);
  74059. };
  74060. return Path2;
  74061. }());
  74062. /**
  74063. * Represents a 3D path made up of multiple 3D points
  74064. */
  74065. var Path3D = /** @class */ (function () {
  74066. /**
  74067. * new Path3D(path, normal, raw)
  74068. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  74069. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  74070. * @param path an array of Vector3, the curve axis of the Path3D
  74071. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  74072. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  74073. */
  74074. function Path3D(
  74075. /**
  74076. * an array of Vector3, the curve axis of the Path3D
  74077. */
  74078. path, firstNormal, raw) {
  74079. if (firstNormal === void 0) { firstNormal = null; }
  74080. this.path = path;
  74081. this._curve = new Array();
  74082. this._distances = new Array();
  74083. this._tangents = new Array();
  74084. this._normals = new Array();
  74085. this._binormals = new Array();
  74086. for (var p = 0; p < path.length; p++) {
  74087. this._curve[p] = path[p].clone(); // hard copy
  74088. }
  74089. this._raw = raw || false;
  74090. this._compute(firstNormal);
  74091. }
  74092. /**
  74093. * Returns the Path3D array of successive Vector3 designing its curve.
  74094. * @returns the Path3D array of successive Vector3 designing its curve.
  74095. */
  74096. Path3D.prototype.getCurve = function () {
  74097. return this._curve;
  74098. };
  74099. /**
  74100. * Returns an array populated with tangent vectors on each Path3D curve point.
  74101. * @returns an array populated with tangent vectors on each Path3D curve point.
  74102. */
  74103. Path3D.prototype.getTangents = function () {
  74104. return this._tangents;
  74105. };
  74106. /**
  74107. * Returns an array populated with normal vectors on each Path3D curve point.
  74108. * @returns an array populated with normal vectors on each Path3D curve point.
  74109. */
  74110. Path3D.prototype.getNormals = function () {
  74111. return this._normals;
  74112. };
  74113. /**
  74114. * Returns an array populated with binormal vectors on each Path3D curve point.
  74115. * @returns an array populated with binormal vectors on each Path3D curve point.
  74116. */
  74117. Path3D.prototype.getBinormals = function () {
  74118. return this._binormals;
  74119. };
  74120. /**
  74121. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74122. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74123. */
  74124. Path3D.prototype.getDistances = function () {
  74125. return this._distances;
  74126. };
  74127. /**
  74128. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74129. * @param path path which all values are copied into the curves points
  74130. * @param firstNormal which should be projected onto the curve
  74131. * @returns the same object updated.
  74132. */
  74133. Path3D.prototype.update = function (path, firstNormal) {
  74134. if (firstNormal === void 0) { firstNormal = null; }
  74135. for (var p = 0; p < path.length; p++) {
  74136. this._curve[p].x = path[p].x;
  74137. this._curve[p].y = path[p].y;
  74138. this._curve[p].z = path[p].z;
  74139. }
  74140. this._compute(firstNormal);
  74141. return this;
  74142. };
  74143. // private function compute() : computes tangents, normals and binormals
  74144. Path3D.prototype._compute = function (firstNormal) {
  74145. var l = this._curve.length;
  74146. // first and last tangents
  74147. this._tangents[0] = this._getFirstNonNullVector(0);
  74148. if (!this._raw) {
  74149. this._tangents[0].normalize();
  74150. }
  74151. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  74152. if (!this._raw) {
  74153. this._tangents[l - 1].normalize();
  74154. }
  74155. // normals and binormals at first point : arbitrary vector with _normalVector()
  74156. var tg0 = this._tangents[0];
  74157. var pp0 = this._normalVector(tg0, firstNormal);
  74158. this._normals[0] = pp0;
  74159. if (!this._raw) {
  74160. this._normals[0].normalize();
  74161. }
  74162. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  74163. if (!this._raw) {
  74164. this._binormals[0].normalize();
  74165. }
  74166. this._distances[0] = 0.0;
  74167. // normals and binormals : next points
  74168. var prev; // previous vector (segment)
  74169. var cur; // current vector (segment)
  74170. var curTang; // current tangent
  74171. // previous normal
  74172. var prevBinor; // previous binormal
  74173. for (var i = 1; i < l; i++) {
  74174. // tangents
  74175. prev = this._getLastNonNullVector(i);
  74176. if (i < l - 1) {
  74177. cur = this._getFirstNonNullVector(i);
  74178. this._tangents[i] = prev.add(cur);
  74179. this._tangents[i].normalize();
  74180. }
  74181. this._distances[i] = this._distances[i - 1] + prev.length();
  74182. // normals and binormals
  74183. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  74184. curTang = this._tangents[i];
  74185. prevBinor = this._binormals[i - 1];
  74186. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  74187. if (!this._raw) {
  74188. this._normals[i].normalize();
  74189. }
  74190. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  74191. if (!this._raw) {
  74192. this._binormals[i].normalize();
  74193. }
  74194. }
  74195. };
  74196. // private function getFirstNonNullVector(index)
  74197. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  74198. Path3D.prototype._getFirstNonNullVector = function (index) {
  74199. var i = 1;
  74200. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  74201. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  74202. i++;
  74203. nNVector = this._curve[index + i].subtract(this._curve[index]);
  74204. }
  74205. return nNVector;
  74206. };
  74207. // private function getLastNonNullVector(index)
  74208. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  74209. Path3D.prototype._getLastNonNullVector = function (index) {
  74210. var i = 1;
  74211. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  74212. while (nLVector.length() === 0 && index > i + 1) {
  74213. i++;
  74214. nLVector = this._curve[index].subtract(this._curve[index - i]);
  74215. }
  74216. return nLVector;
  74217. };
  74218. // private function normalVector(v0, vt, va) :
  74219. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  74220. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  74221. Path3D.prototype._normalVector = function (vt, va) {
  74222. var normal0;
  74223. var tgl = vt.length();
  74224. if (tgl === 0.0) {
  74225. tgl = 1.0;
  74226. }
  74227. if (va === undefined || va === null) {
  74228. var point;
  74229. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  74230. point = new Vector3(0.0, -1.0, 0.0);
  74231. }
  74232. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  74233. point = new Vector3(1.0, 0.0, 0.0);
  74234. }
  74235. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  74236. point = new Vector3(0.0, 0.0, 1.0);
  74237. }
  74238. else {
  74239. point = Vector3.Zero();
  74240. }
  74241. normal0 = Vector3.Cross(vt, point);
  74242. }
  74243. else {
  74244. normal0 = Vector3.Cross(vt, va);
  74245. Vector3.CrossToRef(normal0, vt, normal0);
  74246. }
  74247. normal0.normalize();
  74248. return normal0;
  74249. };
  74250. return Path3D;
  74251. }());
  74252. /**
  74253. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74254. * A Curve3 is designed from a series of successive Vector3.
  74255. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74256. */
  74257. var Curve3 = /** @class */ (function () {
  74258. /**
  74259. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74260. * A Curve3 is designed from a series of successive Vector3.
  74261. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74262. * @param points points which make up the curve
  74263. */
  74264. function Curve3(points) {
  74265. this._length = 0.0;
  74266. this._points = points;
  74267. this._length = this._computeLength(points);
  74268. }
  74269. /**
  74270. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74271. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74272. * @param v1 (Vector3) the control point
  74273. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74274. * @param nbPoints (integer) the wanted number of points in the curve
  74275. * @returns the created Curve3
  74276. */
  74277. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  74278. nbPoints = nbPoints > 2 ? nbPoints : 3;
  74279. var bez = new Array();
  74280. var equation = function (t, val0, val1, val2) {
  74281. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  74282. return res;
  74283. };
  74284. for (var i = 0; i <= nbPoints; i++) {
  74285. 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)));
  74286. }
  74287. return new Curve3(bez);
  74288. };
  74289. /**
  74290. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74291. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74292. * @param v1 (Vector3) the first control point
  74293. * @param v2 (Vector3) the second control point
  74294. * @param v3 (Vector3) the end point of the Cubic Bezier
  74295. * @param nbPoints (integer) the wanted number of points in the curve
  74296. * @returns the created Curve3
  74297. */
  74298. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  74299. nbPoints = nbPoints > 3 ? nbPoints : 4;
  74300. var bez = new Array();
  74301. var equation = function (t, val0, val1, val2, val3) {
  74302. 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;
  74303. return res;
  74304. };
  74305. for (var i = 0; i <= nbPoints; i++) {
  74306. 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)));
  74307. }
  74308. return new Curve3(bez);
  74309. };
  74310. /**
  74311. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74312. * @param p1 (Vector3) the origin point of the Hermite Spline
  74313. * @param t1 (Vector3) the tangent vector at the origin point
  74314. * @param p2 (Vector3) the end point of the Hermite Spline
  74315. * @param t2 (Vector3) the tangent vector at the end point
  74316. * @param nbPoints (integer) the wanted number of points in the curve
  74317. * @returns the created Curve3
  74318. */
  74319. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  74320. var hermite = new Array();
  74321. var step = 1.0 / nbPoints;
  74322. for (var i = 0; i <= nbPoints; i++) {
  74323. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  74324. }
  74325. return new Curve3(hermite);
  74326. };
  74327. /**
  74328. * Returns a Curve3 object along a CatmullRom Spline curve :
  74329. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74330. * @param nbPoints (integer) the wanted number of points between each curve control points
  74331. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74332. * @returns the created Curve3
  74333. */
  74334. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  74335. var catmullRom = new Array();
  74336. var step = 1.0 / nbPoints;
  74337. var amount = 0.0;
  74338. if (closed) {
  74339. var pointsCount = points.length;
  74340. for (var i = 0; i < pointsCount; i++) {
  74341. amount = 0;
  74342. for (var c = 0; c < nbPoints; c++) {
  74343. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  74344. amount += step;
  74345. }
  74346. }
  74347. catmullRom.push(catmullRom[0]);
  74348. }
  74349. else {
  74350. var totalPoints = new Array();
  74351. totalPoints.push(points[0].clone());
  74352. Array.prototype.push.apply(totalPoints, points);
  74353. totalPoints.push(points[points.length - 1].clone());
  74354. for (var i = 0; i < totalPoints.length - 3; i++) {
  74355. amount = 0;
  74356. for (var c = 0; c < nbPoints; c++) {
  74357. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74358. amount += step;
  74359. }
  74360. }
  74361. i--;
  74362. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74363. }
  74364. return new Curve3(catmullRom);
  74365. };
  74366. /**
  74367. * @returns the Curve3 stored array of successive Vector3
  74368. */
  74369. Curve3.prototype.getPoints = function () {
  74370. return this._points;
  74371. };
  74372. /**
  74373. * @returns the computed length (float) of the curve.
  74374. */
  74375. Curve3.prototype.length = function () {
  74376. return this._length;
  74377. };
  74378. /**
  74379. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74380. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74381. * curveA and curveB keep unchanged.
  74382. * @param curve the curve to continue from this curve
  74383. * @returns the newly constructed curve
  74384. */
  74385. Curve3.prototype.continue = function (curve) {
  74386. var lastPoint = this._points[this._points.length - 1];
  74387. var continuedPoints = this._points.slice();
  74388. var curvePoints = curve.getPoints();
  74389. for (var i = 1; i < curvePoints.length; i++) {
  74390. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  74391. }
  74392. var continuedCurve = new Curve3(continuedPoints);
  74393. return continuedCurve;
  74394. };
  74395. Curve3.prototype._computeLength = function (path) {
  74396. var l = 0;
  74397. for (var i = 1; i < path.length; i++) {
  74398. l += (path[i].subtract(path[i - 1])).length();
  74399. }
  74400. return l;
  74401. };
  74402. return Curve3;
  74403. }());
  74404. // Vertex formats
  74405. /**
  74406. * Contains position and normal vectors for a vertex
  74407. */
  74408. var PositionNormalVertex = /** @class */ (function () {
  74409. /**
  74410. * Creates a PositionNormalVertex
  74411. * @param position the position of the vertex (defaut: 0,0,0)
  74412. * @param normal the normal of the vertex (defaut: 0,1,0)
  74413. */
  74414. function PositionNormalVertex(
  74415. /** the position of the vertex (defaut: 0,0,0) */
  74416. position,
  74417. /** the normal of the vertex (defaut: 0,1,0) */
  74418. normal) {
  74419. if (position === void 0) { position = Vector3.Zero(); }
  74420. if (normal === void 0) { normal = Vector3.Up(); }
  74421. this.position = position;
  74422. this.normal = normal;
  74423. }
  74424. /**
  74425. * Clones the PositionNormalVertex
  74426. * @returns the cloned PositionNormalVertex
  74427. */
  74428. PositionNormalVertex.prototype.clone = function () {
  74429. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  74430. };
  74431. return PositionNormalVertex;
  74432. }());
  74433. /**
  74434. * Contains position, normal and uv vectors for a vertex
  74435. */
  74436. var PositionNormalTextureVertex = /** @class */ (function () {
  74437. /**
  74438. * Creates a PositionNormalTextureVertex
  74439. * @param position the position of the vertex (defaut: 0,0,0)
  74440. * @param normal the normal of the vertex (defaut: 0,1,0)
  74441. * @param uv the uv of the vertex (default: 0,0)
  74442. */
  74443. function PositionNormalTextureVertex(
  74444. /** the position of the vertex (defaut: 0,0,0) */
  74445. position,
  74446. /** the normal of the vertex (defaut: 0,1,0) */
  74447. normal,
  74448. /** the uv of the vertex (default: 0,0) */
  74449. uv) {
  74450. if (position === void 0) { position = Vector3.Zero(); }
  74451. if (normal === void 0) { normal = Vector3.Up(); }
  74452. if (uv === void 0) { uv = Vector2.Zero(); }
  74453. this.position = position;
  74454. this.normal = normal;
  74455. this.uv = uv;
  74456. }
  74457. /**
  74458. * Clones the PositionNormalTextureVertex
  74459. * @returns the cloned PositionNormalTextureVertex
  74460. */
  74461. PositionNormalTextureVertex.prototype.clone = function () {
  74462. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  74463. };
  74464. return PositionNormalTextureVertex;
  74465. }());
  74466. // Temporary pre-allocated objects for engine internal use
  74467. // usage in any internal function :
  74468. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  74469. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  74470. /**
  74471. * @hidden
  74472. */
  74473. var Tmp = /** @class */ (function () {
  74474. function Tmp() {
  74475. }
  74476. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  74477. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  74478. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  74479. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  74480. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  74481. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  74482. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  74483. return Tmp;
  74484. }());
  74485. /**
  74486. * @hidden
  74487. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  74488. */
  74489. var MathTmp = /** @class */ (function () {
  74490. function MathTmp() {
  74491. }
  74492. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  74493. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  74494. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  74495. return MathTmp;
  74496. }());
  74497. /***/ }),
  74498. /***/ "./Maths/sphericalPolynomial.ts":
  74499. /*!**************************************!*\
  74500. !*** ./Maths/sphericalPolynomial.ts ***!
  74501. \**************************************/
  74502. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  74503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74504. "use strict";
  74505. __webpack_require__.r(__webpack_exports__);
  74506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  74507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  74508. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74509. /**
  74510. * Class representing spherical polynomial coefficients to the 3rd degree
  74511. */
  74512. var SphericalPolynomial = /** @class */ (function () {
  74513. function SphericalPolynomial() {
  74514. /**
  74515. * The x coefficients of the spherical polynomial
  74516. */
  74517. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74518. /**
  74519. * The y coefficients of the spherical polynomial
  74520. */
  74521. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74522. /**
  74523. * The z coefficients of the spherical polynomial
  74524. */
  74525. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74526. /**
  74527. * The xx coefficients of the spherical polynomial
  74528. */
  74529. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74530. /**
  74531. * The yy coefficients of the spherical polynomial
  74532. */
  74533. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74534. /**
  74535. * The zz coefficients of the spherical polynomial
  74536. */
  74537. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74538. /**
  74539. * The xy coefficients of the spherical polynomial
  74540. */
  74541. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74542. /**
  74543. * The yz coefficients of the spherical polynomial
  74544. */
  74545. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74546. /**
  74547. * The zx coefficients of the spherical polynomial
  74548. */
  74549. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74550. }
  74551. /**
  74552. * Adds an ambient color to the spherical polynomial
  74553. * @param color the color to add
  74554. */
  74555. SphericalPolynomial.prototype.addAmbient = function (color) {
  74556. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74557. this.xx = this.xx.add(colorVector);
  74558. this.yy = this.yy.add(colorVector);
  74559. this.zz = this.zz.add(colorVector);
  74560. };
  74561. /**
  74562. * Scales the spherical polynomial by the given amount
  74563. * @param scale the amount to scale
  74564. */
  74565. SphericalPolynomial.prototype.scale = function (scale) {
  74566. this.x = this.x.scale(scale);
  74567. this.y = this.y.scale(scale);
  74568. this.z = this.z.scale(scale);
  74569. this.xx = this.xx.scale(scale);
  74570. this.yy = this.yy.scale(scale);
  74571. this.zz = this.zz.scale(scale);
  74572. this.yz = this.yz.scale(scale);
  74573. this.zx = this.zx.scale(scale);
  74574. this.xy = this.xy.scale(scale);
  74575. };
  74576. /**
  74577. * Gets the spherical polynomial from harmonics
  74578. * @param harmonics the spherical harmonics
  74579. * @returns the spherical polynomial
  74580. */
  74581. SphericalPolynomial.FromHarmonics = function (harmonics) {
  74582. var result = new SphericalPolynomial();
  74583. result.x = harmonics.l11.scale(1.02333);
  74584. result.y = harmonics.l1_1.scale(1.02333);
  74585. result.z = harmonics.l10.scale(1.02333);
  74586. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  74587. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  74588. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  74589. result.yz = harmonics.l2_1.scale(0.858086);
  74590. result.zx = harmonics.l21.scale(0.858086);
  74591. result.xy = harmonics.l2_2.scale(0.858086);
  74592. result.scale(1.0 / Math.PI);
  74593. return result;
  74594. };
  74595. /**
  74596. * Constructs a spherical polynomial from an array.
  74597. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  74598. * @returns the spherical polynomial
  74599. */
  74600. SphericalPolynomial.FromArray = function (data) {
  74601. var sp = new SphericalPolynomial();
  74602. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  74603. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  74604. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  74605. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  74606. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  74607. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  74608. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  74609. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  74610. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  74611. return sp;
  74612. };
  74613. return SphericalPolynomial;
  74614. }());
  74615. /**
  74616. * Class representing spherical harmonics coefficients to the 3rd degree
  74617. */
  74618. var SphericalHarmonics = /** @class */ (function () {
  74619. function SphericalHarmonics() {
  74620. /**
  74621. * The l0,0 coefficients of the spherical harmonics
  74622. */
  74623. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74624. /**
  74625. * The l1,-1 coefficients of the spherical harmonics
  74626. */
  74627. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74628. /**
  74629. * The l1,0 coefficients of the spherical harmonics
  74630. */
  74631. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74632. /**
  74633. * The l1,1 coefficients of the spherical harmonics
  74634. */
  74635. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74636. /**
  74637. * The l2,-2 coefficients of the spherical harmonics
  74638. */
  74639. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74640. /**
  74641. * The l2,-1 coefficients of the spherical harmonics
  74642. */
  74643. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74644. /**
  74645. * The l2,0 coefficients of the spherical harmonics
  74646. */
  74647. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74648. /**
  74649. * The l2,1 coefficients of the spherical harmonics
  74650. */
  74651. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74652. /**
  74653. * The l2,2 coefficients of the spherical harmonics
  74654. */
  74655. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74656. }
  74657. /**
  74658. * Adds a light to the spherical harmonics
  74659. * @param direction the direction of the light
  74660. * @param color the color of the light
  74661. * @param deltaSolidAngle the delta solid angle of the light
  74662. */
  74663. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  74664. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74665. var c = colorVector.scale(deltaSolidAngle);
  74666. this.l00 = this.l00.add(c.scale(0.282095));
  74667. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  74668. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  74669. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  74670. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  74671. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  74672. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  74673. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  74674. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  74675. };
  74676. /**
  74677. * Scales the spherical harmonics by the given amount
  74678. * @param scale the amount to scale
  74679. */
  74680. SphericalHarmonics.prototype.scale = function (scale) {
  74681. this.l00 = this.l00.scale(scale);
  74682. this.l1_1 = this.l1_1.scale(scale);
  74683. this.l10 = this.l10.scale(scale);
  74684. this.l11 = this.l11.scale(scale);
  74685. this.l2_2 = this.l2_2.scale(scale);
  74686. this.l2_1 = this.l2_1.scale(scale);
  74687. this.l20 = this.l20.scale(scale);
  74688. this.l21 = this.l21.scale(scale);
  74689. this.lL22 = this.lL22.scale(scale);
  74690. };
  74691. /**
  74692. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  74693. *
  74694. * ```
  74695. * E_lm = A_l * L_lm
  74696. * ```
  74697. *
  74698. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  74699. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  74700. * the scaling factors are given in equation 9.
  74701. */
  74702. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  74703. // Constant (Band 0)
  74704. this.l00 = this.l00.scale(3.141593);
  74705. // Linear (Band 1)
  74706. this.l1_1 = this.l1_1.scale(2.094395);
  74707. this.l10 = this.l10.scale(2.094395);
  74708. this.l11 = this.l11.scale(2.094395);
  74709. // Quadratic (Band 2)
  74710. this.l2_2 = this.l2_2.scale(0.785398);
  74711. this.l2_1 = this.l2_1.scale(0.785398);
  74712. this.l20 = this.l20.scale(0.785398);
  74713. this.l21 = this.l21.scale(0.785398);
  74714. this.lL22 = this.lL22.scale(0.785398);
  74715. };
  74716. /**
  74717. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  74718. *
  74719. * ```
  74720. * L = (1/pi) * E * rho
  74721. * ```
  74722. *
  74723. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  74724. */
  74725. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  74726. this.scale(1.0 / Math.PI);
  74727. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  74728. // (The pixel shader must apply albedo after texture fetches, etc).
  74729. };
  74730. /**
  74731. * Gets the spherical harmonics from polynomial
  74732. * @param polynomial the spherical polynomial
  74733. * @returns the spherical harmonics
  74734. */
  74735. SphericalHarmonics.FromPolynomial = function (polynomial) {
  74736. var result = new SphericalHarmonics();
  74737. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  74738. result.l1_1 = polynomial.y.scale(0.977204);
  74739. result.l10 = polynomial.z.scale(0.977204);
  74740. result.l11 = polynomial.x.scale(0.977204);
  74741. result.l2_2 = polynomial.xy.scale(1.16538);
  74742. result.l2_1 = polynomial.yz.scale(1.16538);
  74743. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  74744. result.l21 = polynomial.zx.scale(1.16538);
  74745. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  74746. result.scale(Math.PI);
  74747. return result;
  74748. };
  74749. /**
  74750. * Constructs a spherical harmonics from an array.
  74751. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  74752. * @returns the spherical harmonics
  74753. */
  74754. SphericalHarmonics.FromArray = function (data) {
  74755. var sh = new SphericalHarmonics();
  74756. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  74757. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  74758. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  74759. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  74760. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  74761. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  74762. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  74763. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  74764. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  74765. return sh;
  74766. };
  74767. return SphericalHarmonics;
  74768. }());
  74769. /***/ }),
  74770. /***/ "./Meshes/Builders/boxBuilder.ts":
  74771. /*!***************************************!*\
  74772. !*** ./Meshes/Builders/boxBuilder.ts ***!
  74773. \***************************************/
  74774. /*! exports provided: BoxBuilder */
  74775. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74776. "use strict";
  74777. __webpack_require__.r(__webpack_exports__);
  74778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  74779. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74780. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74781. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74782. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  74783. var normalsSource = [
  74784. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  74785. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  74786. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  74787. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  74788. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  74789. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  74790. ];
  74791. var indices = [];
  74792. var positions = [];
  74793. var normals = [];
  74794. var uvs = [];
  74795. var width = options.width || options.size || 1;
  74796. var height = options.height || options.size || 1;
  74797. var depth = options.depth || options.size || 1;
  74798. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74799. var faceUV = options.faceUV || new Array(6);
  74800. var faceColors = options.faceColors;
  74801. var colors = [];
  74802. // default face colors and UV if undefined
  74803. for (var f = 0; f < 6; f++) {
  74804. if (faceUV[f] === undefined) {
  74805. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74806. }
  74807. if (faceColors && faceColors[f] === undefined) {
  74808. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74809. }
  74810. }
  74811. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  74812. // Create each face in turn.
  74813. for (var index = 0; index < normalsSource.length; index++) {
  74814. var normal = normalsSource[index];
  74815. // Get two vectors perpendicular to the face normal and to each other.
  74816. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  74817. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  74818. // Six indices (two triangles) per face.
  74819. var verticesLength = positions.length / 3;
  74820. indices.push(verticesLength);
  74821. indices.push(verticesLength + 1);
  74822. indices.push(verticesLength + 2);
  74823. indices.push(verticesLength);
  74824. indices.push(verticesLength + 2);
  74825. indices.push(verticesLength + 3);
  74826. // Four vertices per face.
  74827. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  74828. positions.push(vertex.x, vertex.y, vertex.z);
  74829. normals.push(normal.x, normal.y, normal.z);
  74830. uvs.push(faceUV[index].z, faceUV[index].w);
  74831. if (faceColors) {
  74832. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74833. }
  74834. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  74835. positions.push(vertex.x, vertex.y, vertex.z);
  74836. normals.push(normal.x, normal.y, normal.z);
  74837. uvs.push(faceUV[index].x, faceUV[index].w);
  74838. if (faceColors) {
  74839. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74840. }
  74841. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  74842. positions.push(vertex.x, vertex.y, vertex.z);
  74843. normals.push(normal.x, normal.y, normal.z);
  74844. uvs.push(faceUV[index].x, faceUV[index].y);
  74845. if (faceColors) {
  74846. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74847. }
  74848. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  74849. positions.push(vertex.x, vertex.y, vertex.z);
  74850. normals.push(normal.x, normal.y, normal.z);
  74851. uvs.push(faceUV[index].z, faceUV[index].y);
  74852. if (faceColors) {
  74853. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74854. }
  74855. }
  74856. // sides
  74857. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  74858. // Result
  74859. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  74860. vertexData.indices = indices;
  74861. vertexData.positions = positions;
  74862. vertexData.normals = normals;
  74863. vertexData.uvs = uvs;
  74864. if (faceColors) {
  74865. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  74866. vertexData.colors = totalColors;
  74867. }
  74868. return vertexData;
  74869. };
  74870. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  74871. if (scene === void 0) { scene = null; }
  74872. var options = {
  74873. size: size,
  74874. sideOrientation: sideOrientation,
  74875. updatable: updatable
  74876. };
  74877. return BoxBuilder.CreateBox(name, options, scene);
  74878. };
  74879. /**
  74880. * Class containing static functions to help procedurally build meshes
  74881. */
  74882. var BoxBuilder = /** @class */ (function () {
  74883. function BoxBuilder() {
  74884. }
  74885. /**
  74886. * Creates a box mesh
  74887. * * The parameter `size` sets the size (float) of each box side (default 1)
  74888. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  74889. * * 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)
  74890. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74892. * * 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
  74893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74894. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  74895. * @param name defines the name of the mesh
  74896. * @param options defines the options used to create the mesh
  74897. * @param scene defines the hosting scene
  74898. * @returns the box mesh
  74899. */
  74900. BoxBuilder.CreateBox = function (name, options, scene) {
  74901. if (scene === void 0) { scene = null; }
  74902. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  74903. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  74904. box._originalBuilderSideOrientation = options.sideOrientation;
  74905. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  74906. vertexData.applyToMesh(box, options.updatable);
  74907. return box;
  74908. };
  74909. return BoxBuilder;
  74910. }());
  74911. /***/ }),
  74912. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  74913. /*!********************************************!*\
  74914. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  74915. \********************************************/
  74916. /*! exports provided: CylinderBuilder */
  74917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74918. "use strict";
  74919. __webpack_require__.r(__webpack_exports__);
  74920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  74921. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74922. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74923. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74924. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  74925. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  74926. var height = options.height || 2;
  74927. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  74928. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  74929. var tessellation = options.tessellation || 24;
  74930. var subdivisions = options.subdivisions || 1;
  74931. var hasRings = options.hasRings ? true : false;
  74932. var enclose = options.enclose ? true : false;
  74933. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  74934. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74935. var faceUV = options.faceUV || new Array(3);
  74936. var faceColors = options.faceColors;
  74937. // default face colors and UV if undefined
  74938. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  74939. var ringNb = (hasRings) ? subdivisions : 1;
  74940. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  74941. var f;
  74942. for (f = 0; f < surfaceNb; f++) {
  74943. if (faceColors && faceColors[f] === undefined) {
  74944. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74945. }
  74946. }
  74947. for (f = 0; f < surfaceNb; f++) {
  74948. if (faceUV && faceUV[f] === undefined) {
  74949. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74950. }
  74951. }
  74952. var indices = new Array();
  74953. var positions = new Array();
  74954. var normals = new Array();
  74955. var uvs = new Array();
  74956. var colors = new Array();
  74957. var angle_step = Math.PI * 2 * arc / tessellation;
  74958. var angle;
  74959. var h;
  74960. var radius;
  74961. var tan = (diameterBottom - diameterTop) / 2 / height;
  74962. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74963. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74964. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74965. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74966. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74967. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  74968. // positions, normals, uvs
  74969. var i;
  74970. var j;
  74971. var r;
  74972. var ringIdx = 1;
  74973. var s = 1; // surface index
  74974. var cs = 0;
  74975. var v = 0;
  74976. for (i = 0; i <= subdivisions; i++) {
  74977. h = i / subdivisions;
  74978. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  74979. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  74980. for (r = 0; r < ringIdx; r++) {
  74981. if (hasRings) {
  74982. s += r;
  74983. }
  74984. if (enclose) {
  74985. s += 2 * r;
  74986. }
  74987. for (j = 0; j <= tessellation; j++) {
  74988. angle = j * angle_step;
  74989. // position
  74990. ringVertex.x = Math.cos(-angle) * radius;
  74991. ringVertex.y = -height / 2 + h * height;
  74992. ringVertex.z = Math.sin(-angle) * radius;
  74993. // normal
  74994. if (diameterTop === 0 && i === subdivisions) {
  74995. // if no top cap, reuse former normals
  74996. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  74997. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  74998. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  74999. }
  75000. else {
  75001. ringNormal.x = ringVertex.x;
  75002. ringNormal.z = ringVertex.z;
  75003. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  75004. ringNormal.normalize();
  75005. }
  75006. // keep first ring vertex values for enclose
  75007. if (j === 0) {
  75008. ringFirstVertex.copyFrom(ringVertex);
  75009. ringFirstNormal.copyFrom(ringNormal);
  75010. }
  75011. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  75012. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  75013. if (hasRings) {
  75014. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  75015. }
  75016. else {
  75017. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  75018. }
  75019. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  75020. if (faceColors) {
  75021. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  75022. }
  75023. }
  75024. // if enclose, add four vertices and their dedicated normals
  75025. if (arc !== 1 && enclose) {
  75026. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  75027. positions.push(0, ringVertex.y, 0);
  75028. positions.push(0, ringVertex.y, 0);
  75029. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  75030. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  75031. quadNormal.normalize();
  75032. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  75033. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  75034. quadNormal.normalize();
  75035. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  75036. if (hasRings) {
  75037. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  75038. }
  75039. else {
  75040. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  75041. }
  75042. uvs.push(faceUV[s + 1].x, v);
  75043. uvs.push(faceUV[s + 1].z, v);
  75044. if (hasRings) {
  75045. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  75046. }
  75047. else {
  75048. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  75049. }
  75050. uvs.push(faceUV[s + 2].x, v);
  75051. uvs.push(faceUV[s + 2].z, v);
  75052. if (faceColors) {
  75053. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  75054. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  75055. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  75056. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  75057. }
  75058. }
  75059. if (cs !== s) {
  75060. cs = s;
  75061. }
  75062. }
  75063. }
  75064. // indices
  75065. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  75066. var s;
  75067. i = 0;
  75068. for (s = 0; s < subdivisions; s++) {
  75069. var i0 = 0;
  75070. var i1 = 0;
  75071. var i2 = 0;
  75072. var i3 = 0;
  75073. for (j = 0; j < tessellation; j++) {
  75074. i0 = i * (e + 1) + j;
  75075. i1 = (i + 1) * (e + 1) + j;
  75076. i2 = i * (e + 1) + (j + 1);
  75077. i3 = (i + 1) * (e + 1) + (j + 1);
  75078. indices.push(i0, i1, i2);
  75079. indices.push(i3, i2, i1);
  75080. }
  75081. if (arc !== 1 && enclose) { // if enclose, add two quads
  75082. indices.push(i0 + 2, i1 + 2, i2 + 2);
  75083. indices.push(i3 + 2, i2 + 2, i1 + 2);
  75084. indices.push(i0 + 4, i1 + 4, i2 + 4);
  75085. indices.push(i3 + 4, i2 + 4, i1 + 4);
  75086. }
  75087. i = (hasRings) ? (i + 2) : (i + 1);
  75088. }
  75089. // Caps
  75090. var createCylinderCap = function (isTop) {
  75091. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  75092. if (radius === 0) {
  75093. return;
  75094. }
  75095. // Cap positions, normals & uvs
  75096. var angle;
  75097. var circleVector;
  75098. var i;
  75099. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  75100. var c = null;
  75101. if (faceColors) {
  75102. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  75103. }
  75104. // cap center
  75105. var vbase = positions.length / 3;
  75106. var offset = isTop ? height / 2 : -height / 2;
  75107. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  75108. positions.push(center.x, center.y, center.z);
  75109. normals.push(0, isTop ? 1 : -1, 0);
  75110. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  75111. if (c) {
  75112. colors.push(c.r, c.g, c.b, c.a);
  75113. }
  75114. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  75115. for (i = 0; i <= tessellation; i++) {
  75116. angle = Math.PI * 2 * i * arc / tessellation;
  75117. var cos = Math.cos(-angle);
  75118. var sin = Math.sin(-angle);
  75119. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  75120. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  75121. positions.push(circleVector.x, circleVector.y, circleVector.z);
  75122. normals.push(0, isTop ? 1 : -1, 0);
  75123. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  75124. if (c) {
  75125. colors.push(c.r, c.g, c.b, c.a);
  75126. }
  75127. }
  75128. // Cap indices
  75129. for (i = 0; i < tessellation; i++) {
  75130. if (!isTop) {
  75131. indices.push(vbase);
  75132. indices.push(vbase + (i + 1));
  75133. indices.push(vbase + (i + 2));
  75134. }
  75135. else {
  75136. indices.push(vbase);
  75137. indices.push(vbase + (i + 2));
  75138. indices.push(vbase + (i + 1));
  75139. }
  75140. }
  75141. };
  75142. // add caps to geometry
  75143. createCylinderCap(false);
  75144. createCylinderCap(true);
  75145. // Sides
  75146. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75147. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75148. vertexData.indices = indices;
  75149. vertexData.positions = positions;
  75150. vertexData.normals = normals;
  75151. vertexData.uvs = uvs;
  75152. if (faceColors) {
  75153. vertexData.colors = colors;
  75154. }
  75155. return vertexData;
  75156. };
  75157. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  75158. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  75159. if (scene !== undefined) {
  75160. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  75161. updatable = scene;
  75162. }
  75163. scene = subdivisions;
  75164. subdivisions = 1;
  75165. }
  75166. var options = {
  75167. height: height,
  75168. diameterTop: diameterTop,
  75169. diameterBottom: diameterBottom,
  75170. tessellation: tessellation,
  75171. subdivisions: subdivisions,
  75172. sideOrientation: sideOrientation,
  75173. updatable: updatable
  75174. };
  75175. return CylinderBuilder.CreateCylinder(name, options, scene);
  75176. };
  75177. /**
  75178. * Class containing static functions to help procedurally build meshes
  75179. */
  75180. var CylinderBuilder = /** @class */ (function () {
  75181. function CylinderBuilder() {
  75182. }
  75183. /**
  75184. * Creates a cylinder or a cone mesh
  75185. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  75186. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  75187. * * 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.
  75188. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  75189. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  75190. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  75191. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  75192. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  75193. * * 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).
  75194. * * 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
  75195. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  75196. * * 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
  75197. * * 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.
  75198. * * If `enclose` is false, a ring surface is one element.
  75199. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  75200. * * 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
  75201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75202. * * 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
  75203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75204. * @param name defines the name of the mesh
  75205. * @param options defines the options used to create the mesh
  75206. * @param scene defines the hosting scene
  75207. * @returns the cylinder mesh
  75208. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  75209. */
  75210. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  75211. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75212. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75213. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  75214. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  75215. vertexData.applyToMesh(cylinder, options.updatable);
  75216. return cylinder;
  75217. };
  75218. return CylinderBuilder;
  75219. }());
  75220. /***/ }),
  75221. /***/ "./Meshes/Builders/decalBuilder.ts":
  75222. /*!*****************************************!*\
  75223. !*** ./Meshes/Builders/decalBuilder.ts ***!
  75224. \*****************************************/
  75225. /*! exports provided: DecalBuilder */
  75226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75227. "use strict";
  75228. __webpack_require__.r(__webpack_exports__);
  75229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  75230. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75231. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75232. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  75233. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75234. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  75235. var options = {
  75236. position: position,
  75237. normal: normal,
  75238. size: size,
  75239. angle: angle
  75240. };
  75241. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  75242. };
  75243. /**
  75244. * Class containing static functions to help procedurally build meshes
  75245. */
  75246. var DecalBuilder = /** @class */ (function () {
  75247. function DecalBuilder() {
  75248. }
  75249. /**
  75250. * Creates a decal mesh.
  75251. * 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
  75252. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  75253. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  75254. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  75255. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  75256. * @param name defines the name of the mesh
  75257. * @param sourceMesh defines the mesh where the decal must be applied
  75258. * @param options defines the options used to create the mesh
  75259. * @param scene defines the hosting scene
  75260. * @returns the decal mesh
  75261. * @see https://doc.babylonjs.com/how_to/decals
  75262. */
  75263. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  75264. var indices = sourceMesh.getIndices();
  75265. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  75266. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  75267. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75268. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  75269. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  75270. var angle = options.angle || 0;
  75271. // Getting correct rotation
  75272. if (!normal) {
  75273. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  75274. var camera = sourceMesh.getScene().activeCamera;
  75275. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  75276. normal = camera.globalPosition.subtract(cameraWorldTarget);
  75277. }
  75278. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  75279. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  75280. var pitch = Math.atan2(normal.y, len);
  75281. // Matrix
  75282. 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));
  75283. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  75284. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  75285. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  75286. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  75287. vertexData.indices = [];
  75288. vertexData.positions = [];
  75289. vertexData.normals = [];
  75290. vertexData.uvs = [];
  75291. var currentVertexDataIndex = 0;
  75292. var extractDecalVector3 = function (indexId) {
  75293. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  75294. if (!indices || !positions || !normals) {
  75295. return result;
  75296. }
  75297. var vertexId = indices[indexId];
  75298. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  75299. // Send vector to decal local world
  75300. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  75301. // Get normal
  75302. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  75303. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  75304. return result;
  75305. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  75306. var clip = function (vertices, axis) {
  75307. if (vertices.length === 0) {
  75308. return vertices;
  75309. }
  75310. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  75311. var clipVertices = function (v0, v1) {
  75312. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  75313. 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));
  75314. };
  75315. var result = new Array();
  75316. for (var index = 0; index < vertices.length; index += 3) {
  75317. var v1Out;
  75318. var v2Out;
  75319. var v3Out;
  75320. var total = 0;
  75321. var nV1 = null;
  75322. var nV2 = null;
  75323. var nV3 = null;
  75324. var nV4 = null;
  75325. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  75326. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  75327. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  75328. v1Out = d1 > 0;
  75329. v2Out = d2 > 0;
  75330. v3Out = d3 > 0;
  75331. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  75332. switch (total) {
  75333. case 0:
  75334. result.push(vertices[index]);
  75335. result.push(vertices[index + 1]);
  75336. result.push(vertices[index + 2]);
  75337. break;
  75338. case 1:
  75339. if (v1Out) {
  75340. nV1 = vertices[index + 1];
  75341. nV2 = vertices[index + 2];
  75342. nV3 = clipVertices(vertices[index], nV1);
  75343. nV4 = clipVertices(vertices[index], nV2);
  75344. }
  75345. if (v2Out) {
  75346. nV1 = vertices[index];
  75347. nV2 = vertices[index + 2];
  75348. nV3 = clipVertices(vertices[index + 1], nV1);
  75349. nV4 = clipVertices(vertices[index + 1], nV2);
  75350. result.push(nV3);
  75351. result.push(nV2.clone());
  75352. result.push(nV1.clone());
  75353. result.push(nV2.clone());
  75354. result.push(nV3.clone());
  75355. result.push(nV4);
  75356. break;
  75357. }
  75358. if (v3Out) {
  75359. nV1 = vertices[index];
  75360. nV2 = vertices[index + 1];
  75361. nV3 = clipVertices(vertices[index + 2], nV1);
  75362. nV4 = clipVertices(vertices[index + 2], nV2);
  75363. }
  75364. if (nV1 && nV2 && nV3 && nV4) {
  75365. result.push(nV1.clone());
  75366. result.push(nV2.clone());
  75367. result.push(nV3);
  75368. result.push(nV4);
  75369. result.push(nV3.clone());
  75370. result.push(nV2.clone());
  75371. }
  75372. break;
  75373. case 2:
  75374. if (!v1Out) {
  75375. nV1 = vertices[index].clone();
  75376. nV2 = clipVertices(nV1, vertices[index + 1]);
  75377. nV3 = clipVertices(nV1, vertices[index + 2]);
  75378. result.push(nV1);
  75379. result.push(nV2);
  75380. result.push(nV3);
  75381. }
  75382. if (!v2Out) {
  75383. nV1 = vertices[index + 1].clone();
  75384. nV2 = clipVertices(nV1, vertices[index + 2]);
  75385. nV3 = clipVertices(nV1, vertices[index]);
  75386. result.push(nV1);
  75387. result.push(nV2);
  75388. result.push(nV3);
  75389. }
  75390. if (!v3Out) {
  75391. nV1 = vertices[index + 2].clone();
  75392. nV2 = clipVertices(nV1, vertices[index]);
  75393. nV3 = clipVertices(nV1, vertices[index + 1]);
  75394. result.push(nV1);
  75395. result.push(nV2);
  75396. result.push(nV3);
  75397. }
  75398. break;
  75399. case 3:
  75400. break;
  75401. }
  75402. }
  75403. return result;
  75404. };
  75405. for (var index = 0; index < indices.length; index += 3) {
  75406. var faceVertices = new Array();
  75407. faceVertices.push(extractDecalVector3(index));
  75408. faceVertices.push(extractDecalVector3(index + 1));
  75409. faceVertices.push(extractDecalVector3(index + 2));
  75410. // Clip
  75411. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  75412. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  75413. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  75414. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  75415. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  75416. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  75417. if (faceVertices.length === 0) {
  75418. continue;
  75419. }
  75420. // Add UVs and get back to world
  75421. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  75422. var vertex = faceVertices[vIndex];
  75423. //TODO check for Int32Array | Uint32Array | Uint16Array
  75424. vertexData.indices.push(currentVertexDataIndex);
  75425. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  75426. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  75427. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  75428. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  75429. currentVertexDataIndex++;
  75430. }
  75431. }
  75432. // Return mesh
  75433. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  75434. vertexData.applyToMesh(decal);
  75435. decal.position = position.clone();
  75436. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  75437. return decal;
  75438. };
  75439. return DecalBuilder;
  75440. }());
  75441. /***/ }),
  75442. /***/ "./Meshes/Builders/discBuilder.ts":
  75443. /*!****************************************!*\
  75444. !*** ./Meshes/Builders/discBuilder.ts ***!
  75445. \****************************************/
  75446. /*! exports provided: DiscBuilder */
  75447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75448. "use strict";
  75449. __webpack_require__.r(__webpack_exports__);
  75450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  75451. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75452. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75453. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  75454. var positions = new Array();
  75455. var indices = new Array();
  75456. var normals = new Array();
  75457. var uvs = new Array();
  75458. var radius = options.radius || 0.5;
  75459. var tessellation = options.tessellation || 64;
  75460. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  75461. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  75462. // positions and uvs
  75463. positions.push(0, 0, 0); // disc center first
  75464. uvs.push(0.5, 0.5);
  75465. var theta = Math.PI * 2 * arc;
  75466. var step = theta / tessellation;
  75467. for (var a = 0; a < theta; a += step) {
  75468. var x = Math.cos(a);
  75469. var y = Math.sin(a);
  75470. var u = (x + 1) / 2;
  75471. var v = (1 - y) / 2;
  75472. positions.push(radius * x, radius * y, 0);
  75473. uvs.push(u, v);
  75474. }
  75475. if (arc === 1) {
  75476. positions.push(positions[3], positions[4], positions[5]); // close the circle
  75477. uvs.push(uvs[2], uvs[3]);
  75478. }
  75479. //indices
  75480. var vertexNb = positions.length / 3;
  75481. for (var i = 1; i < vertexNb - 1; i++) {
  75482. indices.push(i + 1, 0, i);
  75483. }
  75484. // result
  75485. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  75486. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75487. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  75488. vertexData.indices = indices;
  75489. vertexData.positions = positions;
  75490. vertexData.normals = normals;
  75491. vertexData.uvs = uvs;
  75492. return vertexData;
  75493. };
  75494. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  75495. if (scene === void 0) { scene = null; }
  75496. var options = {
  75497. radius: radius,
  75498. tessellation: tessellation,
  75499. sideOrientation: sideOrientation,
  75500. updatable: updatable
  75501. };
  75502. return DiscBuilder.CreateDisc(name, options, scene);
  75503. };
  75504. /**
  75505. * Class containing static functions to help procedurally build meshes
  75506. */
  75507. var DiscBuilder = /** @class */ (function () {
  75508. function DiscBuilder() {
  75509. }
  75510. /**
  75511. * Creates a plane polygonal mesh. By default, this is a disc
  75512. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  75513. * * 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
  75514. * * 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
  75515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75516. * * 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
  75517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75518. * @param name defines the name of the mesh
  75519. * @param options defines the options used to create the mesh
  75520. * @param scene defines the hosting scene
  75521. * @returns the plane polygonal mesh
  75522. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  75523. */
  75524. DiscBuilder.CreateDisc = function (name, options, scene) {
  75525. if (scene === void 0) { scene = null; }
  75526. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  75527. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75528. disc._originalBuilderSideOrientation = options.sideOrientation;
  75529. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  75530. vertexData.applyToMesh(disc, options.updatable);
  75531. return disc;
  75532. };
  75533. return DiscBuilder;
  75534. }());
  75535. /***/ }),
  75536. /***/ "./Meshes/Builders/groundBuilder.ts":
  75537. /*!******************************************!*\
  75538. !*** ./Meshes/Builders/groundBuilder.ts ***!
  75539. \******************************************/
  75540. /*! exports provided: GroundBuilder */
  75541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75542. "use strict";
  75543. __webpack_require__.r(__webpack_exports__);
  75544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  75545. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75546. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75547. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75548. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  75549. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  75550. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  75551. var indices = [];
  75552. var positions = [];
  75553. var normals = [];
  75554. var uvs = [];
  75555. var row, col;
  75556. var width = options.width || 1;
  75557. var height = options.height || 1;
  75558. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75559. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75560. for (row = 0; row <= subdivisionsY; row++) {
  75561. for (col = 0; col <= subdivisionsX; col++) {
  75562. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  75563. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75564. positions.push(position.x, position.y, position.z);
  75565. normals.push(normal.x, normal.y, normal.z);
  75566. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  75567. }
  75568. }
  75569. for (row = 0; row < subdivisionsY; row++) {
  75570. for (col = 0; col < subdivisionsX; col++) {
  75571. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75572. indices.push(col + 1 + row * (subdivisionsX + 1));
  75573. indices.push(col + row * (subdivisionsX + 1));
  75574. indices.push(col + (row + 1) * (subdivisionsX + 1));
  75575. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75576. indices.push(col + row * (subdivisionsX + 1));
  75577. }
  75578. }
  75579. // Result
  75580. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75581. vertexData.indices = indices;
  75582. vertexData.positions = positions;
  75583. vertexData.normals = normals;
  75584. vertexData.uvs = uvs;
  75585. return vertexData;
  75586. };
  75587. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  75588. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  75589. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  75590. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  75591. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  75592. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  75593. var precision = options.precision || { w: 1, h: 1 };
  75594. var indices = new Array();
  75595. var positions = new Array();
  75596. var normals = new Array();
  75597. var uvs = new Array();
  75598. var row, col, tileRow, tileCol;
  75599. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  75600. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  75601. precision.w = (precision.w < 1) ? 1 : precision.w;
  75602. precision.h = (precision.h < 1) ? 1 : precision.h;
  75603. var tileSize = {
  75604. 'w': (xmax - xmin) / subdivisions.w,
  75605. 'h': (zmax - zmin) / subdivisions.h
  75606. };
  75607. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  75608. // Indices
  75609. var base = positions.length / 3;
  75610. var rowLength = precision.w + 1;
  75611. for (row = 0; row < precision.h; row++) {
  75612. for (col = 0; col < precision.w; col++) {
  75613. var square = [
  75614. base + col + row * rowLength,
  75615. base + (col + 1) + row * rowLength,
  75616. base + (col + 1) + (row + 1) * rowLength,
  75617. base + col + (row + 1) * rowLength
  75618. ];
  75619. indices.push(square[1]);
  75620. indices.push(square[2]);
  75621. indices.push(square[3]);
  75622. indices.push(square[0]);
  75623. indices.push(square[1]);
  75624. indices.push(square[3]);
  75625. }
  75626. }
  75627. // Position, normals and uvs
  75628. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75629. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75630. for (row = 0; row <= precision.h; row++) {
  75631. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  75632. for (col = 0; col <= precision.w; col++) {
  75633. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  75634. position.y = 0;
  75635. positions.push(position.x, position.y, position.z);
  75636. normals.push(normal.x, normal.y, normal.z);
  75637. uvs.push(col / precision.w, row / precision.h);
  75638. }
  75639. }
  75640. }
  75641. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  75642. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  75643. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  75644. }
  75645. }
  75646. // Result
  75647. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75648. vertexData.indices = indices;
  75649. vertexData.positions = positions;
  75650. vertexData.normals = normals;
  75651. vertexData.uvs = uvs;
  75652. return vertexData;
  75653. };
  75654. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  75655. var indices = [];
  75656. var positions = [];
  75657. var normals = [];
  75658. var uvs = [];
  75659. var row, col;
  75660. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75661. var alphaFilter = options.alphaFilter || 0.0;
  75662. // Vertices
  75663. for (row = 0; row <= options.subdivisions; row++) {
  75664. for (col = 0; col <= options.subdivisions; col++) {
  75665. 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));
  75666. // Compute height
  75667. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  75668. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  75669. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  75670. var r = options.buffer[pos] / 255.0;
  75671. var g = options.buffer[pos + 1] / 255.0;
  75672. var b = options.buffer[pos + 2] / 255.0;
  75673. var a = options.buffer[pos + 3] / 255.0;
  75674. var gradient = r * filter.r + g * filter.g + b * filter.b;
  75675. // If our alpha channel is not within our filter then we will assign a 'special' height
  75676. // Then when building the indices, we will ignore any vertex that is using the special height
  75677. if (a >= alphaFilter) {
  75678. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  75679. }
  75680. else {
  75681. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  75682. }
  75683. // Add vertex
  75684. positions.push(position.x, position.y, position.z);
  75685. normals.push(0, 0, 0);
  75686. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  75687. }
  75688. }
  75689. // Indices
  75690. for (row = 0; row < options.subdivisions; row++) {
  75691. for (col = 0; col < options.subdivisions; col++) {
  75692. // Calculate Indices
  75693. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  75694. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  75695. var idx3 = (col + row * (options.subdivisions + 1));
  75696. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  75697. // Check that all indices are visible (based on our special height)
  75698. // Only display the vertex if all Indices are visible
  75699. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  75700. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  75701. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  75702. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  75703. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  75704. indices.push(idx1);
  75705. indices.push(idx2);
  75706. indices.push(idx3);
  75707. }
  75708. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  75709. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  75710. indices.push(idx4);
  75711. indices.push(idx1);
  75712. indices.push(idx3);
  75713. }
  75714. }
  75715. }
  75716. // Normals
  75717. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  75718. // Result
  75719. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75720. vertexData.indices = indices;
  75721. vertexData.positions = positions;
  75722. vertexData.normals = normals;
  75723. vertexData.uvs = uvs;
  75724. return vertexData;
  75725. };
  75726. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  75727. var options = {
  75728. width: width,
  75729. height: height,
  75730. subdivisions: subdivisions,
  75731. updatable: updatable
  75732. };
  75733. return GroundBuilder.CreateGround(name, options, scene);
  75734. };
  75735. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  75736. var options = {
  75737. xmin: xmin,
  75738. zmin: zmin,
  75739. xmax: xmax,
  75740. zmax: zmax,
  75741. subdivisions: subdivisions,
  75742. precision: precision,
  75743. updatable: updatable
  75744. };
  75745. return GroundBuilder.CreateTiledGround(name, options, scene);
  75746. };
  75747. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  75748. var options = {
  75749. width: width,
  75750. height: height,
  75751. subdivisions: subdivisions,
  75752. minHeight: minHeight,
  75753. maxHeight: maxHeight,
  75754. updatable: updatable,
  75755. onReady: onReady,
  75756. alphaFilter: alphaFilter
  75757. };
  75758. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  75759. };
  75760. /**
  75761. * Class containing static functions to help procedurally build meshes
  75762. */
  75763. var GroundBuilder = /** @class */ (function () {
  75764. function GroundBuilder() {
  75765. }
  75766. /**
  75767. * Creates a ground mesh
  75768. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  75769. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  75770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75771. * @param name defines the name of the mesh
  75772. * @param options defines the options used to create the mesh
  75773. * @param scene defines the hosting scene
  75774. * @returns the ground mesh
  75775. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  75776. */
  75777. GroundBuilder.CreateGround = function (name, options, scene) {
  75778. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75779. ground._setReady(false);
  75780. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75781. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75782. ground._width = options.width || 1;
  75783. ground._height = options.height || 1;
  75784. ground._maxX = ground._width / 2;
  75785. ground._maxZ = ground._height / 2;
  75786. ground._minX = -ground._maxX;
  75787. ground._minZ = -ground._maxZ;
  75788. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  75789. vertexData.applyToMesh(ground, options.updatable);
  75790. ground._setReady(true);
  75791. return ground;
  75792. };
  75793. /**
  75794. * Creates a tiled ground mesh
  75795. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  75796. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  75797. * * 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
  75798. * * 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
  75799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75800. * @param name defines the name of the mesh
  75801. * @param options defines the options used to create the mesh
  75802. * @param scene defines the hosting scene
  75803. * @returns the tiled ground mesh
  75804. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  75805. */
  75806. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  75807. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75808. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  75809. vertexData.applyToMesh(tiledGround, options.updatable);
  75810. return tiledGround;
  75811. };
  75812. /**
  75813. * Creates a ground mesh from a height map
  75814. * * The parameter `url` sets the URL of the height map image resource.
  75815. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  75816. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  75817. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  75818. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  75819. * * 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.
  75820. * * 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).
  75821. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  75822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75823. * @param name defines the name of the mesh
  75824. * @param url defines the url to the height map
  75825. * @param options defines the options used to create the mesh
  75826. * @param scene defines the hosting scene
  75827. * @returns the ground mesh
  75828. * @see https://doc.babylonjs.com/babylon101/height_map
  75829. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  75830. */
  75831. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  75832. var width = options.width || 10.0;
  75833. var height = options.height || 10.0;
  75834. var subdivisions = options.subdivisions || 1 | 0;
  75835. var minHeight = options.minHeight || 0.0;
  75836. var maxHeight = options.maxHeight || 1.0;
  75837. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75838. var alphaFilter = options.alphaFilter || 0.0;
  75839. var updatable = options.updatable;
  75840. var onReady = options.onReady;
  75841. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75842. ground._subdivisionsX = subdivisions;
  75843. ground._subdivisionsY = subdivisions;
  75844. ground._width = width;
  75845. ground._height = height;
  75846. ground._maxX = ground._width / 2.0;
  75847. ground._maxZ = ground._height / 2.0;
  75848. ground._minX = -ground._maxX;
  75849. ground._minZ = -ground._maxZ;
  75850. ground._setReady(false);
  75851. var onload = function (img) {
  75852. // Getting height map data
  75853. var canvas = document.createElement("canvas");
  75854. var context = canvas.getContext("2d");
  75855. if (!context) {
  75856. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  75857. }
  75858. if (scene.isDisposed) {
  75859. return;
  75860. }
  75861. var bufferWidth = img.width;
  75862. var bufferHeight = img.height;
  75863. canvas.width = bufferWidth;
  75864. canvas.height = bufferHeight;
  75865. context.drawImage(img, 0, 0);
  75866. // Create VertexData from map data
  75867. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  75868. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  75869. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  75870. width: width, height: height,
  75871. subdivisions: subdivisions,
  75872. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  75873. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  75874. alphaFilter: alphaFilter
  75875. });
  75876. vertexData.applyToMesh(ground, updatable);
  75877. //execute ready callback, if set
  75878. if (onReady) {
  75879. onReady(ground);
  75880. }
  75881. ground._setReady(true);
  75882. };
  75883. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  75884. return ground;
  75885. };
  75886. return GroundBuilder;
  75887. }());
  75888. /***/ }),
  75889. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  75890. /*!*********************************************!*\
  75891. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  75892. \*********************************************/
  75893. /*! exports provided: IcoSphereBuilder */
  75894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75895. "use strict";
  75896. __webpack_require__.r(__webpack_exports__);
  75897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  75898. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75899. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75900. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75901. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  75902. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  75903. var radius = options.radius || 1;
  75904. var flat = (options.flat === undefined) ? true : options.flat;
  75905. var subdivisions = options.subdivisions || 4;
  75906. var radiusX = options.radiusX || radius;
  75907. var radiusY = options.radiusY || radius;
  75908. var radiusZ = options.radiusZ || radius;
  75909. var t = (1 + Math.sqrt(5)) / 2;
  75910. // 12 vertex x,y,z
  75911. var ico_vertices = [
  75912. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  75913. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  75914. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  75915. ];
  75916. // index of 3 vertex makes a face of icopshere
  75917. var ico_indices = [
  75918. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  75919. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  75920. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  75921. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  75922. ];
  75923. // vertex for uv have aliased position, not for UV
  75924. var vertices_unalias_id = [
  75925. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  75926. // vertex alias
  75927. 0,
  75928. 2,
  75929. 3,
  75930. 3,
  75931. 3,
  75932. 4,
  75933. 7,
  75934. 8,
  75935. 9,
  75936. 9,
  75937. 10,
  75938. 11 // 23: B + 12
  75939. ];
  75940. // uv as integer step (not pixels !)
  75941. var ico_vertexuv = [
  75942. 5, 1, 3, 1, 6, 4, 0, 0,
  75943. 5, 3, 4, 2, 2, 2, 4, 0,
  75944. 2, 0, 1, 1, 6, 0, 6, 2,
  75945. // vertex alias (for same vertex on different faces)
  75946. 0, 4,
  75947. 3, 3,
  75948. 4, 4,
  75949. 3, 1,
  75950. 4, 2,
  75951. 4, 4,
  75952. 0, 2,
  75953. 1, 1,
  75954. 2, 2,
  75955. 3, 3,
  75956. 1, 3,
  75957. 2, 4 // 23: B + 12
  75958. ];
  75959. // Vertices[0, 1, ...9, A, B] : position on UV plane
  75960. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  75961. // First island of uv mapping
  75962. // v = 4h 3+ 2
  75963. // v = 3h 9+ 4
  75964. // v = 2h 9+ 5 B
  75965. // v = 1h 9 1 0
  75966. // v = 0h 3 8 7 A
  75967. // u = 0 1 2 3 4 5 6 *a
  75968. // Second island of uv mapping
  75969. // v = 4h 0+ B+ 4+
  75970. // v = 3h A+ 2+
  75971. // v = 2h 7+ 6 3+
  75972. // v = 1h 8+ 3+
  75973. // v = 0h
  75974. // u = 0 1 2 3 4 5 6 *a
  75975. // Face layout on texture UV mapping
  75976. // ============
  75977. // \ 4 /\ 16 / ======
  75978. // \ / \ / /\ 11 /
  75979. // \/ 7 \/ / \ /
  75980. // ======= / 10 \/
  75981. // /\ 17 /\ =======
  75982. // / \ / \ \ 15 /\
  75983. // / 8 \/ 12 \ \ / \
  75984. // ============ \/ 6 \
  75985. // \ 18 /\ ============
  75986. // \ / \ \ 5 /\ 0 /
  75987. // \/ 13 \ \ / \ /
  75988. // ======= \/ 1 \/
  75989. // =============
  75990. // /\ 19 /\ 2 /\
  75991. // / \ / \ / \
  75992. // / 14 \/ 9 \/ 3 \
  75993. // ===================
  75994. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  75995. var ustep = 138 / 1024;
  75996. var vstep = 239 / 1024;
  75997. var uoffset = 60 / 1024;
  75998. var voffset = 26 / 1024;
  75999. // Second island should have margin, not to touch the first island
  76000. // avoid any borderline artefact in pixel rounding
  76001. var island_u_offset = -40 / 1024;
  76002. var island_v_offset = +20 / 1024;
  76003. // face is either island 0 or 1 :
  76004. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  76005. var island = [
  76006. 0, 0, 0, 0, 1,
  76007. 0, 0, 1, 1, 0,
  76008. 0, 0, 1, 1, 0,
  76009. 0, 1, 1, 1, 0 // 15 - 19
  76010. ];
  76011. var indices = new Array();
  76012. var positions = new Array();
  76013. var normals = new Array();
  76014. var uvs = new Array();
  76015. var current_indice = 0;
  76016. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  76017. var face_vertex_pos = new Array(3);
  76018. var face_vertex_uv = new Array(3);
  76019. var v012;
  76020. for (v012 = 0; v012 < 3; v012++) {
  76021. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76022. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  76023. }
  76024. // create all with normals
  76025. for (var face = 0; face < 20; face++) {
  76026. // 3 vertex per face
  76027. for (v012 = 0; v012 < 3; v012++) {
  76028. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  76029. var v_id = ico_indices[3 * face + v012];
  76030. // vertex have 3D position (x,y,z)
  76031. 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]);
  76032. // Normalize to get normal, then scale to radius
  76033. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  76034. // uv Coordinates from vertex ID
  76035. 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);
  76036. }
  76037. // Subdivide the face (interpolate pos, norm, uv)
  76038. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  76039. // - norm is linear interpolation of vertex corner normal
  76040. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  76041. // - uv is linear interpolation
  76042. //
  76043. // Topology is as below for sub-divide by 2
  76044. // vertex shown as v0,v1,v2
  76045. // interp index is i1 to progress in range [v0,v1[
  76046. // interp index is i2 to progress in range [v0,v2[
  76047. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  76048. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  76049. //
  76050. //
  76051. // i2 v2
  76052. // ^ ^
  76053. // / / \
  76054. // / / \
  76055. // / / \
  76056. // / / (0,1) \
  76057. // / #---------\
  76058. // / / \ (0,0)'/ \
  76059. // / / \ / \
  76060. // / / \ / \
  76061. // / / (0,0) \ / (1,0) \
  76062. // / #---------#---------\
  76063. // v0 v1
  76064. //
  76065. // --------------------> i1
  76066. //
  76067. // interp of (i1,i2):
  76068. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  76069. // along i1 : lerp(x0,x1, i1/(S-i2))
  76070. //
  76071. // centroid of triangle is needed to get help normal computation
  76072. // (c1,c2) are used for centroid location
  76073. var interp_vertex = function (i1, i2, c1, c2) {
  76074. // vertex is interpolated from
  76075. // - face_vertex_pos[0..2]
  76076. // - face_vertex_uv[0..2]
  76077. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  76078. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  76079. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  76080. pos_interp.normalize();
  76081. var vertex_normal;
  76082. if (flat) {
  76083. // in flat mode, recalculate normal as face centroid normal
  76084. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  76085. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  76086. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  76087. }
  76088. else {
  76089. // in smooth mode, recalculate normal from each single vertex position
  76090. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  76091. }
  76092. // Vertex normal need correction due to X,Y,Z radius scaling
  76093. vertex_normal.x /= radiusX;
  76094. vertex_normal.y /= radiusY;
  76095. vertex_normal.z /= radiusZ;
  76096. vertex_normal.normalize();
  76097. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  76098. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  76099. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  76100. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  76101. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  76102. uvs.push(uv_interp.x, uv_interp.y);
  76103. // push each vertex has member of a face
  76104. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  76105. indices.push(current_indice);
  76106. current_indice++;
  76107. };
  76108. for (var i2 = 0; i2 < subdivisions; i2++) {
  76109. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  76110. // face : (i1,i2) for /\ :
  76111. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  76112. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76113. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76114. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76115. if (i1 + i2 + 1 < subdivisions) {
  76116. // face : (i1,i2)' for \/ :
  76117. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  76118. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76119. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76120. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76121. }
  76122. }
  76123. }
  76124. }
  76125. // Sides
  76126. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76127. // Result
  76128. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76129. vertexData.indices = indices;
  76130. vertexData.positions = positions;
  76131. vertexData.normals = normals;
  76132. vertexData.uvs = uvs;
  76133. return vertexData;
  76134. };
  76135. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  76136. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  76137. };
  76138. /**
  76139. * Class containing static functions to help procedurally build meshes
  76140. */
  76141. var IcoSphereBuilder = /** @class */ (function () {
  76142. function IcoSphereBuilder() {
  76143. }
  76144. /**
  76145. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76146. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76147. * * 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`)
  76148. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76149. * * 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
  76150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76151. * * 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
  76152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76153. * @param name defines the name of the mesh
  76154. * @param options defines the options used to create the mesh
  76155. * @param scene defines the hosting scene
  76156. * @returns the icosahedron mesh
  76157. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76158. */
  76159. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  76160. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76161. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76162. sphere._originalBuilderSideOrientation = options.sideOrientation;
  76163. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  76164. vertexData.applyToMesh(sphere, options.updatable);
  76165. return sphere;
  76166. };
  76167. return IcoSphereBuilder;
  76168. }());
  76169. /***/ }),
  76170. /***/ "./Meshes/Builders/index.ts":
  76171. /*!**********************************!*\
  76172. !*** ./Meshes/Builders/index.ts ***!
  76173. \**********************************/
  76174. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  76175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76176. "use strict";
  76177. __webpack_require__.r(__webpack_exports__);
  76178. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  76179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  76180. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  76181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  76182. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  76184. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  76185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  76186. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  76187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  76188. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  76189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  76190. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  76191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  76192. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  76193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  76194. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  76195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  76196. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  76197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  76198. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  76199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  76200. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  76201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  76202. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  76203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  76204. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  76205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  76206. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  76207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  76208. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  76209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  76210. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  76211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  76212. /***/ }),
  76213. /***/ "./Meshes/Builders/latheBuilder.ts":
  76214. /*!*****************************************!*\
  76215. !*** ./Meshes/Builders/latheBuilder.ts ***!
  76216. \*****************************************/
  76217. /*! exports provided: LatheBuilder */
  76218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76219. "use strict";
  76220. __webpack_require__.r(__webpack_exports__);
  76221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  76222. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76223. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76224. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76225. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  76226. var options = {
  76227. shape: shape,
  76228. radius: radius,
  76229. tessellation: tessellation,
  76230. sideOrientation: sideOrientation,
  76231. updatable: updatable
  76232. };
  76233. return LatheBuilder.CreateLathe(name, options, scene);
  76234. };
  76235. /**
  76236. * Class containing static functions to help procedurally build meshes
  76237. */
  76238. var LatheBuilder = /** @class */ (function () {
  76239. function LatheBuilder() {
  76240. }
  76241. /**
  76242. * Creates lathe mesh.
  76243. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  76244. * * 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
  76245. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  76246. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  76247. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  76248. * * 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
  76249. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  76250. * * 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
  76251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76252. * * 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
  76253. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  76254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76255. * @param name defines the name of the mesh
  76256. * @param options defines the options used to create the mesh
  76257. * @param scene defines the hosting scene
  76258. * @returns the lathe mesh
  76259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  76260. */
  76261. LatheBuilder.CreateLathe = function (name, options, scene) {
  76262. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  76263. var closed = (options.closed === undefined) ? true : options.closed;
  76264. var shape = options.shape;
  76265. var radius = options.radius || 1;
  76266. var tessellation = options.tessellation || 64;
  76267. var clip = options.clip || 0;
  76268. var updatable = options.updatable;
  76269. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76270. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  76271. var pi2 = Math.PI * 2;
  76272. var paths = new Array();
  76273. var invertUV = options.invertUV || false;
  76274. var i = 0;
  76275. var p = 0;
  76276. var step = pi2 / tessellation * arc;
  76277. var rotated;
  76278. var path = new Array();
  76279. for (i = 0; i <= tessellation - clip; i++) {
  76280. var path = [];
  76281. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76282. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  76283. 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));
  76284. }
  76285. for (p = 0; p < shape.length; p++) {
  76286. 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);
  76287. path.push(rotated);
  76288. }
  76289. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76290. 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));
  76291. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  76292. }
  76293. paths.push(path);
  76294. }
  76295. // lathe ribbon
  76296. 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);
  76297. return lathe;
  76298. };
  76299. return LatheBuilder;
  76300. }());
  76301. /***/ }),
  76302. /***/ "./Meshes/Builders/linesBuilder.ts":
  76303. /*!*****************************************!*\
  76304. !*** ./Meshes/Builders/linesBuilder.ts ***!
  76305. \*****************************************/
  76306. /*! exports provided: LinesBuilder */
  76307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76308. "use strict";
  76309. __webpack_require__.r(__webpack_exports__);
  76310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  76311. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76312. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76313. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76314. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  76315. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76316. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  76317. var indices = [];
  76318. var positions = [];
  76319. var lines = options.lines;
  76320. var colors = options.colors;
  76321. var vertexColors = [];
  76322. var idx = 0;
  76323. for (var l = 0; l < lines.length; l++) {
  76324. var points = lines[l];
  76325. for (var index = 0; index < points.length; index++) {
  76326. positions.push(points[index].x, points[index].y, points[index].z);
  76327. if (colors) {
  76328. var color = colors[l];
  76329. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  76330. }
  76331. if (index > 0) {
  76332. indices.push(idx - 1);
  76333. indices.push(idx);
  76334. }
  76335. idx++;
  76336. }
  76337. }
  76338. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76339. vertexData.indices = indices;
  76340. vertexData.positions = positions;
  76341. if (colors) {
  76342. vertexData.colors = vertexColors;
  76343. }
  76344. return vertexData;
  76345. };
  76346. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  76347. var dashSize = options.dashSize || 3;
  76348. var gapSize = options.gapSize || 1;
  76349. var dashNb = options.dashNb || 200;
  76350. var points = options.points;
  76351. var positions = new Array();
  76352. var indices = new Array();
  76353. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76354. var lg = 0;
  76355. var nb = 0;
  76356. var shft = 0;
  76357. var dashshft = 0;
  76358. var curshft = 0;
  76359. var idx = 0;
  76360. var i = 0;
  76361. for (i = 0; i < points.length - 1; i++) {
  76362. points[i + 1].subtractToRef(points[i], curvect);
  76363. lg += curvect.length();
  76364. }
  76365. shft = lg / dashNb;
  76366. dashshft = dashSize * shft / (dashSize + gapSize);
  76367. for (i = 0; i < points.length - 1; i++) {
  76368. points[i + 1].subtractToRef(points[i], curvect);
  76369. nb = Math.floor(curvect.length() / shft);
  76370. curvect.normalize();
  76371. for (var j = 0; j < nb; j++) {
  76372. curshft = shft * j;
  76373. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  76374. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  76375. indices.push(idx, idx + 1);
  76376. idx += 2;
  76377. }
  76378. }
  76379. // Result
  76380. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76381. vertexData.positions = positions;
  76382. vertexData.indices = indices;
  76383. return vertexData;
  76384. };
  76385. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  76386. if (scene === void 0) { scene = null; }
  76387. if (updatable === void 0) { updatable = false; }
  76388. if (instance === void 0) { instance = null; }
  76389. var options = {
  76390. points: points,
  76391. updatable: updatable,
  76392. instance: instance
  76393. };
  76394. return LinesBuilder.CreateLines(name, options, scene);
  76395. };
  76396. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  76397. if (scene === void 0) { scene = null; }
  76398. var options = {
  76399. points: points,
  76400. dashSize: dashSize,
  76401. gapSize: gapSize,
  76402. dashNb: dashNb,
  76403. updatable: updatable,
  76404. instance: instance
  76405. };
  76406. return LinesBuilder.CreateDashedLines(name, options, scene);
  76407. };
  76408. /**
  76409. * Class containing static functions to help procedurally build meshes
  76410. */
  76411. var LinesBuilder = /** @class */ (function () {
  76412. function LinesBuilder() {
  76413. }
  76414. /**
  76415. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  76416. * * 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
  76417. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  76418. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  76419. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  76420. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  76421. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  76422. * * 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
  76423. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  76424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  76426. * @param name defines the name of the new line system
  76427. * @param options defines the options used to create the line system
  76428. * @param scene defines the hosting scene
  76429. * @returns a new line system mesh
  76430. */
  76431. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  76432. var instance = options.instance;
  76433. var lines = options.lines;
  76434. var colors = options.colors;
  76435. if (instance) { // lines update
  76436. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76437. var vertexColor;
  76438. var lineColors;
  76439. if (colors) {
  76440. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  76441. }
  76442. var i = 0;
  76443. var c = 0;
  76444. for (var l = 0; l < lines.length; l++) {
  76445. var points = lines[l];
  76446. for (var p = 0; p < points.length; p++) {
  76447. positions[i] = points[p].x;
  76448. positions[i + 1] = points[p].y;
  76449. positions[i + 2] = points[p].z;
  76450. if (colors && vertexColor) {
  76451. lineColors = colors[l];
  76452. vertexColor[c] = lineColors[p].r;
  76453. vertexColor[c + 1] = lineColors[p].g;
  76454. vertexColor[c + 2] = lineColors[p].b;
  76455. vertexColor[c + 3] = lineColors[p].a;
  76456. c += 4;
  76457. }
  76458. i += 3;
  76459. }
  76460. }
  76461. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  76462. if (colors && vertexColor) {
  76463. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  76464. }
  76465. return instance;
  76466. }
  76467. // line system creation
  76468. var useVertexColor = (colors) ? true : false;
  76469. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  76470. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  76471. vertexData.applyToMesh(lineSystem, options.updatable);
  76472. return lineSystem;
  76473. };
  76474. /**
  76475. * Creates a line mesh
  76476. * 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
  76477. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76478. * * The parameter `points` is an array successive Vector3
  76479. * * 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
  76480. * * The optional parameter `colors` is an array of successive Color4, one per line point
  76481. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  76482. * * When updating an instance, remember that only point positions can change, not the number of points
  76483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  76485. * @param name defines the name of the new line system
  76486. * @param options defines the options used to create the line system
  76487. * @param scene defines the hosting scene
  76488. * @returns a new line mesh
  76489. */
  76490. LinesBuilder.CreateLines = function (name, options, scene) {
  76491. if (scene === void 0) { scene = null; }
  76492. var colors = (options.colors) ? [options.colors] : null;
  76493. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  76494. return lines;
  76495. };
  76496. /**
  76497. * Creates a dashed line mesh
  76498. * * 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
  76499. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76500. * * The parameter `points` is an array successive Vector3
  76501. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  76502. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  76503. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76504. * * 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
  76505. * * When updating an instance, remember that only point positions can change, not the number of points
  76506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76507. * @param name defines the name of the mesh
  76508. * @param options defines the options used to create the mesh
  76509. * @param scene defines the hosting scene
  76510. * @returns the dashed line mesh
  76511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  76512. */
  76513. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  76514. if (scene === void 0) { scene = null; }
  76515. var points = options.points;
  76516. var instance = options.instance;
  76517. var gapSize = options.gapSize || 1;
  76518. var dashSize = options.dashSize || 3;
  76519. if (instance) { // dashed lines update
  76520. var positionFunction = function (positions) {
  76521. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76522. var nbSeg = positions.length / 6;
  76523. var lg = 0;
  76524. var nb = 0;
  76525. var shft = 0;
  76526. var dashshft = 0;
  76527. var curshft = 0;
  76528. var p = 0;
  76529. var i = 0;
  76530. var j = 0;
  76531. for (i = 0; i < points.length - 1; i++) {
  76532. points[i + 1].subtractToRef(points[i], curvect);
  76533. lg += curvect.length();
  76534. }
  76535. shft = lg / nbSeg;
  76536. var dashSize = instance._creationDataStorage.dashSize;
  76537. var gapSize = instance._creationDataStorage.gapSize;
  76538. dashshft = dashSize * shft / (dashSize + gapSize);
  76539. for (i = 0; i < points.length - 1; i++) {
  76540. points[i + 1].subtractToRef(points[i], curvect);
  76541. nb = Math.floor(curvect.length() / shft);
  76542. curvect.normalize();
  76543. j = 0;
  76544. while (j < nb && p < positions.length) {
  76545. curshft = shft * j;
  76546. positions[p] = points[i].x + curshft * curvect.x;
  76547. positions[p + 1] = points[i].y + curshft * curvect.y;
  76548. positions[p + 2] = points[i].z + curshft * curvect.z;
  76549. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  76550. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  76551. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  76552. p += 6;
  76553. j++;
  76554. }
  76555. }
  76556. while (p < positions.length) {
  76557. positions[p] = points[i].x;
  76558. positions[p + 1] = points[i].y;
  76559. positions[p + 2] = points[i].z;
  76560. p += 3;
  76561. }
  76562. };
  76563. instance.updateMeshPositions(positionFunction, false);
  76564. return instance;
  76565. }
  76566. // dashed lines creation
  76567. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  76568. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  76569. vertexData.applyToMesh(dashedLines, options.updatable);
  76570. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  76571. dashedLines._creationDataStorage.dashSize = dashSize;
  76572. dashedLines._creationDataStorage.gapSize = gapSize;
  76573. return dashedLines;
  76574. };
  76575. return LinesBuilder;
  76576. }());
  76577. /***/ }),
  76578. /***/ "./Meshes/Builders/planeBuilder.ts":
  76579. /*!*****************************************!*\
  76580. !*** ./Meshes/Builders/planeBuilder.ts ***!
  76581. \*****************************************/
  76582. /*! exports provided: PlaneBuilder */
  76583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76584. "use strict";
  76585. __webpack_require__.r(__webpack_exports__);
  76586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  76587. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76588. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76589. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  76590. var indices = [];
  76591. var positions = [];
  76592. var normals = [];
  76593. var uvs = [];
  76594. var width = options.width || options.size || 1;
  76595. var height = options.height || options.size || 1;
  76596. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  76597. // Vertices
  76598. var halfWidth = width / 2.0;
  76599. var halfHeight = height / 2.0;
  76600. positions.push(-halfWidth, -halfHeight, 0);
  76601. normals.push(0, 0, -1.0);
  76602. uvs.push(0.0, 0.0);
  76603. positions.push(halfWidth, -halfHeight, 0);
  76604. normals.push(0, 0, -1.0);
  76605. uvs.push(1.0, 0.0);
  76606. positions.push(halfWidth, halfHeight, 0);
  76607. normals.push(0, 0, -1.0);
  76608. uvs.push(1.0, 1.0);
  76609. positions.push(-halfWidth, halfHeight, 0);
  76610. normals.push(0, 0, -1.0);
  76611. uvs.push(0.0, 1.0);
  76612. // Indices
  76613. indices.push(0);
  76614. indices.push(1);
  76615. indices.push(2);
  76616. indices.push(0);
  76617. indices.push(2);
  76618. indices.push(3);
  76619. // Sides
  76620. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76621. // Result
  76622. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  76623. vertexData.indices = indices;
  76624. vertexData.positions = positions;
  76625. vertexData.normals = normals;
  76626. vertexData.uvs = uvs;
  76627. return vertexData;
  76628. };
  76629. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  76630. var options = {
  76631. size: size,
  76632. width: size,
  76633. height: size,
  76634. sideOrientation: sideOrientation,
  76635. updatable: updatable
  76636. };
  76637. return PlaneBuilder.CreatePlane(name, options, scene);
  76638. };
  76639. /**
  76640. * Class containing static functions to help procedurally build meshes
  76641. */
  76642. var PlaneBuilder = /** @class */ (function () {
  76643. function PlaneBuilder() {
  76644. }
  76645. /**
  76646. * Creates a plane mesh
  76647. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  76648. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  76649. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  76650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76651. * * 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
  76652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76653. * @param name defines the name of the mesh
  76654. * @param options defines the options used to create the mesh
  76655. * @param scene defines the hosting scene
  76656. * @returns the plane mesh
  76657. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  76658. */
  76659. PlaneBuilder.CreatePlane = function (name, options, scene) {
  76660. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  76661. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76662. plane._originalBuilderSideOrientation = options.sideOrientation;
  76663. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  76664. vertexData.applyToMesh(plane, options.updatable);
  76665. if (options.sourcePlane) {
  76666. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  76667. plane.setDirection(options.sourcePlane.normal.scale(-1));
  76668. }
  76669. return plane;
  76670. };
  76671. return PlaneBuilder;
  76672. }());
  76673. /***/ }),
  76674. /***/ "./Meshes/Builders/polygonBuilder.ts":
  76675. /*!*******************************************!*\
  76676. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  76677. \*******************************************/
  76678. /*! exports provided: PolygonBuilder */
  76679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76680. "use strict";
  76681. __webpack_require__.r(__webpack_exports__);
  76682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  76683. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76684. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76685. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76686. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  76687. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76688. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  76689. var faceUV = fUV || new Array(3);
  76690. var faceColors = fColors;
  76691. var colors = [];
  76692. // default face colors and UV if undefined
  76693. for (var f = 0; f < 3; f++) {
  76694. if (faceUV[f] === undefined) {
  76695. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76696. }
  76697. if (faceColors && faceColors[f] === undefined) {
  76698. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76699. }
  76700. }
  76701. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76702. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  76703. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  76704. var indices = polygon.getIndices();
  76705. // set face colours and textures
  76706. var idx = 0;
  76707. var face = 0;
  76708. for (var index = 0; index < normals.length; index += 3) {
  76709. //Edge Face no. 1
  76710. if (Math.abs(normals[index + 1]) < 0.001) {
  76711. face = 1;
  76712. }
  76713. //Top Face no. 0
  76714. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  76715. face = 0;
  76716. }
  76717. //Bottom Face no. 2
  76718. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  76719. face = 2;
  76720. }
  76721. idx = index / 3;
  76722. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  76723. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  76724. if (faceColors) {
  76725. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  76726. }
  76727. }
  76728. // sides
  76729. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  76730. // Result
  76731. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76732. vertexData.indices = indices;
  76733. vertexData.positions = positions;
  76734. vertexData.normals = normals;
  76735. vertexData.uvs = uvs;
  76736. if (faceColors) {
  76737. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  76738. vertexData.colors = totalColors;
  76739. }
  76740. return vertexData;
  76741. };
  76742. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  76743. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76744. var options = {
  76745. shape: shape,
  76746. holes: holes,
  76747. updatable: updatable,
  76748. sideOrientation: sideOrientation
  76749. };
  76750. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76751. };
  76752. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  76753. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76754. var options = {
  76755. shape: shape,
  76756. holes: holes,
  76757. depth: depth,
  76758. updatable: updatable,
  76759. sideOrientation: sideOrientation
  76760. };
  76761. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  76762. };
  76763. /**
  76764. * Class containing static functions to help procedurally build meshes
  76765. */
  76766. var PolygonBuilder = /** @class */ (function () {
  76767. function PolygonBuilder() {
  76768. }
  76769. /**
  76770. * Creates a polygon mesh
  76771. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  76772. * * 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
  76773. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76775. * * 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)
  76776. * * Remember you can only change the shape positions, not their number when updating a polygon
  76777. * @param name defines the name of the mesh
  76778. * @param options defines the options used to create the mesh
  76779. * @param scene defines the hosting scene
  76780. * @param earcutInjection can be used to inject your own earcut reference
  76781. * @returns the polygon mesh
  76782. */
  76783. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  76784. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76785. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76786. var shape = options.shape;
  76787. var holes = options.holes || [];
  76788. var depth = options.depth || 0;
  76789. var contours = [];
  76790. var hole = [];
  76791. for (var i = 0; i < shape.length; i++) {
  76792. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  76793. }
  76794. var epsilon = 0.00000001;
  76795. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  76796. contours.pop();
  76797. }
  76798. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  76799. for (var hNb = 0; hNb < holes.length; hNb++) {
  76800. hole = [];
  76801. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  76802. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  76803. }
  76804. polygonTriangulation.addHole(hole);
  76805. }
  76806. var polygon = polygonTriangulation.build(options.updatable, depth);
  76807. polygon._originalBuilderSideOrientation = options.sideOrientation;
  76808. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  76809. vertexData.applyToMesh(polygon, options.updatable);
  76810. return polygon;
  76811. };
  76812. /**
  76813. * Creates an extruded polygon mesh, with depth in the Y direction.
  76814. * * 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)
  76815. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  76816. * @param name defines the name of the mesh
  76817. * @param options defines the options used to create the mesh
  76818. * @param scene defines the hosting scene
  76819. * @param earcutInjection can be used to inject your own earcut reference
  76820. * @returns the polygon mesh
  76821. */
  76822. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  76823. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76824. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76825. };
  76826. return PolygonBuilder;
  76827. }());
  76828. /***/ }),
  76829. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  76830. /*!**********************************************!*\
  76831. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  76832. \**********************************************/
  76833. /*! exports provided: PolyhedronBuilder */
  76834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76835. "use strict";
  76836. __webpack_require__.r(__webpack_exports__);
  76837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  76838. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76839. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76840. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76841. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  76842. // provided polyhedron types :
  76843. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  76844. // 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)
  76845. var polyhedra = [];
  76846. 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]] };
  76847. 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]] };
  76848. polyhedra[2] = {
  76849. 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]],
  76850. 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]]
  76851. };
  76852. polyhedra[3] = {
  76853. 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]],
  76854. 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]]
  76855. };
  76856. polyhedra[4] = {
  76857. 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]],
  76858. 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]]
  76859. };
  76860. 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]] };
  76861. 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]] };
  76862. 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]] };
  76863. 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]] };
  76864. 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]] };
  76865. 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]] };
  76866. 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]] };
  76867. 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]] };
  76868. 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]] };
  76869. polyhedra[14] = {
  76870. 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]],
  76871. 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]]
  76872. };
  76873. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  76874. var size = options.size;
  76875. var sizeX = options.sizeX || size || 1;
  76876. var sizeY = options.sizeY || size || 1;
  76877. var sizeZ = options.sizeZ || size || 1;
  76878. var data = options.custom || polyhedra[type];
  76879. var nbfaces = data.face.length;
  76880. var faceUV = options.faceUV || new Array(nbfaces);
  76881. var faceColors = options.faceColors;
  76882. var flat = (options.flat === undefined) ? true : options.flat;
  76883. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76884. var positions = new Array();
  76885. var indices = new Array();
  76886. var normals = new Array();
  76887. var uvs = new Array();
  76888. var colors = new Array();
  76889. var index = 0;
  76890. var faceIdx = 0; // face cursor in the array "indexes"
  76891. var indexes = new Array();
  76892. var i = 0;
  76893. var f = 0;
  76894. var u, v, ang, x, y, tmp;
  76895. // default face colors and UV if undefined
  76896. if (flat) {
  76897. for (f = 0; f < nbfaces; f++) {
  76898. if (faceColors && faceColors[f] === undefined) {
  76899. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76900. }
  76901. if (faceUV && faceUV[f] === undefined) {
  76902. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76903. }
  76904. }
  76905. }
  76906. if (!flat) {
  76907. for (i = 0; i < data.vertex.length; i++) {
  76908. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  76909. uvs.push(0, 0);
  76910. }
  76911. for (f = 0; f < nbfaces; f++) {
  76912. for (i = 0; i < data.face[f].length - 2; i++) {
  76913. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  76914. }
  76915. }
  76916. }
  76917. else {
  76918. for (f = 0; f < nbfaces; f++) {
  76919. var fl = data.face[f].length; // number of vertices of the current face
  76920. ang = 2 * Math.PI / fl;
  76921. x = 0.5 * Math.tan(ang / 2);
  76922. y = 0.5;
  76923. // positions, uvs, colors
  76924. for (i = 0; i < fl; i++) {
  76925. // positions
  76926. 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);
  76927. indexes.push(index);
  76928. index++;
  76929. // uvs
  76930. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  76931. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  76932. uvs.push(u, v);
  76933. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  76934. y = x * Math.sin(ang) + y * Math.cos(ang);
  76935. x = tmp;
  76936. // colors
  76937. if (faceColors) {
  76938. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  76939. }
  76940. }
  76941. // indices from indexes
  76942. for (i = 0; i < fl - 2; i++) {
  76943. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  76944. }
  76945. faceIdx += fl;
  76946. }
  76947. }
  76948. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  76949. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76950. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76951. vertexData.positions = positions;
  76952. vertexData.indices = indices;
  76953. vertexData.normals = normals;
  76954. vertexData.uvs = uvs;
  76955. if (faceColors && flat) {
  76956. vertexData.colors = colors;
  76957. }
  76958. return vertexData;
  76959. };
  76960. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  76961. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  76962. };
  76963. /**
  76964. * Class containing static functions to help procedurally build meshes
  76965. */
  76966. var PolyhedronBuilder = /** @class */ (function () {
  76967. function PolyhedronBuilder() {
  76968. }
  76969. /**
  76970. * Creates a polyhedron mesh
  76971. * * 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
  76972. * * The parameter `size` (positive float, default 1) sets the polygon size
  76973. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76974. * * 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`
  76975. * * 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
  76976. * * 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)`)
  76977. * * 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
  76978. * * 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
  76979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76980. * * 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
  76981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76982. * @param name defines the name of the mesh
  76983. * @param options defines the options used to create the mesh
  76984. * @param scene defines the hosting scene
  76985. * @returns the polyhedron mesh
  76986. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  76987. */
  76988. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  76989. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76990. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76991. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  76992. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  76993. vertexData.applyToMesh(polyhedron, options.updatable);
  76994. return polyhedron;
  76995. };
  76996. return PolyhedronBuilder;
  76997. }());
  76998. /***/ }),
  76999. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  77000. /*!******************************************!*\
  77001. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  77002. \******************************************/
  77003. /*! exports provided: RibbonBuilder */
  77004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77005. "use strict";
  77006. __webpack_require__.r(__webpack_exports__);
  77007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  77008. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77009. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77010. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  77011. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77012. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  77013. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  77014. var pathArray = options.pathArray;
  77015. var closeArray = options.closeArray || false;
  77016. var closePath = options.closePath || false;
  77017. var invertUV = options.invertUV || false;
  77018. var defaultOffset = Math.floor(pathArray[0].length / 2);
  77019. var offset = options.offset || defaultOffset;
  77020. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  77021. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  77022. var customUV = options.uvs;
  77023. var customColors = options.colors;
  77024. var positions = [];
  77025. var indices = [];
  77026. var normals = [];
  77027. var uvs = [];
  77028. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  77029. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  77030. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  77031. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  77032. var minlg; // minimal length among all paths from pathArray
  77033. var lg = []; // array of path lengths : nb of vertex per path
  77034. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  77035. var p; // path iterator
  77036. var i; // point iterator
  77037. var j; // point iterator
  77038. // if single path in pathArray
  77039. if (pathArray.length < 2) {
  77040. var ar1 = [];
  77041. var ar2 = [];
  77042. for (i = 0; i < pathArray[0].length - offset; i++) {
  77043. ar1.push(pathArray[0][i]);
  77044. ar2.push(pathArray[0][i + offset]);
  77045. }
  77046. pathArray = [ar1, ar2];
  77047. }
  77048. // positions and horizontal distances (u)
  77049. var idc = 0;
  77050. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  77051. var path;
  77052. var l;
  77053. minlg = pathArray[0].length;
  77054. var vectlg;
  77055. var dist;
  77056. for (p = 0; p < pathArray.length; p++) {
  77057. uTotalDistance[p] = 0;
  77058. us[p] = [0];
  77059. path = pathArray[p];
  77060. l = path.length;
  77061. minlg = (minlg < l) ? minlg : l;
  77062. j = 0;
  77063. while (j < l) {
  77064. positions.push(path[j].x, path[j].y, path[j].z);
  77065. if (j > 0) {
  77066. vectlg = path[j].subtract(path[j - 1]).length();
  77067. dist = vectlg + uTotalDistance[p];
  77068. us[p].push(dist);
  77069. uTotalDistance[p] = dist;
  77070. }
  77071. j++;
  77072. }
  77073. if (closePath) { // an extra hidden vertex is added in the "positions" array
  77074. j--;
  77075. positions.push(path[0].x, path[0].y, path[0].z);
  77076. vectlg = path[j].subtract(path[0]).length();
  77077. dist = vectlg + uTotalDistance[p];
  77078. us[p].push(dist);
  77079. uTotalDistance[p] = dist;
  77080. }
  77081. lg[p] = l + closePathCorr;
  77082. idx[p] = idc;
  77083. idc += (l + closePathCorr);
  77084. }
  77085. // vertical distances (v)
  77086. var path1;
  77087. var path2;
  77088. var vertex1 = null;
  77089. var vertex2 = null;
  77090. for (i = 0; i < minlg + closePathCorr; i++) {
  77091. vTotalDistance[i] = 0;
  77092. vs[i] = [0];
  77093. for (p = 0; p < pathArray.length - 1; p++) {
  77094. path1 = pathArray[p];
  77095. path2 = pathArray[p + 1];
  77096. if (i === minlg) { // closePath
  77097. vertex1 = path1[0];
  77098. vertex2 = path2[0];
  77099. }
  77100. else {
  77101. vertex1 = path1[i];
  77102. vertex2 = path2[i];
  77103. }
  77104. vectlg = vertex2.subtract(vertex1).length();
  77105. dist = vectlg + vTotalDistance[i];
  77106. vs[i].push(dist);
  77107. vTotalDistance[i] = dist;
  77108. }
  77109. if (closeArray && vertex2 && vertex1) {
  77110. path1 = pathArray[p];
  77111. path2 = pathArray[0];
  77112. if (i === minlg) { // closePath
  77113. vertex2 = path2[0];
  77114. }
  77115. vectlg = vertex2.subtract(vertex1).length();
  77116. dist = vectlg + vTotalDistance[i];
  77117. vTotalDistance[i] = dist;
  77118. }
  77119. }
  77120. // uvs
  77121. var u;
  77122. var v;
  77123. if (customUV) {
  77124. for (p = 0; p < customUV.length; p++) {
  77125. uvs.push(customUV[p].x, customUV[p].y);
  77126. }
  77127. }
  77128. else {
  77129. for (p = 0; p < pathArray.length; p++) {
  77130. for (i = 0; i < minlg + closePathCorr; i++) {
  77131. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  77132. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  77133. if (invertUV) {
  77134. uvs.push(v, u);
  77135. }
  77136. else {
  77137. uvs.push(u, v);
  77138. }
  77139. }
  77140. }
  77141. }
  77142. // indices
  77143. p = 0; // path index
  77144. var pi = 0; // positions array index
  77145. var l1 = lg[p] - 1; // path1 length
  77146. var l2 = lg[p + 1] - 1; // path2 length
  77147. var min = (l1 < l2) ? l1 : l2; // current path stop index
  77148. var shft = idx[1] - idx[0]; // shift
  77149. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  77150. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  77151. // 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
  77152. indices.push(pi, pi + shft, pi + 1);
  77153. indices.push(pi + shft + 1, pi + 1, pi + shft);
  77154. pi += 1;
  77155. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  77156. p++;
  77157. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  77158. shft = idx[0] - idx[p];
  77159. l1 = lg[p] - 1;
  77160. l2 = lg[0] - 1;
  77161. }
  77162. else {
  77163. shft = idx[p + 1] - idx[p];
  77164. l1 = lg[p] - 1;
  77165. l2 = lg[p + 1] - 1;
  77166. }
  77167. pi = idx[p];
  77168. min = (l1 < l2) ? l1 + pi : l2 + pi;
  77169. }
  77170. }
  77171. // normals
  77172. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  77173. if (closePath) { // update both the first and last vertex normals to their average value
  77174. var indexFirst = 0;
  77175. var indexLast = 0;
  77176. for (p = 0; p < pathArray.length; p++) {
  77177. indexFirst = idx[p] * 3;
  77178. if (p + 1 < pathArray.length) {
  77179. indexLast = (idx[p + 1] - 1) * 3;
  77180. }
  77181. else {
  77182. indexLast = normals.length - 3;
  77183. }
  77184. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77185. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77186. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77187. normals[indexLast] = normals[indexFirst];
  77188. normals[indexLast + 1] = normals[indexFirst + 1];
  77189. normals[indexLast + 2] = normals[indexFirst + 2];
  77190. }
  77191. }
  77192. // sides
  77193. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77194. // Colors
  77195. var colors = null;
  77196. if (customColors) {
  77197. colors = new Float32Array(customColors.length * 4);
  77198. for (var c = 0; c < customColors.length; c++) {
  77199. colors[c * 4] = customColors[c].r;
  77200. colors[c * 4 + 1] = customColors[c].g;
  77201. colors[c * 4 + 2] = customColors[c].b;
  77202. colors[c * 4 + 3] = customColors[c].a;
  77203. }
  77204. }
  77205. // Result
  77206. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  77207. var positions32 = new Float32Array(positions);
  77208. var normals32 = new Float32Array(normals);
  77209. var uvs32 = new Float32Array(uvs);
  77210. vertexData.indices = indices;
  77211. vertexData.positions = positions32;
  77212. vertexData.normals = normals32;
  77213. vertexData.uvs = uvs32;
  77214. if (colors) {
  77215. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77216. }
  77217. if (closePath) {
  77218. vertexData._idx = idx;
  77219. }
  77220. return vertexData;
  77221. };
  77222. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  77223. if (closeArray === void 0) { closeArray = false; }
  77224. if (updatable === void 0) { updatable = false; }
  77225. return RibbonBuilder.CreateRibbon(name, {
  77226. pathArray: pathArray,
  77227. closeArray: closeArray,
  77228. closePath: closePath,
  77229. offset: offset,
  77230. updatable: updatable,
  77231. sideOrientation: sideOrientation,
  77232. instance: instance
  77233. }, scene);
  77234. };
  77235. /**
  77236. * Class containing static functions to help procedurally build meshes
  77237. */
  77238. var RibbonBuilder = /** @class */ (function () {
  77239. function RibbonBuilder() {
  77240. }
  77241. /**
  77242. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77243. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  77244. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  77245. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  77246. * * 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
  77247. * * 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
  77248. * * 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
  77249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77250. * * 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
  77251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77252. * * 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
  77253. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  77254. * * 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
  77255. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  77256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77257. * @param name defines the name of the mesh
  77258. * @param options defines the options used to create the mesh
  77259. * @param scene defines the hosting scene
  77260. * @returns the ribbon mesh
  77261. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  77262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77263. */
  77264. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  77265. if (scene === void 0) { scene = null; }
  77266. var pathArray = options.pathArray;
  77267. var closeArray = options.closeArray;
  77268. var closePath = options.closePath;
  77269. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77270. var instance = options.instance;
  77271. var updatable = options.updatable;
  77272. if (instance) { // existing ribbon instance update
  77273. // positionFunction : ribbon case
  77274. // only pathArray and sideOrientation parameters are taken into account for positions update
  77275. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  77276. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  77277. var positionFunction = function (positions) {
  77278. var minlg = pathArray[0].length;
  77279. var mesh = instance;
  77280. var i = 0;
  77281. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  77282. for (var si = 1; si <= ns; ++si) {
  77283. for (var p = 0; p < pathArray.length; ++p) {
  77284. var path = pathArray[p];
  77285. var l = path.length;
  77286. minlg = (minlg < l) ? minlg : l;
  77287. for (var j = 0; j < minlg; ++j) {
  77288. var pathPoint = path[j];
  77289. positions[i] = pathPoint.x;
  77290. positions[i + 1] = pathPoint.y;
  77291. positions[i + 2] = pathPoint.z;
  77292. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77293. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77294. i += 3;
  77295. }
  77296. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  77297. var pathPoint = path[0];
  77298. positions[i] = pathPoint.x;
  77299. positions[i + 1] = pathPoint.y;
  77300. positions[i + 2] = pathPoint.z;
  77301. i += 3;
  77302. }
  77303. }
  77304. }
  77305. };
  77306. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77307. positionFunction(positions);
  77308. if (instance._boundingInfo) {
  77309. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  77310. }
  77311. else {
  77312. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  77313. }
  77314. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  77315. if (options.colors) {
  77316. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77317. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  77318. var color = options.colors[c];
  77319. colors[colorIndex] = color.r;
  77320. colors[colorIndex + 1] = color.g;
  77321. colors[colorIndex + 2] = color.b;
  77322. colors[colorIndex + 3] = color.a;
  77323. }
  77324. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  77325. }
  77326. if (options.uvs) {
  77327. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  77328. for (var i = 0; i < options.uvs.length; i++) {
  77329. uvs[i * 2] = options.uvs[i].x;
  77330. uvs[i * 2 + 1] = options.uvs[i].y;
  77331. }
  77332. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  77333. }
  77334. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  77335. var indices = instance.getIndices();
  77336. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77337. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  77338. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  77339. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  77340. var indexFirst = 0;
  77341. var indexLast = 0;
  77342. for (var p = 0; p < pathArray.length; p++) {
  77343. indexFirst = instance._creationDataStorage.idx[p] * 3;
  77344. if (p + 1 < pathArray.length) {
  77345. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  77346. }
  77347. else {
  77348. indexLast = normals.length - 3;
  77349. }
  77350. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77351. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77352. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77353. normals[indexLast] = normals[indexFirst];
  77354. normals[indexLast + 1] = normals[indexFirst + 1];
  77355. normals[indexLast + 2] = normals[indexFirst + 2];
  77356. }
  77357. }
  77358. if (!(instance.areNormalsFrozen)) {
  77359. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  77360. }
  77361. }
  77362. return instance;
  77363. }
  77364. else { // new ribbon creation
  77365. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77366. ribbon._originalBuilderSideOrientation = sideOrientation;
  77367. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  77368. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  77369. if (closePath) {
  77370. ribbon._creationDataStorage.idx = vertexData._idx;
  77371. }
  77372. ribbon._creationDataStorage.closePath = closePath;
  77373. ribbon._creationDataStorage.closeArray = closeArray;
  77374. vertexData.applyToMesh(ribbon, updatable);
  77375. return ribbon;
  77376. }
  77377. };
  77378. return RibbonBuilder;
  77379. }());
  77380. /***/ }),
  77381. /***/ "./Meshes/Builders/shapeBuilder.ts":
  77382. /*!*****************************************!*\
  77383. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  77384. \*****************************************/
  77385. /*! exports provided: ShapeBuilder */
  77386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77387. "use strict";
  77388. __webpack_require__.r(__webpack_exports__);
  77389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  77390. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77391. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77392. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77393. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  77394. if (scene === void 0) { scene = null; }
  77395. var options = {
  77396. shape: shape,
  77397. path: path,
  77398. scale: scale,
  77399. rotation: rotation,
  77400. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77401. sideOrientation: sideOrientation,
  77402. instance: instance,
  77403. updatable: updatable
  77404. };
  77405. return ShapeBuilder.ExtrudeShape(name, options, scene);
  77406. };
  77407. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  77408. var options = {
  77409. shape: shape,
  77410. path: path,
  77411. scaleFunction: scaleFunction,
  77412. rotationFunction: rotationFunction,
  77413. ribbonCloseArray: ribbonCloseArray,
  77414. ribbonClosePath: ribbonClosePath,
  77415. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77416. sideOrientation: sideOrientation,
  77417. instance: instance,
  77418. updatable: updatable
  77419. };
  77420. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  77421. };
  77422. /**
  77423. * Class containing static functions to help procedurally build meshes
  77424. */
  77425. var ShapeBuilder = /** @class */ (function () {
  77426. function ShapeBuilder() {
  77427. }
  77428. /**
  77429. * 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.
  77430. * * 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.
  77431. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77432. * * 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.
  77433. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  77434. * * 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
  77435. * * 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
  77436. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  77437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77438. * * 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
  77439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  77440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77441. * @param name defines the name of the mesh
  77442. * @param options defines the options used to create the mesh
  77443. * @param scene defines the hosting scene
  77444. * @returns the extruded shape mesh
  77445. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77447. */
  77448. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  77449. if (scene === void 0) { scene = null; }
  77450. var path = options.path;
  77451. var shape = options.shape;
  77452. var scale = options.scale || 1;
  77453. var rotation = options.rotation || 0;
  77454. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77455. var updatable = options.updatable;
  77456. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77457. var instance = options.instance || null;
  77458. var invertUV = options.invertUV || false;
  77459. 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);
  77460. };
  77461. /**
  77462. * Creates an custom extruded shape mesh.
  77463. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  77464. * * 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.
  77465. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77466. * * 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
  77467. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  77468. * * 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
  77469. * * It must returns a float value that will be the scale value applied to the shape on each path point
  77470. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77471. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  77472. * * 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
  77473. * * 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
  77474. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  77475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77476. * * 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
  77477. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77479. * @param name defines the name of the mesh
  77480. * @param options defines the options used to create the mesh
  77481. * @param scene defines the hosting scene
  77482. * @returns the custom extruded shape mesh
  77483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  77484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77486. */
  77487. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  77488. var path = options.path;
  77489. var shape = options.shape;
  77490. var scaleFunction = options.scaleFunction || (function () { return 1; });
  77491. var rotationFunction = options.rotationFunction || (function () { return 0; });
  77492. var ribbonCloseArray = options.ribbonCloseArray || false;
  77493. var ribbonClosePath = options.ribbonClosePath || false;
  77494. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77495. var updatable = options.updatable;
  77496. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77497. var instance = options.instance;
  77498. var invertUV = options.invertUV || false;
  77499. 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);
  77500. };
  77501. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  77502. // extrusion geometry
  77503. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  77504. var tangents = path3D.getTangents();
  77505. var normals = path3D.getNormals();
  77506. var binormals = path3D.getBinormals();
  77507. var distances = path3D.getDistances();
  77508. var angle = 0;
  77509. var returnScale = function () { return scale !== null ? scale : 1; };
  77510. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  77511. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  77512. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  77513. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  77514. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  77515. for (var i = 0; i < curve.length; i++) {
  77516. var shapePath = new Array();
  77517. var angleStep = rotate(i, distances[i]);
  77518. var scaleRatio = scl(i, distances[i]);
  77519. for (var p = 0; p < shape.length; p++) {
  77520. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  77521. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  77522. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77523. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  77524. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  77525. shapePath[p] = rotated;
  77526. }
  77527. shapePaths[index] = shapePath;
  77528. angle += angleStep;
  77529. index++;
  77530. }
  77531. // cap
  77532. var capPath = function (shapePath) {
  77533. var pointCap = Array();
  77534. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77535. var i;
  77536. for (i = 0; i < shapePath.length; i++) {
  77537. barycenter.addInPlace(shapePath[i]);
  77538. }
  77539. barycenter.scaleInPlace(1.0 / shapePath.length);
  77540. for (i = 0; i < shapePath.length; i++) {
  77541. pointCap.push(barycenter);
  77542. }
  77543. return pointCap;
  77544. };
  77545. switch (cap) {
  77546. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  77547. break;
  77548. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  77549. shapePaths[0] = capPath(shapePaths[2]);
  77550. shapePaths[1] = shapePaths[2];
  77551. break;
  77552. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  77553. shapePaths[index] = shapePaths[index - 1];
  77554. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77555. break;
  77556. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  77557. shapePaths[0] = capPath(shapePaths[2]);
  77558. shapePaths[1] = shapePaths[2];
  77559. shapePaths[index] = shapePaths[index - 1];
  77560. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77561. break;
  77562. default:
  77563. break;
  77564. }
  77565. return shapePaths;
  77566. };
  77567. var path3D;
  77568. var pathArray;
  77569. if (instance) { // instance update
  77570. var storage = instance._creationDataStorage;
  77571. path3D = storage.path3D.update(curve);
  77572. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  77573. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  77574. return instance;
  77575. }
  77576. // extruded shape creation
  77577. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  77578. var newShapePaths = new Array();
  77579. cap = (cap < 0 || cap > 3) ? 0 : cap;
  77580. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  77581. 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);
  77582. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  77583. extrudedGeneric._creationDataStorage.path3D = path3D;
  77584. extrudedGeneric._creationDataStorage.cap = cap;
  77585. return extrudedGeneric;
  77586. };
  77587. return ShapeBuilder;
  77588. }());
  77589. /***/ }),
  77590. /***/ "./Meshes/Builders/sphereBuilder.ts":
  77591. /*!******************************************!*\
  77592. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  77593. \******************************************/
  77594. /*! exports provided: SphereBuilder */
  77595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77596. "use strict";
  77597. __webpack_require__.r(__webpack_exports__);
  77598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  77599. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77600. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77601. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77602. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  77603. var segments = options.segments || 32;
  77604. var diameterX = options.diameterX || options.diameter || 1;
  77605. var diameterY = options.diameterY || options.diameter || 1;
  77606. var diameterZ = options.diameterZ || options.diameter || 1;
  77607. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77608. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  77609. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77610. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  77611. var totalZRotationSteps = 2 + segments;
  77612. var totalYRotationSteps = 2 * totalZRotationSteps;
  77613. var indices = [];
  77614. var positions = [];
  77615. var normals = [];
  77616. var uvs = [];
  77617. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  77618. var normalizedZ = zRotationStep / totalZRotationSteps;
  77619. var angleZ = normalizedZ * Math.PI * slice;
  77620. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  77621. var normalizedY = yRotationStep / totalYRotationSteps;
  77622. var angleY = normalizedY * Math.PI * 2 * arc;
  77623. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  77624. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  77625. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  77626. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  77627. var vertex = complete.multiply(radius);
  77628. var normal = complete.divide(radius).normalize();
  77629. positions.push(vertex.x, vertex.y, vertex.z);
  77630. normals.push(normal.x, normal.y, normal.z);
  77631. uvs.push(normalizedY, normalizedZ);
  77632. }
  77633. if (zRotationStep > 0) {
  77634. var verticesCount = positions.length / 3;
  77635. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  77636. indices.push((firstIndex));
  77637. indices.push((firstIndex + 1));
  77638. indices.push(firstIndex + totalYRotationSteps + 1);
  77639. indices.push((firstIndex + totalYRotationSteps + 1));
  77640. indices.push((firstIndex + 1));
  77641. indices.push((firstIndex + totalYRotationSteps + 2));
  77642. }
  77643. }
  77644. }
  77645. // Sides
  77646. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77647. // Result
  77648. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77649. vertexData.indices = indices;
  77650. vertexData.positions = positions;
  77651. vertexData.normals = normals;
  77652. vertexData.uvs = uvs;
  77653. return vertexData;
  77654. };
  77655. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  77656. var options = {
  77657. segments: segments,
  77658. diameterX: diameter,
  77659. diameterY: diameter,
  77660. diameterZ: diameter,
  77661. sideOrientation: sideOrientation,
  77662. updatable: updatable
  77663. };
  77664. return SphereBuilder.CreateSphere(name, options, scene);
  77665. };
  77666. /**
  77667. * Class containing static functions to help procedurally build meshes
  77668. */
  77669. var SphereBuilder = /** @class */ (function () {
  77670. function SphereBuilder() {
  77671. }
  77672. /**
  77673. * Creates a sphere mesh
  77674. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  77675. * * 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`)
  77676. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  77677. * * 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
  77678. * * 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)
  77679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77680. * * 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
  77681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77682. * @param name defines the name of the mesh
  77683. * @param options defines the options used to create the mesh
  77684. * @param scene defines the hosting scene
  77685. * @returns the sphere mesh
  77686. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  77687. */
  77688. SphereBuilder.CreateSphere = function (name, options, scene) {
  77689. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77690. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77691. sphere._originalBuilderSideOrientation = options.sideOrientation;
  77692. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  77693. vertexData.applyToMesh(sphere, options.updatable);
  77694. return sphere;
  77695. };
  77696. return SphereBuilder;
  77697. }());
  77698. /***/ }),
  77699. /***/ "./Meshes/Builders/torusBuilder.ts":
  77700. /*!*****************************************!*\
  77701. !*** ./Meshes/Builders/torusBuilder.ts ***!
  77702. \*****************************************/
  77703. /*! exports provided: TorusBuilder */
  77704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77705. "use strict";
  77706. __webpack_require__.r(__webpack_exports__);
  77707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  77708. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77709. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77710. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77711. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  77712. var indices = [];
  77713. var positions = [];
  77714. var normals = [];
  77715. var uvs = [];
  77716. var diameter = options.diameter || 1;
  77717. var thickness = options.thickness || 0.5;
  77718. var tessellation = options.tessellation || 16;
  77719. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77720. var stride = tessellation + 1;
  77721. for (var i = 0; i <= tessellation; i++) {
  77722. var u = i / tessellation;
  77723. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  77724. 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));
  77725. for (var j = 0; j <= tessellation; j++) {
  77726. var v = 1 - j / tessellation;
  77727. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  77728. var dx = Math.cos(innerAngle);
  77729. var dy = Math.sin(innerAngle);
  77730. // Create a vertex.
  77731. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  77732. var position = normal.scale(thickness / 2);
  77733. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  77734. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  77735. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  77736. positions.push(position.x, position.y, position.z);
  77737. normals.push(normal.x, normal.y, normal.z);
  77738. uvs.push(textureCoordinate.x, textureCoordinate.y);
  77739. // And create indices for two triangles.
  77740. var nextI = (i + 1) % stride;
  77741. var nextJ = (j + 1) % stride;
  77742. indices.push(i * stride + j);
  77743. indices.push(i * stride + nextJ);
  77744. indices.push(nextI * stride + j);
  77745. indices.push(i * stride + nextJ);
  77746. indices.push(nextI * stride + nextJ);
  77747. indices.push(nextI * stride + j);
  77748. }
  77749. }
  77750. // Sides
  77751. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77752. // Result
  77753. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77754. vertexData.indices = indices;
  77755. vertexData.positions = positions;
  77756. vertexData.normals = normals;
  77757. vertexData.uvs = uvs;
  77758. return vertexData;
  77759. };
  77760. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  77761. var options = {
  77762. diameter: diameter,
  77763. thickness: thickness,
  77764. tessellation: tessellation,
  77765. sideOrientation: sideOrientation,
  77766. updatable: updatable
  77767. };
  77768. return TorusBuilder.CreateTorus(name, options, scene);
  77769. };
  77770. /**
  77771. * Class containing static functions to help procedurally build meshes
  77772. */
  77773. var TorusBuilder = /** @class */ (function () {
  77774. function TorusBuilder() {
  77775. }
  77776. /**
  77777. * Creates a torus mesh
  77778. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  77779. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  77780. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  77781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77782. * * 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
  77783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77784. * @param name defines the name of the mesh
  77785. * @param options defines the options used to create the mesh
  77786. * @param scene defines the hosting scene
  77787. * @returns the torus mesh
  77788. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  77789. */
  77790. TorusBuilder.CreateTorus = function (name, options, scene) {
  77791. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77792. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77793. torus._originalBuilderSideOrientation = options.sideOrientation;
  77794. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  77795. vertexData.applyToMesh(torus, options.updatable);
  77796. return torus;
  77797. };
  77798. return TorusBuilder;
  77799. }());
  77800. /***/ }),
  77801. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  77802. /*!*********************************************!*\
  77803. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  77804. \*********************************************/
  77805. /*! exports provided: TorusKnotBuilder */
  77806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77807. "use strict";
  77808. __webpack_require__.r(__webpack_exports__);
  77809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  77810. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77811. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77812. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77813. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  77814. var indices = new Array();
  77815. var positions = new Array();
  77816. var normals = new Array();
  77817. var uvs = new Array();
  77818. var radius = options.radius || 2;
  77819. var tube = options.tube || 0.5;
  77820. var radialSegments = options.radialSegments || 32;
  77821. var tubularSegments = options.tubularSegments || 32;
  77822. var p = options.p || 2;
  77823. var q = options.q || 3;
  77824. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77825. // Helper
  77826. var getPos = function (angle) {
  77827. var cu = Math.cos(angle);
  77828. var su = Math.sin(angle);
  77829. var quOverP = q / p * angle;
  77830. var cs = Math.cos(quOverP);
  77831. var tx = radius * (2 + cs) * 0.5 * cu;
  77832. var ty = radius * (2 + cs) * su * 0.5;
  77833. var tz = radius * Math.sin(quOverP) * 0.5;
  77834. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  77835. };
  77836. // Vertices
  77837. var i;
  77838. var j;
  77839. for (i = 0; i <= radialSegments; i++) {
  77840. var modI = i % radialSegments;
  77841. var u = modI / radialSegments * 2 * p * Math.PI;
  77842. var p1 = getPos(u);
  77843. var p2 = getPos(u + 0.01);
  77844. var tang = p2.subtract(p1);
  77845. var n = p2.add(p1);
  77846. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  77847. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  77848. bitan.normalize();
  77849. n.normalize();
  77850. for (j = 0; j < tubularSegments; j++) {
  77851. var modJ = j % tubularSegments;
  77852. var v = modJ / tubularSegments * 2 * Math.PI;
  77853. var cx = -tube * Math.cos(v);
  77854. var cy = tube * Math.sin(v);
  77855. positions.push(p1.x + cx * n.x + cy * bitan.x);
  77856. positions.push(p1.y + cx * n.y + cy * bitan.y);
  77857. positions.push(p1.z + cx * n.z + cy * bitan.z);
  77858. uvs.push(i / radialSegments);
  77859. uvs.push(j / tubularSegments);
  77860. }
  77861. }
  77862. for (i = 0; i < radialSegments; i++) {
  77863. for (j = 0; j < tubularSegments; j++) {
  77864. var jNext = (j + 1) % tubularSegments;
  77865. var a = i * tubularSegments + j;
  77866. var b = (i + 1) * tubularSegments + j;
  77867. var c = (i + 1) * tubularSegments + jNext;
  77868. var d = i * tubularSegments + jNext;
  77869. indices.push(d);
  77870. indices.push(b);
  77871. indices.push(a);
  77872. indices.push(d);
  77873. indices.push(c);
  77874. indices.push(b);
  77875. }
  77876. }
  77877. // Normals
  77878. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77879. // Sides
  77880. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77881. // Result
  77882. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77883. vertexData.indices = indices;
  77884. vertexData.positions = positions;
  77885. vertexData.normals = normals;
  77886. vertexData.uvs = uvs;
  77887. return vertexData;
  77888. };
  77889. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  77890. var options = {
  77891. radius: radius,
  77892. tube: tube,
  77893. radialSegments: radialSegments,
  77894. tubularSegments: tubularSegments,
  77895. p: p,
  77896. q: q,
  77897. sideOrientation: sideOrientation,
  77898. updatable: updatable
  77899. };
  77900. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  77901. };
  77902. /**
  77903. * Class containing static functions to help procedurally build meshes
  77904. */
  77905. var TorusKnotBuilder = /** @class */ (function () {
  77906. function TorusKnotBuilder() {
  77907. }
  77908. /**
  77909. * Creates a torus knot mesh
  77910. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  77911. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  77912. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  77913. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  77914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77915. * * 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
  77916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77917. * @param name defines the name of the mesh
  77918. * @param options defines the options used to create the mesh
  77919. * @param scene defines the hosting scene
  77920. * @returns the torus knot mesh
  77921. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  77922. */
  77923. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  77924. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77925. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77926. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  77927. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  77928. vertexData.applyToMesh(torusKnot, options.updatable);
  77929. return torusKnot;
  77930. };
  77931. return TorusKnotBuilder;
  77932. }());
  77933. /***/ }),
  77934. /***/ "./Meshes/Builders/tubeBuilder.ts":
  77935. /*!****************************************!*\
  77936. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  77937. \****************************************/
  77938. /*! exports provided: TubeBuilder */
  77939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77940. "use strict";
  77941. __webpack_require__.r(__webpack_exports__);
  77942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  77943. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77944. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77945. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77946. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  77947. var options = {
  77948. path: path,
  77949. radius: radius,
  77950. tessellation: tessellation,
  77951. radiusFunction: radiusFunction,
  77952. arc: 1,
  77953. cap: cap,
  77954. updatable: updatable,
  77955. sideOrientation: sideOrientation,
  77956. instance: instance
  77957. };
  77958. return TubeBuilder.CreateTube(name, options, scene);
  77959. };
  77960. /**
  77961. * Class containing static functions to help procedurally build meshes
  77962. */
  77963. var TubeBuilder = /** @class */ (function () {
  77964. function TubeBuilder() {
  77965. }
  77966. /**
  77967. * Creates a tube mesh.
  77968. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77969. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  77970. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  77971. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  77972. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  77973. * * 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)
  77974. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  77975. * * 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
  77976. * * 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
  77977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77978. * * 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
  77979. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77981. * @param name defines the name of the mesh
  77982. * @param options defines the options used to create the mesh
  77983. * @param scene defines the hosting scene
  77984. * @returns the tube mesh
  77985. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77986. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  77987. */
  77988. TubeBuilder.CreateTube = function (name, options, scene) {
  77989. var path = options.path;
  77990. var instance = options.instance;
  77991. var radius = 1.0;
  77992. if (options.radius !== undefined) {
  77993. radius = options.radius;
  77994. }
  77995. else if (instance) {
  77996. radius = instance._creationDataStorage.radius;
  77997. }
  77998. var tessellation = options.tessellation || 64 | 0;
  77999. var radiusFunction = options.radiusFunction || null;
  78000. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  78001. var invertUV = options.invertUV || false;
  78002. var updatable = options.updatable;
  78003. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78004. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  78005. // tube geometry
  78006. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  78007. var tangents = path3D.getTangents();
  78008. var normals = path3D.getNormals();
  78009. var distances = path3D.getDistances();
  78010. var pi2 = Math.PI * 2;
  78011. var step = pi2 / tessellation * arc;
  78012. var returnRadius = function () { return radius; };
  78013. var radiusFunctionFinal = radiusFunction || returnRadius;
  78014. var circlePath;
  78015. var rad;
  78016. var normal;
  78017. var rotated;
  78018. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  78019. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  78020. for (var i = 0; i < path.length; i++) {
  78021. rad = radiusFunctionFinal(i, distances[i]); // current radius
  78022. circlePath = Array(); // current circle array
  78023. normal = normals[i]; // current normal
  78024. for (var t = 0; t < tessellation; t++) {
  78025. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  78026. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78027. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  78028. rotated.scaleInPlace(rad).addInPlace(path[i]);
  78029. circlePath[t] = rotated;
  78030. }
  78031. circlePaths[index] = circlePath;
  78032. index++;
  78033. }
  78034. // cap
  78035. var capPath = function (nbPoints, pathIndex) {
  78036. var pointCap = Array();
  78037. for (var i = 0; i < nbPoints; i++) {
  78038. pointCap.push(path[pathIndex]);
  78039. }
  78040. return pointCap;
  78041. };
  78042. switch (cap) {
  78043. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  78044. break;
  78045. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  78046. circlePaths[0] = capPath(tessellation, 0);
  78047. circlePaths[1] = circlePaths[2].slice(0);
  78048. break;
  78049. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  78050. circlePaths[index] = circlePaths[index - 1].slice(0);
  78051. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  78052. break;
  78053. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  78054. circlePaths[0] = capPath(tessellation, 0);
  78055. circlePaths[1] = circlePaths[2].slice(0);
  78056. circlePaths[index] = circlePaths[index - 1].slice(0);
  78057. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  78058. break;
  78059. default:
  78060. break;
  78061. }
  78062. return circlePaths;
  78063. };
  78064. var path3D;
  78065. var pathArray;
  78066. if (instance) { // tube update
  78067. var storage = instance._creationDataStorage;
  78068. var arc = options.arc || storage.arc;
  78069. path3D = storage.path3D.update(path);
  78070. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  78071. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  78072. // Update mode, no need to recreate the storage.
  78073. storage.path3D = path3D;
  78074. storage.pathArray = pathArray;
  78075. storage.arc = arc;
  78076. storage.radius = radius;
  78077. return instance;
  78078. }
  78079. // tube creation
  78080. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  78081. var newPathArray = new Array();
  78082. cap = (cap < 0 || cap > 3) ? 0 : cap;
  78083. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  78084. 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);
  78085. tube._creationDataStorage.pathArray = pathArray;
  78086. tube._creationDataStorage.path3D = path3D;
  78087. tube._creationDataStorage.tessellation = tessellation;
  78088. tube._creationDataStorage.cap = cap;
  78089. tube._creationDataStorage.arc = options.arc;
  78090. tube._creationDataStorage.radius = radius;
  78091. return tube;
  78092. };
  78093. return TubeBuilder;
  78094. }());
  78095. /***/ }),
  78096. /***/ "./Meshes/Compression/dracoCompression.ts":
  78097. /*!************************************************!*\
  78098. !*** ./Meshes/Compression/dracoCompression.ts ***!
  78099. \************************************************/
  78100. /*! exports provided: DracoCompression */
  78101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78102. "use strict";
  78103. __webpack_require__.r(__webpack_exports__);
  78104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  78105. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  78106. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78107. /**
  78108. * Draco compression (https://google.github.io/draco/)
  78109. *
  78110. * This class wraps the Draco module.
  78111. *
  78112. * **Encoder**
  78113. *
  78114. * The encoder is not currently implemented.
  78115. *
  78116. * **Decoder**
  78117. *
  78118. * 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.
  78119. *
  78120. * To update the configuration, use the following code:
  78121. * ```javascript
  78122. * DracoCompression.Configuration = {
  78123. * decoder: {
  78124. * wasmUrl: "<url to the WebAssembly library>",
  78125. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  78126. * fallbackUrl: "<url to the fallback JavaScript library>",
  78127. * }
  78128. * };
  78129. * ```
  78130. *
  78131. * 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.
  78132. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  78133. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  78134. *
  78135. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  78136. * ```javascript
  78137. * var dracoCompression = new DracoCompression();
  78138. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  78139. * [VertexBuffer.PositionKind]: 0
  78140. * });
  78141. * ```
  78142. *
  78143. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  78144. */
  78145. var DracoCompression = /** @class */ (function () {
  78146. /**
  78147. * Constructor
  78148. */
  78149. function DracoCompression() {
  78150. }
  78151. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  78152. /**
  78153. * Returns true if the decoder is available.
  78154. */
  78155. get: function () {
  78156. if (typeof DracoDecoderModule !== "undefined") {
  78157. return true;
  78158. }
  78159. var decoder = DracoCompression.Configuration.decoder;
  78160. if (decoder) {
  78161. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78162. return true;
  78163. }
  78164. if (decoder.fallbackUrl) {
  78165. return true;
  78166. }
  78167. }
  78168. return false;
  78169. },
  78170. enumerable: true,
  78171. configurable: true
  78172. });
  78173. /**
  78174. * Stop all async operations and release resources.
  78175. */
  78176. DracoCompression.prototype.dispose = function () {
  78177. };
  78178. /**
  78179. * Decode Draco compressed mesh data to vertex data.
  78180. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  78181. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  78182. * @returns A promise that resolves with the decoded vertex data
  78183. */
  78184. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  78185. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  78186. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  78187. var module = wrappedModule.module;
  78188. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78189. var buffer = new module.DecoderBuffer();
  78190. buffer.Init(dataView, dataView.byteLength);
  78191. var decoder = new module.Decoder();
  78192. var geometry;
  78193. var status;
  78194. try {
  78195. var type = decoder.GetEncodedGeometryType(buffer);
  78196. switch (type) {
  78197. case module.TRIANGULAR_MESH:
  78198. geometry = new module.Mesh();
  78199. status = decoder.DecodeBufferToMesh(buffer, geometry);
  78200. break;
  78201. case module.POINT_CLOUD:
  78202. geometry = new module.PointCloud();
  78203. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  78204. break;
  78205. default:
  78206. throw new Error("Invalid geometry type " + type);
  78207. }
  78208. if (!status.ok() || !geometry.ptr) {
  78209. throw new Error(status.error_msg());
  78210. }
  78211. var numPoints = geometry.num_points();
  78212. if (type === module.TRIANGULAR_MESH) {
  78213. var numFaces = geometry.num_faces();
  78214. var faceIndices = new module.DracoInt32Array();
  78215. try {
  78216. var indices = new Uint32Array(numFaces * 3);
  78217. for (var i = 0; i < numFaces; i++) {
  78218. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  78219. var offset = i * 3;
  78220. indices[offset + 0] = faceIndices.GetValue(0);
  78221. indices[offset + 1] = faceIndices.GetValue(1);
  78222. indices[offset + 2] = faceIndices.GetValue(2);
  78223. }
  78224. vertexData.indices = indices;
  78225. }
  78226. finally {
  78227. module.destroy(faceIndices);
  78228. }
  78229. }
  78230. for (var kind in attributes) {
  78231. var uniqueId = attributes[kind];
  78232. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  78233. var dracoData = new module.DracoFloat32Array();
  78234. try {
  78235. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  78236. var babylonData = new Float32Array(numPoints * attribute.num_components());
  78237. for (var i = 0; i < babylonData.length; i++) {
  78238. babylonData[i] = dracoData.GetValue(i);
  78239. }
  78240. vertexData.set(babylonData, kind);
  78241. }
  78242. finally {
  78243. module.destroy(dracoData);
  78244. }
  78245. }
  78246. }
  78247. finally {
  78248. if (geometry) {
  78249. module.destroy(geometry);
  78250. }
  78251. module.destroy(decoder);
  78252. module.destroy(buffer);
  78253. }
  78254. return vertexData;
  78255. });
  78256. };
  78257. DracoCompression._GetDecoderModule = function () {
  78258. if (!DracoCompression._DecoderModulePromise) {
  78259. var promise = null;
  78260. var config_1 = {};
  78261. if (typeof DracoDecoderModule !== "undefined") {
  78262. promise = Promise.resolve();
  78263. }
  78264. else {
  78265. var decoder = DracoCompression.Configuration.decoder;
  78266. if (decoder) {
  78267. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78268. promise = Promise.all([
  78269. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  78270. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  78271. config_1.wasmBinary = data;
  78272. })
  78273. ]);
  78274. }
  78275. else if (decoder.fallbackUrl) {
  78276. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  78277. }
  78278. }
  78279. }
  78280. if (!promise) {
  78281. throw new Error("Draco decoder module is not available");
  78282. }
  78283. DracoCompression._DecoderModulePromise = promise.then(function () {
  78284. return new Promise(function (resolve) {
  78285. config_1.onModuleLoaded = function (decoderModule) {
  78286. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  78287. resolve({ module: decoderModule });
  78288. };
  78289. DracoDecoderModule(config_1);
  78290. });
  78291. });
  78292. }
  78293. return DracoCompression._DecoderModulePromise;
  78294. };
  78295. DracoCompression._LoadScriptAsync = function (url) {
  78296. return new Promise(function (resolve, reject) {
  78297. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  78298. resolve();
  78299. }, function (message) {
  78300. reject(new Error(message));
  78301. });
  78302. });
  78303. };
  78304. DracoCompression._LoadFileAsync = function (url) {
  78305. return new Promise(function (resolve, reject) {
  78306. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  78307. resolve(data);
  78308. }, undefined, undefined, true, function (request, exception) {
  78309. reject(exception);
  78310. });
  78311. });
  78312. };
  78313. /**
  78314. * The configuration. Defaults to the following urls:
  78315. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  78316. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  78317. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78318. */
  78319. DracoCompression.Configuration = {
  78320. decoder: {
  78321. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  78322. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  78323. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78324. }
  78325. };
  78326. return DracoCompression;
  78327. }());
  78328. /***/ }),
  78329. /***/ "./Meshes/Compression/index.ts":
  78330. /*!*************************************!*\
  78331. !*** ./Meshes/Compression/index.ts ***!
  78332. \*************************************/
  78333. /*! exports provided: DracoCompression */
  78334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78335. "use strict";
  78336. __webpack_require__.r(__webpack_exports__);
  78337. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  78338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  78339. /***/ }),
  78340. /***/ "./Meshes/abstractMesh.ts":
  78341. /*!********************************!*\
  78342. !*** ./Meshes/abstractMesh.ts ***!
  78343. \********************************/
  78344. /*! exports provided: AbstractMesh */
  78345. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78346. "use strict";
  78347. __webpack_require__.r(__webpack_exports__);
  78348. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  78349. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  78350. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  78351. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  78352. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  78353. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  78354. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  78355. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78356. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  78357. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  78358. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  78359. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  78360. /** @hidden */
  78361. var _FacetDataStorage = /** @class */ (function () {
  78362. function _FacetDataStorage() {
  78363. this.facetNb = 0; // facet number
  78364. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  78365. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  78366. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  78367. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  78368. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  78369. this.subDiv = {
  78370. max: 1,
  78371. X: 1,
  78372. Y: 1,
  78373. Z: 1
  78374. };
  78375. this.facetDepthSort = false; // is the facet depth sort to be computed
  78376. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  78377. }
  78378. return _FacetDataStorage;
  78379. }());
  78380. /**
  78381. * Class used to store all common mesh properties
  78382. */
  78383. var AbstractMesh = /** @class */ (function (_super) {
  78384. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  78385. // Constructor
  78386. /**
  78387. * Creates a new AbstractMesh
  78388. * @param name defines the name of the mesh
  78389. * @param scene defines the hosting scene
  78390. */
  78391. function AbstractMesh(name, scene) {
  78392. if (scene === void 0) { scene = null; }
  78393. var _this = _super.call(this, name, scene, false) || this;
  78394. _this._facetData = new _FacetDataStorage();
  78395. /**
  78396. * The culling strategy to use to check whether the mesh must be rendered or not.
  78397. * This value can be changed at any time and will be used on the next render mesh selection.
  78398. * The possible values are :
  78399. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78400. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78401. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78402. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78403. * Please read each static variable documentation to get details about the culling process.
  78404. * */
  78405. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  78406. // Events
  78407. /**
  78408. * An event triggered when this mesh collides with another one
  78409. */
  78410. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78411. /**
  78412. * An event triggered when the collision's position changes
  78413. */
  78414. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78415. /**
  78416. * An event triggered when material is changed
  78417. */
  78418. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78419. // Properties
  78420. /**
  78421. * Gets or sets the orientation for POV movement & rotation
  78422. */
  78423. _this.definedFacingForward = true;
  78424. _this._visibility = 1.0;
  78425. /** Gets or sets the alpha index used to sort transparent meshes
  78426. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  78427. */
  78428. _this.alphaIndex = Number.MAX_VALUE;
  78429. /**
  78430. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  78431. */
  78432. _this.isVisible = true;
  78433. /**
  78434. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78435. */
  78436. _this.isPickable = true;
  78437. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  78438. _this.showSubMeshesBoundingBox = false;
  78439. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  78440. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  78441. */
  78442. _this.isBlocker = false;
  78443. /**
  78444. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  78445. */
  78446. _this.enablePointerMoveEvents = false;
  78447. /**
  78448. * Specifies the rendering group id for this mesh (0 by default)
  78449. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78450. */
  78451. _this.renderingGroupId = 0;
  78452. _this._receiveShadows = false;
  78453. /** Defines color to use when rendering outline */
  78454. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78455. /** Define width to use when rendering outline */
  78456. _this.outlineWidth = 0.02;
  78457. /** Defines color to use when rendering overlay */
  78458. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78459. /** Defines alpha to use when rendering overlay */
  78460. _this.overlayAlpha = 0.5;
  78461. _this._hasVertexAlpha = false;
  78462. _this._useVertexColors = true;
  78463. _this._computeBonesUsingShaders = true;
  78464. _this._numBoneInfluencers = 4;
  78465. _this._applyFog = true;
  78466. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  78467. _this.useOctreeForRenderingSelection = true;
  78468. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  78469. _this.useOctreeForPicking = true;
  78470. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  78471. _this.useOctreeForCollisions = true;
  78472. _this._layerMask = 0x0FFFFFFF;
  78473. /**
  78474. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  78475. */
  78476. _this.alwaysSelectAsActiveMesh = false;
  78477. /**
  78478. * Gets or sets the current action manager
  78479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78480. */
  78481. _this.actionManager = null;
  78482. // Collisions
  78483. _this._checkCollisions = false;
  78484. _this._collisionMask = -1;
  78485. _this._collisionGroup = -1;
  78486. /**
  78487. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  78488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78489. */
  78490. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  78491. /**
  78492. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  78493. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78494. */
  78495. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78496. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78497. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78498. // Edges
  78499. /**
  78500. * Defines edge width used when edgesRenderer is enabled
  78501. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78502. */
  78503. _this.edgesWidth = 1;
  78504. /**
  78505. * Defines edge color used when edgesRenderer is enabled
  78506. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78507. */
  78508. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  78509. /** @hidden */
  78510. _this._renderId = 0;
  78511. /** @hidden */
  78512. _this._intersectionsInProgress = new Array();
  78513. /** @hidden */
  78514. _this._unIndexed = false;
  78515. /** @hidden */
  78516. _this._lightSources = new Array();
  78517. /**
  78518. * An event triggered when the mesh is rebuilt.
  78519. */
  78520. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78521. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  78522. if (collidedMesh === void 0) { collidedMesh = null; }
  78523. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  78524. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  78525. _this.position.addInPlace(_this._diffPositionForCollisions);
  78526. }
  78527. if (collidedMesh) {
  78528. _this.onCollideObservable.notifyObservers(collidedMesh);
  78529. }
  78530. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  78531. };
  78532. _this.getScene().addMesh(_this);
  78533. _this._resyncLightSources();
  78534. return _this;
  78535. }
  78536. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  78537. /**
  78538. * No billboard
  78539. */
  78540. get: function () {
  78541. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  78542. },
  78543. enumerable: true,
  78544. configurable: true
  78545. });
  78546. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  78547. /** Billboard on X axis */
  78548. get: function () {
  78549. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  78550. },
  78551. enumerable: true,
  78552. configurable: true
  78553. });
  78554. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  78555. /** Billboard on Y axis */
  78556. get: function () {
  78557. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  78558. },
  78559. enumerable: true,
  78560. configurable: true
  78561. });
  78562. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  78563. /** Billboard on Z axis */
  78564. get: function () {
  78565. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  78566. },
  78567. enumerable: true,
  78568. configurable: true
  78569. });
  78570. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  78571. /** Billboard on all axes */
  78572. get: function () {
  78573. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  78574. },
  78575. enumerable: true,
  78576. configurable: true
  78577. });
  78578. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  78579. /**
  78580. * Gets the number of facets in the mesh
  78581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78582. */
  78583. get: function () {
  78584. return this._facetData.facetNb;
  78585. },
  78586. enumerable: true,
  78587. configurable: true
  78588. });
  78589. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  78590. /**
  78591. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  78592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78593. */
  78594. get: function () {
  78595. return this._facetData.partitioningSubdivisions;
  78596. },
  78597. set: function (nb) {
  78598. this._facetData.partitioningSubdivisions = nb;
  78599. },
  78600. enumerable: true,
  78601. configurable: true
  78602. });
  78603. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  78604. /**
  78605. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  78606. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  78607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78608. */
  78609. get: function () {
  78610. return this._facetData.partitioningBBoxRatio;
  78611. },
  78612. set: function (ratio) {
  78613. this._facetData.partitioningBBoxRatio = ratio;
  78614. },
  78615. enumerable: true,
  78616. configurable: true
  78617. });
  78618. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  78619. /**
  78620. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  78621. * Works only for updatable meshes.
  78622. * Doesn't work with multi-materials
  78623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78624. */
  78625. get: function () {
  78626. return this._facetData.facetDepthSort;
  78627. },
  78628. set: function (sort) {
  78629. this._facetData.facetDepthSort = sort;
  78630. },
  78631. enumerable: true,
  78632. configurable: true
  78633. });
  78634. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  78635. /**
  78636. * The location (Vector3) where the facet depth sort must be computed from.
  78637. * By default, the active camera position.
  78638. * Used only when facet depth sort is enabled
  78639. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78640. */
  78641. get: function () {
  78642. return this._facetData.facetDepthSortFrom;
  78643. },
  78644. set: function (location) {
  78645. this._facetData.facetDepthSortFrom = location;
  78646. },
  78647. enumerable: true,
  78648. configurable: true
  78649. });
  78650. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  78651. /**
  78652. * gets a boolean indicating if facetData is enabled
  78653. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78654. */
  78655. get: function () {
  78656. return this._facetData.facetDataEnabled;
  78657. },
  78658. enumerable: true,
  78659. configurable: true
  78660. });
  78661. /** @hidden */
  78662. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  78663. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  78664. return false;
  78665. }
  78666. this._markSubMeshesAsMiscDirty();
  78667. return true;
  78668. };
  78669. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  78670. /** Set a function to call when this mesh collides with another one */
  78671. set: function (callback) {
  78672. if (this._onCollideObserver) {
  78673. this.onCollideObservable.remove(this._onCollideObserver);
  78674. }
  78675. this._onCollideObserver = this.onCollideObservable.add(callback);
  78676. },
  78677. enumerable: true,
  78678. configurable: true
  78679. });
  78680. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  78681. /** Set a function to call when the collision's position changes */
  78682. set: function (callback) {
  78683. if (this._onCollisionPositionChangeObserver) {
  78684. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  78685. }
  78686. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  78687. },
  78688. enumerable: true,
  78689. configurable: true
  78690. });
  78691. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  78692. /**
  78693. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78694. */
  78695. get: function () {
  78696. return this._visibility;
  78697. },
  78698. /**
  78699. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78700. */
  78701. set: function (value) {
  78702. if (this._visibility === value) {
  78703. return;
  78704. }
  78705. this._visibility = value;
  78706. this._markSubMeshesAsMiscDirty();
  78707. },
  78708. enumerable: true,
  78709. configurable: true
  78710. });
  78711. Object.defineProperty(AbstractMesh.prototype, "material", {
  78712. /** Gets or sets current material */
  78713. get: function () {
  78714. return this._material;
  78715. },
  78716. set: function (value) {
  78717. if (this._material === value) {
  78718. return;
  78719. }
  78720. // remove from material mesh map id needed
  78721. if (this._material && this._material.meshMap) {
  78722. this._material.meshMap[this.uniqueId] = undefined;
  78723. }
  78724. this._material = value;
  78725. if (value && value.meshMap) {
  78726. value.meshMap[this.uniqueId] = this;
  78727. }
  78728. if (this.onMaterialChangedObservable.hasObservers) {
  78729. this.onMaterialChangedObservable.notifyObservers(this);
  78730. }
  78731. if (!this.subMeshes) {
  78732. return;
  78733. }
  78734. this._unBindEffect();
  78735. },
  78736. enumerable: true,
  78737. configurable: true
  78738. });
  78739. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  78740. /**
  78741. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  78742. * @see http://doc.babylonjs.com/babylon101/shadows
  78743. */
  78744. get: function () {
  78745. return this._receiveShadows;
  78746. },
  78747. set: function (value) {
  78748. if (this._receiveShadows === value) {
  78749. return;
  78750. }
  78751. this._receiveShadows = value;
  78752. this._markSubMeshesAsLightDirty();
  78753. },
  78754. enumerable: true,
  78755. configurable: true
  78756. });
  78757. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  78758. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  78759. get: function () {
  78760. return this._hasVertexAlpha;
  78761. },
  78762. set: function (value) {
  78763. if (this._hasVertexAlpha === value) {
  78764. return;
  78765. }
  78766. this._hasVertexAlpha = value;
  78767. this._markSubMeshesAsAttributesDirty();
  78768. this._markSubMeshesAsMiscDirty();
  78769. },
  78770. enumerable: true,
  78771. configurable: true
  78772. });
  78773. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  78774. /** 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) */
  78775. get: function () {
  78776. return this._useVertexColors;
  78777. },
  78778. set: function (value) {
  78779. if (this._useVertexColors === value) {
  78780. return;
  78781. }
  78782. this._useVertexColors = value;
  78783. this._markSubMeshesAsAttributesDirty();
  78784. },
  78785. enumerable: true,
  78786. configurable: true
  78787. });
  78788. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  78789. /**
  78790. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  78791. */
  78792. get: function () {
  78793. return this._computeBonesUsingShaders;
  78794. },
  78795. set: function (value) {
  78796. if (this._computeBonesUsingShaders === value) {
  78797. return;
  78798. }
  78799. this._computeBonesUsingShaders = value;
  78800. this._markSubMeshesAsAttributesDirty();
  78801. },
  78802. enumerable: true,
  78803. configurable: true
  78804. });
  78805. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  78806. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  78807. get: function () {
  78808. return this._numBoneInfluencers;
  78809. },
  78810. set: function (value) {
  78811. if (this._numBoneInfluencers === value) {
  78812. return;
  78813. }
  78814. this._numBoneInfluencers = value;
  78815. this._markSubMeshesAsAttributesDirty();
  78816. },
  78817. enumerable: true,
  78818. configurable: true
  78819. });
  78820. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  78821. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  78822. get: function () {
  78823. return this._applyFog;
  78824. },
  78825. set: function (value) {
  78826. if (this._applyFog === value) {
  78827. return;
  78828. }
  78829. this._applyFog = value;
  78830. this._markSubMeshesAsMiscDirty();
  78831. },
  78832. enumerable: true,
  78833. configurable: true
  78834. });
  78835. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  78836. /**
  78837. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  78838. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  78839. */
  78840. get: function () {
  78841. return this._layerMask;
  78842. },
  78843. set: function (value) {
  78844. if (value === this._layerMask) {
  78845. return;
  78846. }
  78847. this._layerMask = value;
  78848. this._resyncLightSources();
  78849. },
  78850. enumerable: true,
  78851. configurable: true
  78852. });
  78853. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  78854. /**
  78855. * Gets or sets a collision mask used to mask collisions (default is -1).
  78856. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78857. */
  78858. get: function () {
  78859. return this._collisionMask;
  78860. },
  78861. set: function (mask) {
  78862. this._collisionMask = !isNaN(mask) ? mask : -1;
  78863. },
  78864. enumerable: true,
  78865. configurable: true
  78866. });
  78867. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  78868. /**
  78869. * Gets or sets the current collision group mask (-1 by default).
  78870. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78871. */
  78872. get: function () {
  78873. return this._collisionGroup;
  78874. },
  78875. set: function (mask) {
  78876. this._collisionGroup = !isNaN(mask) ? mask : -1;
  78877. },
  78878. enumerable: true,
  78879. configurable: true
  78880. });
  78881. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  78882. /** @hidden */
  78883. get: function () {
  78884. return null;
  78885. },
  78886. enumerable: true,
  78887. configurable: true
  78888. });
  78889. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  78890. get: function () {
  78891. return this._skeleton;
  78892. },
  78893. /**
  78894. * Gets or sets a skeleton to apply skining transformations
  78895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78896. */
  78897. set: function (value) {
  78898. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  78899. this._skeleton._unregisterMeshWithPoseMatrix(this);
  78900. }
  78901. if (value && value.needInitialSkinMatrix) {
  78902. value._registerMeshWithPoseMatrix(this);
  78903. }
  78904. this._skeleton = value;
  78905. if (!this._skeleton) {
  78906. this._bonesTransformMatrices = null;
  78907. }
  78908. this._markSubMeshesAsAttributesDirty();
  78909. },
  78910. enumerable: true,
  78911. configurable: true
  78912. });
  78913. /**
  78914. * Returns the string "AbstractMesh"
  78915. * @returns "AbstractMesh"
  78916. */
  78917. AbstractMesh.prototype.getClassName = function () {
  78918. return "AbstractMesh";
  78919. };
  78920. /**
  78921. * Gets a string representation of the current mesh
  78922. * @param fullDetails defines a boolean indicating if full details must be included
  78923. * @returns a string representation of the current mesh
  78924. */
  78925. AbstractMesh.prototype.toString = function (fullDetails) {
  78926. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  78927. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  78928. if (this._skeleton) {
  78929. ret += ", skeleton: " + this._skeleton.name;
  78930. }
  78931. if (fullDetails) {
  78932. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  78933. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  78934. }
  78935. return ret;
  78936. };
  78937. /** @hidden */
  78938. AbstractMesh.prototype._rebuild = function () {
  78939. this.onRebuildObservable.notifyObservers(this);
  78940. if (this._occlusionQuery) {
  78941. this._occlusionQuery = null;
  78942. }
  78943. if (!this.subMeshes) {
  78944. return;
  78945. }
  78946. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78947. var subMesh = _a[_i];
  78948. subMesh._rebuild();
  78949. }
  78950. };
  78951. /** @hidden */
  78952. AbstractMesh.prototype._resyncLightSources = function () {
  78953. this._lightSources.length = 0;
  78954. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  78955. var light = _a[_i];
  78956. if (!light.isEnabled()) {
  78957. continue;
  78958. }
  78959. if (light.canAffectMesh(this)) {
  78960. this._lightSources.push(light);
  78961. }
  78962. }
  78963. this._markSubMeshesAsLightDirty();
  78964. };
  78965. /** @hidden */
  78966. AbstractMesh.prototype._resyncLighSource = function (light) {
  78967. var isIn = light.isEnabled() && light.canAffectMesh(this);
  78968. var index = this._lightSources.indexOf(light);
  78969. if (index === -1) {
  78970. if (!isIn) {
  78971. return;
  78972. }
  78973. this._lightSources.push(light);
  78974. }
  78975. else {
  78976. if (isIn) {
  78977. return;
  78978. }
  78979. this._lightSources.splice(index, 1);
  78980. }
  78981. this._markSubMeshesAsLightDirty();
  78982. };
  78983. /** @hidden */
  78984. AbstractMesh.prototype._unBindEffect = function () {
  78985. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78986. var subMesh = _a[_i];
  78987. subMesh.setEffect(null);
  78988. }
  78989. };
  78990. /** @hidden */
  78991. AbstractMesh.prototype._removeLightSource = function (light) {
  78992. var index = this._lightSources.indexOf(light);
  78993. if (index === -1) {
  78994. return;
  78995. }
  78996. this._lightSources.splice(index, 1);
  78997. this._markSubMeshesAsLightDirty();
  78998. };
  78999. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  79000. if (!this.subMeshes) {
  79001. return;
  79002. }
  79003. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79004. var subMesh = _a[_i];
  79005. if (subMesh._materialDefines) {
  79006. func(subMesh._materialDefines);
  79007. }
  79008. }
  79009. };
  79010. /** @hidden */
  79011. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  79012. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  79013. };
  79014. /** @hidden */
  79015. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  79016. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  79017. };
  79018. /** @hidden */
  79019. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  79020. if (!this.subMeshes) {
  79021. return;
  79022. }
  79023. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79024. var subMesh = _a[_i];
  79025. var material = subMesh.getMaterial();
  79026. if (material) {
  79027. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  79028. }
  79029. }
  79030. };
  79031. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  79032. /**
  79033. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79034. */
  79035. get: function () {
  79036. return this._scaling;
  79037. },
  79038. set: function (newScaling) {
  79039. this._scaling = newScaling;
  79040. if (this.physicsImpostor) {
  79041. this.physicsImpostor.forceUpdate();
  79042. }
  79043. },
  79044. enumerable: true,
  79045. configurable: true
  79046. });
  79047. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  79048. // Methods
  79049. /**
  79050. * Returns true if the mesh is blocked. Implemented by child classes
  79051. */
  79052. get: function () {
  79053. return false;
  79054. },
  79055. enumerable: true,
  79056. configurable: true
  79057. });
  79058. /**
  79059. * Returns the mesh itself by default. Implemented by child classes
  79060. * @param camera defines the camera to use to pick the right LOD level
  79061. * @returns the currentAbstractMesh
  79062. */
  79063. AbstractMesh.prototype.getLOD = function (camera) {
  79064. return this;
  79065. };
  79066. /**
  79067. * Returns 0 by default. Implemented by child classes
  79068. * @returns an integer
  79069. */
  79070. AbstractMesh.prototype.getTotalVertices = function () {
  79071. return 0;
  79072. };
  79073. /**
  79074. * Returns a positive integer : the total number of indices in this mesh geometry.
  79075. * @returns the numner of indices or zero if the mesh has no geometry.
  79076. */
  79077. AbstractMesh.prototype.getTotalIndices = function () {
  79078. return 0;
  79079. };
  79080. /**
  79081. * Returns null by default. Implemented by child classes
  79082. * @returns null
  79083. */
  79084. AbstractMesh.prototype.getIndices = function () {
  79085. return null;
  79086. };
  79087. /**
  79088. * Returns the array of the requested vertex data kind. Implemented by child classes
  79089. * @param kind defines the vertex data kind to use
  79090. * @returns null
  79091. */
  79092. AbstractMesh.prototype.getVerticesData = function (kind) {
  79093. return null;
  79094. };
  79095. /**
  79096. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79097. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79098. * Note that a new underlying VertexBuffer object is created each call.
  79099. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79100. * @param kind defines vertex data kind:
  79101. * * VertexBuffer.PositionKind
  79102. * * VertexBuffer.UVKind
  79103. * * VertexBuffer.UV2Kind
  79104. * * VertexBuffer.UV3Kind
  79105. * * VertexBuffer.UV4Kind
  79106. * * VertexBuffer.UV5Kind
  79107. * * VertexBuffer.UV6Kind
  79108. * * VertexBuffer.ColorKind
  79109. * * VertexBuffer.MatricesIndicesKind
  79110. * * VertexBuffer.MatricesIndicesExtraKind
  79111. * * VertexBuffer.MatricesWeightsKind
  79112. * * VertexBuffer.MatricesWeightsExtraKind
  79113. * @param data defines the data source
  79114. * @param updatable defines if the data must be flagged as updatable (or static)
  79115. * @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
  79116. * @returns the current mesh
  79117. */
  79118. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  79119. return this;
  79120. };
  79121. /**
  79122. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79123. * If the mesh has no geometry, it is simply returned as it is.
  79124. * @param kind defines vertex data kind:
  79125. * * VertexBuffer.PositionKind
  79126. * * VertexBuffer.UVKind
  79127. * * VertexBuffer.UV2Kind
  79128. * * VertexBuffer.UV3Kind
  79129. * * VertexBuffer.UV4Kind
  79130. * * VertexBuffer.UV5Kind
  79131. * * VertexBuffer.UV6Kind
  79132. * * VertexBuffer.ColorKind
  79133. * * VertexBuffer.MatricesIndicesKind
  79134. * * VertexBuffer.MatricesIndicesExtraKind
  79135. * * VertexBuffer.MatricesWeightsKind
  79136. * * VertexBuffer.MatricesWeightsExtraKind
  79137. * @param data defines the data source
  79138. * @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
  79139. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79140. * @returns the current mesh
  79141. */
  79142. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  79143. return this;
  79144. };
  79145. /**
  79146. * Sets the mesh indices,
  79147. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79148. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79149. * @param totalVertices Defines the total number of vertices
  79150. * @returns the current mesh
  79151. */
  79152. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  79153. return this;
  79154. };
  79155. /**
  79156. * Gets a boolean indicating if specific vertex data is present
  79157. * @param kind defines the vertex data kind to use
  79158. * @returns true is data kind is present
  79159. */
  79160. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  79161. return false;
  79162. };
  79163. /**
  79164. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79165. * @returns a BoundingInfo
  79166. */
  79167. AbstractMesh.prototype.getBoundingInfo = function () {
  79168. if (this._masterMesh) {
  79169. return this._masterMesh.getBoundingInfo();
  79170. }
  79171. if (!this._boundingInfo) {
  79172. // this._boundingInfo is being created here
  79173. this._updateBoundingInfo();
  79174. }
  79175. // cannot be null.
  79176. return this._boundingInfo;
  79177. };
  79178. /**
  79179. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79180. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79181. * @returns the current mesh
  79182. */
  79183. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  79184. if (includeDescendants === void 0) { includeDescendants = true; }
  79185. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  79186. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  79187. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  79188. if (maxDimension === 0) {
  79189. return this;
  79190. }
  79191. var scale = 1 / maxDimension;
  79192. this.scaling.scaleInPlace(scale);
  79193. return this;
  79194. };
  79195. /**
  79196. * Overwrite the current bounding info
  79197. * @param boundingInfo defines the new bounding info
  79198. * @returns the current mesh
  79199. */
  79200. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  79201. this._boundingInfo = boundingInfo;
  79202. return this;
  79203. };
  79204. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  79205. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79206. get: function () {
  79207. 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));
  79208. },
  79209. enumerable: true,
  79210. configurable: true
  79211. });
  79212. /** @hidden */
  79213. AbstractMesh.prototype._preActivate = function () {
  79214. };
  79215. /** @hidden */
  79216. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  79217. };
  79218. /** @hidden */
  79219. AbstractMesh.prototype._activate = function (renderId) {
  79220. this._renderId = renderId;
  79221. };
  79222. /**
  79223. * Gets the current world matrix
  79224. * @returns a Matrix
  79225. */
  79226. AbstractMesh.prototype.getWorldMatrix = function () {
  79227. if (this._masterMesh) {
  79228. return this._masterMesh.getWorldMatrix();
  79229. }
  79230. return _super.prototype.getWorldMatrix.call(this);
  79231. };
  79232. /** @hidden */
  79233. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  79234. if (this._masterMesh) {
  79235. return this._masterMesh._getWorldMatrixDeterminant();
  79236. }
  79237. return _super.prototype._getWorldMatrixDeterminant.call(this);
  79238. };
  79239. // ================================== Point of View Movement =================================
  79240. /**
  79241. * Perform relative position change from the point of view of behind the front of the mesh.
  79242. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79243. * Supports definition of mesh facing forward or backward
  79244. * @param amountRight defines the distance on the right axis
  79245. * @param amountUp defines the distance on the up axis
  79246. * @param amountForward defines the distance on the forward axis
  79247. * @returns the current mesh
  79248. */
  79249. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  79250. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  79251. return this;
  79252. };
  79253. /**
  79254. * Calculate relative position change from the point of view of behind the front of the mesh.
  79255. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79256. * Supports definition of mesh facing forward or backward
  79257. * @param amountRight defines the distance on the right axis
  79258. * @param amountUp defines the distance on the up axis
  79259. * @param amountForward defines the distance on the forward axis
  79260. * @returns the new displacement vector
  79261. */
  79262. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  79263. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  79264. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  79265. rotQuaternion.toRotationMatrix(rotMatrix);
  79266. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79267. var defForwardMult = this.definedFacingForward ? -1 : 1;
  79268. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  79269. return translationDelta;
  79270. };
  79271. // ================================== Point of View Rotation =================================
  79272. /**
  79273. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79274. * Supports definition of mesh facing forward or backward
  79275. * @param flipBack defines the flip
  79276. * @param twirlClockwise defines the twirl
  79277. * @param tiltRight defines the tilt
  79278. * @returns the current mesh
  79279. */
  79280. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79281. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  79282. return this;
  79283. };
  79284. /**
  79285. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79286. * Supports definition of mesh facing forward or backward.
  79287. * @param flipBack defines the flip
  79288. * @param twirlClockwise defines the twirl
  79289. * @param tiltRight defines the tilt
  79290. * @returns the new rotation vector
  79291. */
  79292. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79293. var defForwardMult = this.definedFacingForward ? 1 : -1;
  79294. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  79295. };
  79296. /**
  79297. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79298. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79299. * @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
  79300. * @returns the new bounding vectors
  79301. */
  79302. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  79303. if (includeDescendants === void 0) { includeDescendants = true; }
  79304. if (predicate === void 0) { predicate = null; }
  79305. // Ensures that all world matrix will be recomputed.
  79306. this.getScene().incrementRenderId();
  79307. this.computeWorldMatrix(true);
  79308. var min;
  79309. var max;
  79310. var boundingInfo = this.getBoundingInfo();
  79311. if (!this.subMeshes) {
  79312. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  79313. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  79314. }
  79315. else {
  79316. min = boundingInfo.boundingBox.minimumWorld;
  79317. max = boundingInfo.boundingBox.maximumWorld;
  79318. }
  79319. if (includeDescendants) {
  79320. var descendants = this.getDescendants(false);
  79321. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  79322. var descendant = descendants_1[_i];
  79323. var childMesh = descendant;
  79324. childMesh.computeWorldMatrix(true);
  79325. // Filters meshes based on custom predicate function.
  79326. if (predicate && !predicate(childMesh)) {
  79327. continue;
  79328. }
  79329. //make sure we have the needed params to get mix and max
  79330. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  79331. continue;
  79332. }
  79333. var childBoundingInfo = childMesh.getBoundingInfo();
  79334. var boundingBox = childBoundingInfo.boundingBox;
  79335. var minBox = boundingBox.minimumWorld;
  79336. var maxBox = boundingBox.maximumWorld;
  79337. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  79338. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  79339. }
  79340. }
  79341. return {
  79342. min: min,
  79343. max: max
  79344. };
  79345. };
  79346. /**
  79347. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79348. * This means the mesh underlying bounding box and sphere are recomputed.
  79349. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79350. * @returns the current mesh
  79351. */
  79352. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  79353. if (applySkeleton === void 0) { applySkeleton = false; }
  79354. if (this._boundingInfo && this._boundingInfo.isLocked) {
  79355. return this;
  79356. }
  79357. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  79358. return this;
  79359. };
  79360. /** @hidden */
  79361. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  79362. if (data) {
  79363. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  79364. if (this._boundingInfo) {
  79365. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  79366. }
  79367. else {
  79368. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  79369. }
  79370. }
  79371. if (this.subMeshes) {
  79372. for (var index = 0; index < this.subMeshes.length; index++) {
  79373. this.subMeshes[index].refreshBoundingInfo();
  79374. }
  79375. }
  79376. this._updateBoundingInfo();
  79377. };
  79378. /** @hidden */
  79379. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  79380. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79381. if (data && applySkeleton && this.skeleton) {
  79382. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  79383. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  79384. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  79385. if (matricesWeightsData && matricesIndicesData) {
  79386. var needExtras = this.numBoneInfluencers > 4;
  79387. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  79388. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  79389. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  79390. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79391. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79392. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79393. var matWeightIdx = 0;
  79394. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  79395. finalMatrix.reset();
  79396. var inf;
  79397. var weight;
  79398. for (inf = 0; inf < 4; inf++) {
  79399. weight = matricesWeightsData[matWeightIdx + inf];
  79400. if (weight > 0) {
  79401. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79402. finalMatrix.addToSelf(tempMatrix);
  79403. }
  79404. }
  79405. if (needExtras) {
  79406. for (inf = 0; inf < 4; inf++) {
  79407. weight = matricesWeightsExtraData[matWeightIdx + inf];
  79408. if (weight > 0) {
  79409. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79410. finalMatrix.addToSelf(tempMatrix);
  79411. }
  79412. }
  79413. }
  79414. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  79415. tempVector.toArray(data, index);
  79416. }
  79417. }
  79418. }
  79419. return data;
  79420. };
  79421. /** @hidden */
  79422. AbstractMesh.prototype._updateBoundingInfo = function () {
  79423. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  79424. if (this._boundingInfo) {
  79425. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  79426. }
  79427. else {
  79428. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  79429. }
  79430. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  79431. return this;
  79432. };
  79433. /** @hidden */
  79434. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  79435. if (!this.subMeshes) {
  79436. return this;
  79437. }
  79438. var count = this.subMeshes.length;
  79439. for (var subIndex = 0; subIndex < count; subIndex++) {
  79440. var subMesh = this.subMeshes[subIndex];
  79441. if (count > 1 || !subMesh.IsGlobal) {
  79442. subMesh.updateBoundingInfo(matrix);
  79443. }
  79444. }
  79445. return this;
  79446. };
  79447. /** @hidden */
  79448. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  79449. // Bounding info
  79450. this._updateBoundingInfo();
  79451. };
  79452. /**
  79453. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79454. * A mesh is in the frustum if its bounding box intersects the frustum
  79455. * @param frustumPlanes defines the frustum to test
  79456. * @returns true if the mesh is in the frustum planes
  79457. */
  79458. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  79459. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  79460. };
  79461. /**
  79462. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79463. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79464. * @param frustumPlanes defines the frustum to test
  79465. * @returns true if the mesh is completely in the frustum planes
  79466. */
  79467. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  79468. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  79469. };
  79470. /**
  79471. * True if the mesh intersects another mesh or a SolidParticle object
  79472. * @param mesh defines a target mesh or SolidParticle to test
  79473. * @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)
  79474. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79475. * @returns true if there is an intersection
  79476. */
  79477. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  79478. if (precise === void 0) { precise = false; }
  79479. if (!this._boundingInfo || !mesh._boundingInfo) {
  79480. return false;
  79481. }
  79482. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  79483. return true;
  79484. }
  79485. if (includeDescendants) {
  79486. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  79487. var child = _a[_i];
  79488. if (child.intersectsMesh(mesh, precise, true)) {
  79489. return true;
  79490. }
  79491. }
  79492. }
  79493. return false;
  79494. };
  79495. /**
  79496. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79497. * @param point defines the point to test
  79498. * @returns true if there is an intersection
  79499. */
  79500. AbstractMesh.prototype.intersectsPoint = function (point) {
  79501. if (!this._boundingInfo) {
  79502. return false;
  79503. }
  79504. return this._boundingInfo.intersectsPoint(point);
  79505. };
  79506. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  79507. // Collisions
  79508. /**
  79509. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79511. */
  79512. get: function () {
  79513. return this._checkCollisions;
  79514. },
  79515. set: function (collisionEnabled) {
  79516. this._checkCollisions = collisionEnabled;
  79517. },
  79518. enumerable: true,
  79519. configurable: true
  79520. });
  79521. Object.defineProperty(AbstractMesh.prototype, "collider", {
  79522. /**
  79523. * Gets Collider object used to compute collisions (not physics)
  79524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79525. */
  79526. get: function () {
  79527. return this._collider;
  79528. },
  79529. enumerable: true,
  79530. configurable: true
  79531. });
  79532. /**
  79533. * Move the mesh using collision engine
  79534. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79535. * @param displacement defines the requested displacement vector
  79536. * @returns the current mesh
  79537. */
  79538. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  79539. var globalPosition = this.getAbsolutePosition();
  79540. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  79541. var coordinator = this.getScene().collisionCoordinator;
  79542. if (!this._collider) {
  79543. this._collider = coordinator.createCollider();
  79544. }
  79545. this._collider._radius = this.ellipsoid;
  79546. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  79547. return this;
  79548. };
  79549. // Collisions
  79550. /** @hidden */
  79551. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  79552. this._generatePointsArray();
  79553. if (!this._positions) {
  79554. return this;
  79555. }
  79556. // Transformation
  79557. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  79558. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  79559. subMesh._lastColliderWorldVertices = [];
  79560. subMesh._trianglePlanes = [];
  79561. var start = subMesh.verticesStart;
  79562. var end = (subMesh.verticesStart + subMesh.verticesCount);
  79563. for (var i = start; i < end; i++) {
  79564. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  79565. }
  79566. }
  79567. // Collide
  79568. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  79569. if (collider.collisionFound) {
  79570. collider.collidedMesh = this;
  79571. }
  79572. return this;
  79573. };
  79574. /** @hidden */
  79575. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  79576. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  79577. var len = subMeshes.length;
  79578. for (var index = 0; index < len; index++) {
  79579. var subMesh = subMeshes.data[index];
  79580. // Bounding test
  79581. if (len > 1 && !subMesh._checkCollision(collider)) {
  79582. continue;
  79583. }
  79584. this._collideForSubMesh(subMesh, transformMatrix, collider);
  79585. }
  79586. return this;
  79587. };
  79588. /** @hidden */
  79589. AbstractMesh.prototype._checkCollision = function (collider) {
  79590. // Bounding box test
  79591. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  79592. return this;
  79593. }
  79594. // Transformation matrix
  79595. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79596. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79597. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  79598. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  79599. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  79600. return this;
  79601. };
  79602. // Picking
  79603. /** @hidden */
  79604. AbstractMesh.prototype._generatePointsArray = function () {
  79605. return false;
  79606. };
  79607. /**
  79608. * Checks if the passed Ray intersects with the mesh
  79609. * @param ray defines the ray to use
  79610. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79611. * @returns the picking info
  79612. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79613. */
  79614. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  79615. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  79616. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  79617. var boundingInfo = this._boundingInfo;
  79618. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  79619. return pickingInfo;
  79620. }
  79621. if (!this._generatePointsArray()) {
  79622. return pickingInfo;
  79623. }
  79624. var intersectInfo = null;
  79625. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  79626. var len = subMeshes.length;
  79627. for (var index = 0; index < len; index++) {
  79628. var subMesh = subMeshes.data[index];
  79629. // Bounding test
  79630. if (len > 1 && !subMesh.canIntersects(ray)) {
  79631. continue;
  79632. }
  79633. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  79634. if (currentIntersectInfo) {
  79635. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  79636. intersectInfo = currentIntersectInfo;
  79637. intersectInfo.subMeshId = index;
  79638. if (fastCheck) {
  79639. break;
  79640. }
  79641. }
  79642. }
  79643. }
  79644. if (intersectInfo) {
  79645. // Get picked point
  79646. var world = this.getWorldMatrix();
  79647. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79648. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  79649. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  79650. ray.direction.scaleToRef(intersectInfo.distance, direction);
  79651. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  79652. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  79653. // Return result
  79654. pickingInfo.hit = true;
  79655. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  79656. pickingInfo.pickedPoint = pickedPoint;
  79657. pickingInfo.pickedMesh = this;
  79658. pickingInfo.bu = intersectInfo.bu || 0;
  79659. pickingInfo.bv = intersectInfo.bv || 0;
  79660. pickingInfo.faceId = intersectInfo.faceId;
  79661. pickingInfo.subMeshId = intersectInfo.subMeshId;
  79662. return pickingInfo;
  79663. }
  79664. return pickingInfo;
  79665. };
  79666. /**
  79667. * Clones the current mesh
  79668. * @param name defines the mesh name
  79669. * @param newParent defines the new mesh parent
  79670. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79671. * @returns the new mesh
  79672. */
  79673. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  79674. return null;
  79675. };
  79676. /**
  79677. * Disposes all the submeshes of the current meshnp
  79678. * @returns the current mesh
  79679. */
  79680. AbstractMesh.prototype.releaseSubMeshes = function () {
  79681. if (this.subMeshes) {
  79682. while (this.subMeshes.length) {
  79683. this.subMeshes[0].dispose();
  79684. }
  79685. }
  79686. else {
  79687. this.subMeshes = new Array();
  79688. }
  79689. return this;
  79690. };
  79691. /**
  79692. * Releases resources associated with this abstract mesh.
  79693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79695. */
  79696. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  79697. var _this = this;
  79698. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  79699. var index;
  79700. // Smart Array Retainers.
  79701. this.getScene().freeActiveMeshes();
  79702. this.getScene().freeRenderingGroups();
  79703. // Action manager
  79704. if (this.actionManager !== undefined && this.actionManager !== null) {
  79705. this.actionManager.dispose();
  79706. this.actionManager = null;
  79707. }
  79708. // Skeleton
  79709. this._skeleton = null;
  79710. // Intersections in progress
  79711. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  79712. var other = this._intersectionsInProgress[index];
  79713. var pos = other._intersectionsInProgress.indexOf(this);
  79714. other._intersectionsInProgress.splice(pos, 1);
  79715. }
  79716. this._intersectionsInProgress = [];
  79717. // Lights
  79718. var lights = this.getScene().lights;
  79719. lights.forEach(function (light) {
  79720. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  79721. if (meshIndex !== -1) {
  79722. light.includedOnlyMeshes.splice(meshIndex, 1);
  79723. }
  79724. meshIndex = light.excludedMeshes.indexOf(_this);
  79725. if (meshIndex !== -1) {
  79726. light.excludedMeshes.splice(meshIndex, 1);
  79727. }
  79728. // Shadow generators
  79729. var generator = light.getShadowGenerator();
  79730. if (generator) {
  79731. var shadowMap = generator.getShadowMap();
  79732. if (shadowMap && shadowMap.renderList) {
  79733. meshIndex = shadowMap.renderList.indexOf(_this);
  79734. if (meshIndex !== -1) {
  79735. shadowMap.renderList.splice(meshIndex, 1);
  79736. }
  79737. }
  79738. }
  79739. });
  79740. // SubMeshes
  79741. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  79742. this.releaseSubMeshes();
  79743. }
  79744. // Query
  79745. var engine = this.getScene().getEngine();
  79746. if (this._occlusionQuery) {
  79747. this.isOcclusionQueryInProgress = false;
  79748. engine.deleteQuery(this._occlusionQuery);
  79749. this._occlusionQuery = null;
  79750. }
  79751. // Engine
  79752. engine.wipeCaches();
  79753. // Remove from scene
  79754. this.getScene().removeMesh(this);
  79755. if (disposeMaterialAndTextures) {
  79756. if (this.material) {
  79757. this.material.dispose(false, true);
  79758. }
  79759. }
  79760. if (!doNotRecurse) {
  79761. // Particles
  79762. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  79763. if (this.getScene().particleSystems[index].emitter === this) {
  79764. this.getScene().particleSystems[index].dispose();
  79765. index--;
  79766. }
  79767. }
  79768. }
  79769. // facet data
  79770. if (this._facetData.facetDataEnabled) {
  79771. this.disableFacetData();
  79772. }
  79773. this.onAfterWorldMatrixUpdateObservable.clear();
  79774. this.onCollideObservable.clear();
  79775. this.onCollisionPositionChangeObservable.clear();
  79776. this.onRebuildObservable.clear();
  79777. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  79778. };
  79779. /**
  79780. * Adds the passed mesh as a child to the current mesh
  79781. * @param mesh defines the child mesh
  79782. * @returns the current mesh
  79783. */
  79784. AbstractMesh.prototype.addChild = function (mesh) {
  79785. mesh.setParent(this);
  79786. return this;
  79787. };
  79788. /**
  79789. * Removes the passed mesh from the current mesh children list
  79790. * @param mesh defines the child mesh
  79791. * @returns the current mesh
  79792. */
  79793. AbstractMesh.prototype.removeChild = function (mesh) {
  79794. mesh.setParent(null);
  79795. return this;
  79796. };
  79797. // Facet data
  79798. /** @hidden */
  79799. AbstractMesh.prototype._initFacetData = function () {
  79800. var data = this._facetData;
  79801. if (!data.facetNormals) {
  79802. data.facetNormals = new Array();
  79803. }
  79804. if (!data.facetPositions) {
  79805. data.facetPositions = new Array();
  79806. }
  79807. if (!data.facetPartitioning) {
  79808. data.facetPartitioning = new Array();
  79809. }
  79810. data.facetNb = (this.getIndices().length / 3) | 0;
  79811. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  79812. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  79813. for (var f = 0; f < data.facetNb; f++) {
  79814. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79815. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79816. }
  79817. data.facetDataEnabled = true;
  79818. return this;
  79819. };
  79820. /**
  79821. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79822. * This method can be called within the render loop.
  79823. * 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
  79824. * @returns the current mesh
  79825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79826. */
  79827. AbstractMesh.prototype.updateFacetData = function () {
  79828. var data = this._facetData;
  79829. if (!data.facetDataEnabled) {
  79830. this._initFacetData();
  79831. }
  79832. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79833. var indices = this.getIndices();
  79834. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  79835. var bInfo = this.getBoundingInfo();
  79836. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  79837. // init arrays, matrix and sort function on first call
  79838. data.facetDepthSortEnabled = true;
  79839. if (indices instanceof Uint16Array) {
  79840. data.depthSortedIndices = new Uint16Array(indices);
  79841. }
  79842. else if (indices instanceof Uint32Array) {
  79843. data.depthSortedIndices = new Uint32Array(indices);
  79844. }
  79845. else {
  79846. var needs32bits = false;
  79847. for (var i = 0; i < indices.length; i++) {
  79848. if (indices[i] > 65535) {
  79849. needs32bits = true;
  79850. break;
  79851. }
  79852. }
  79853. if (needs32bits) {
  79854. data.depthSortedIndices = new Uint32Array(indices);
  79855. }
  79856. else {
  79857. data.depthSortedIndices = new Uint16Array(indices);
  79858. }
  79859. }
  79860. data.facetDepthSortFunction = function (f1, f2) {
  79861. return (f2.sqDistance - f1.sqDistance);
  79862. };
  79863. if (!data.facetDepthSortFrom) {
  79864. var camera = this.getScene().activeCamera;
  79865. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79866. }
  79867. data.depthSortedFacets = [];
  79868. for (var f = 0; f < data.facetNb; f++) {
  79869. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  79870. data.depthSortedFacets.push(depthSortedFacet);
  79871. }
  79872. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  79873. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79874. }
  79875. 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"];
  79876. 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"];
  79877. 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"];
  79878. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  79879. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  79880. data.subDiv.max = data.partitioningSubdivisions;
  79881. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  79882. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  79883. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  79884. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  79885. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  79886. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  79887. // set the parameters for ComputeNormals()
  79888. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  79889. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  79890. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  79891. data.facetParameters.bInfo = bInfo;
  79892. data.facetParameters.bbSize = data.bbSize;
  79893. data.facetParameters.subDiv = data.subDiv;
  79894. data.facetParameters.ratio = this.partitioningBBoxRatio;
  79895. data.facetParameters.depthSort = data.facetDepthSort;
  79896. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79897. this.computeWorldMatrix(true);
  79898. this._worldMatrix.invertToRef(data.invertedMatrix);
  79899. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  79900. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  79901. }
  79902. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  79903. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  79904. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79905. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  79906. var l = (data.depthSortedIndices.length / 3) | 0;
  79907. for (var f = 0; f < l; f++) {
  79908. var sind = data.depthSortedFacets[f].ind;
  79909. data.depthSortedIndices[f * 3] = indices[sind];
  79910. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  79911. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  79912. }
  79913. this.updateIndices(data.depthSortedIndices);
  79914. }
  79915. return this;
  79916. };
  79917. /**
  79918. * Returns the facetLocalNormals array.
  79919. * The normals are expressed in the mesh local spac
  79920. * @returns an array of Vector3
  79921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79922. */
  79923. AbstractMesh.prototype.getFacetLocalNormals = function () {
  79924. if (!this._facetData.facetNormals) {
  79925. this.updateFacetData();
  79926. }
  79927. return this._facetData.facetNormals;
  79928. };
  79929. /**
  79930. * Returns the facetLocalPositions array.
  79931. * The facet positions are expressed in the mesh local space
  79932. * @returns an array of Vector3
  79933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79934. */
  79935. AbstractMesh.prototype.getFacetLocalPositions = function () {
  79936. if (!this._facetData.facetPositions) {
  79937. this.updateFacetData();
  79938. }
  79939. return this._facetData.facetPositions;
  79940. };
  79941. /**
  79942. * Returns the facetLocalPartioning array
  79943. * @returns an array of array of numbers
  79944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79945. */
  79946. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  79947. if (!this._facetData.facetPartitioning) {
  79948. this.updateFacetData();
  79949. }
  79950. return this._facetData.facetPartitioning;
  79951. };
  79952. /**
  79953. * Returns the i-th facet position in the world system.
  79954. * This method allocates a new Vector3 per call
  79955. * @param i defines the facet index
  79956. * @returns a new Vector3
  79957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79958. */
  79959. AbstractMesh.prototype.getFacetPosition = function (i) {
  79960. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79961. this.getFacetPositionToRef(i, pos);
  79962. return pos;
  79963. };
  79964. /**
  79965. * Sets the reference Vector3 with the i-th facet position in the world system
  79966. * @param i defines the facet index
  79967. * @param ref defines the target vector
  79968. * @returns the current mesh
  79969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79970. */
  79971. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  79972. var localPos = (this.getFacetLocalPositions())[i];
  79973. var world = this.getWorldMatrix();
  79974. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  79975. return this;
  79976. };
  79977. /**
  79978. * Returns the i-th facet normal in the world system.
  79979. * This method allocates a new Vector3 per call
  79980. * @param i defines the facet index
  79981. * @returns a new Vector3
  79982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79983. */
  79984. AbstractMesh.prototype.getFacetNormal = function (i) {
  79985. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79986. this.getFacetNormalToRef(i, norm);
  79987. return norm;
  79988. };
  79989. /**
  79990. * Sets the reference Vector3 with the i-th facet normal in the world system
  79991. * @param i defines the facet index
  79992. * @param ref defines the target vector
  79993. * @returns the current mesh
  79994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79995. */
  79996. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  79997. var localNorm = (this.getFacetLocalNormals())[i];
  79998. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  79999. return this;
  80000. };
  80001. /**
  80002. * 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)
  80003. * @param x defines x coordinate
  80004. * @param y defines y coordinate
  80005. * @param z defines z coordinate
  80006. * @returns the array of facet indexes
  80007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80008. */
  80009. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  80010. var bInfo = this.getBoundingInfo();
  80011. var data = this._facetData;
  80012. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  80013. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  80014. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  80015. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  80016. return null;
  80017. }
  80018. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  80019. };
  80020. /**
  80021. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80022. * @param projected sets as the (x,y,z) world projection on the facet
  80023. * @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
  80024. * @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
  80025. * @param x defines x coordinate
  80026. * @param y defines y coordinate
  80027. * @param z defines z coordinate
  80028. * @returns the face index if found (or null instead)
  80029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80030. */
  80031. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  80032. if (checkFace === void 0) { checkFace = false; }
  80033. if (facing === void 0) { facing = true; }
  80034. var world = this.getWorldMatrix();
  80035. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  80036. world.invertToRef(invMat);
  80037. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  80038. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  80039. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  80040. if (projected) {
  80041. // tranform the local computed projected vector to world coordinates
  80042. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  80043. }
  80044. return closest;
  80045. };
  80046. /**
  80047. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80048. * @param projected sets as the (x,y,z) local projection on the facet
  80049. * @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
  80050. * @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
  80051. * @param x defines x coordinate
  80052. * @param y defines y coordinate
  80053. * @param z defines z coordinate
  80054. * @returns the face index if found (or null instead)
  80055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80056. */
  80057. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  80058. if (checkFace === void 0) { checkFace = false; }
  80059. if (facing === void 0) { facing = true; }
  80060. var closest = null;
  80061. var tmpx = 0.0;
  80062. var tmpy = 0.0;
  80063. var tmpz = 0.0;
  80064. var d = 0.0; // tmp dot facet normal * facet position
  80065. var t0 = 0.0;
  80066. var projx = 0.0;
  80067. var projy = 0.0;
  80068. var projz = 0.0;
  80069. // Get all the facets in the same partitioning block than (x, y, z)
  80070. var facetPositions = this.getFacetLocalPositions();
  80071. var facetNormals = this.getFacetLocalNormals();
  80072. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  80073. if (!facetsInBlock) {
  80074. return null;
  80075. }
  80076. // Get the closest facet to (x, y, z)
  80077. var shortest = Number.MAX_VALUE; // init distance vars
  80078. var tmpDistance = shortest;
  80079. var fib; // current facet in the block
  80080. var norm; // current facet normal
  80081. var p0; // current facet barycenter position
  80082. // loop on all the facets in the current partitioning block
  80083. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  80084. fib = facetsInBlock[idx];
  80085. norm = facetNormals[fib];
  80086. p0 = facetPositions[fib];
  80087. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  80088. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  80089. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  80090. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  80091. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  80092. projx = x + norm.x * t0;
  80093. projy = y + norm.y * t0;
  80094. projz = z + norm.z * t0;
  80095. tmpx = projx - x;
  80096. tmpy = projy - y;
  80097. tmpz = projz - z;
  80098. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  80099. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  80100. shortest = tmpDistance;
  80101. closest = fib;
  80102. if (projected) {
  80103. projected.x = projx;
  80104. projected.y = projy;
  80105. projected.z = projz;
  80106. }
  80107. }
  80108. }
  80109. }
  80110. return closest;
  80111. };
  80112. /**
  80113. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80114. * @returns the parameters
  80115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80116. */
  80117. AbstractMesh.prototype.getFacetDataParameters = function () {
  80118. return this._facetData.facetParameters;
  80119. };
  80120. /**
  80121. * Disables the feature FacetData and frees the related memory
  80122. * @returns the current mesh
  80123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80124. */
  80125. AbstractMesh.prototype.disableFacetData = function () {
  80126. if (this._facetData.facetDataEnabled) {
  80127. this._facetData.facetDataEnabled = false;
  80128. this._facetData.facetPositions = new Array();
  80129. this._facetData.facetNormals = new Array();
  80130. this._facetData.facetPartitioning = new Array();
  80131. this._facetData.facetParameters = null;
  80132. this._facetData.depthSortedIndices = new Uint32Array(0);
  80133. }
  80134. return this;
  80135. };
  80136. /**
  80137. * Updates the AbstractMesh indices array
  80138. * @param indices defines the data source
  80139. * @returns the current mesh
  80140. */
  80141. AbstractMesh.prototype.updateIndices = function (indices) {
  80142. return this;
  80143. };
  80144. /**
  80145. * Creates new normals data for the mesh
  80146. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80147. * @returns the current mesh
  80148. */
  80149. AbstractMesh.prototype.createNormals = function (updatable) {
  80150. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  80151. var indices = this.getIndices();
  80152. var normals;
  80153. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  80154. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  80155. }
  80156. else {
  80157. normals = [];
  80158. }
  80159. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  80160. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  80161. return this;
  80162. };
  80163. /**
  80164. * Align the mesh with a normal
  80165. * @param normal defines the normal to use
  80166. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80167. * @returns the current mesh
  80168. */
  80169. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  80170. if (!upDirection) {
  80171. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  80172. }
  80173. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  80174. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  80175. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  80176. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  80177. if (this.rotationQuaternion) {
  80178. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  80179. }
  80180. else {
  80181. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  80182. }
  80183. return this;
  80184. };
  80185. /** @hidden */
  80186. AbstractMesh.prototype._checkOcclusionQuery = function () {
  80187. return false;
  80188. };
  80189. /** No occlusion */
  80190. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  80191. /** Occlusion set to optimisitic */
  80192. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  80193. /** Occlusion set to strict */
  80194. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  80195. /** Use an accurante occlusion algorithm */
  80196. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  80197. /** Use a conservative occlusion algorithm */
  80198. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  80199. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80200. * Test order :
  80201. * Is the bounding sphere outside the frustum ?
  80202. * If not, are the bounding box vertices outside the frustum ?
  80203. * It not, then the cullable object is in the frustum.
  80204. */
  80205. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  80206. /** Culling strategy : Bounding Sphere Only.
  80207. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80208. * It's also less accurate than the standard because some not visible objects can still be selected.
  80209. * Test : is the bounding sphere outside the frustum ?
  80210. * If not, then the cullable object is in the frustum.
  80211. */
  80212. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  80213. /** Culling strategy : Optimistic Inclusion.
  80214. * This in an inclusion test first, then the standard exclusion test.
  80215. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80216. * 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.
  80217. * Anyway, it's as accurate as the standard strategy.
  80218. * Test :
  80219. * Is the cullable object bounding sphere center in the frustum ?
  80220. * If not, apply the default culling strategy.
  80221. */
  80222. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  80223. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80224. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80225. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80226. * 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.
  80227. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80228. * Test :
  80229. * Is the cullable object bounding sphere center in the frustum ?
  80230. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80231. */
  80232. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  80233. return AbstractMesh;
  80234. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  80235. /***/ }),
  80236. /***/ "./Meshes/buffer.ts":
  80237. /*!**************************!*\
  80238. !*** ./Meshes/buffer.ts ***!
  80239. \**************************/
  80240. /*! exports provided: Buffer, VertexBuffer */
  80241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80242. "use strict";
  80243. __webpack_require__.r(__webpack_exports__);
  80244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  80245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  80246. /**
  80247. * Class used to store data that will be store in GPU memory
  80248. */
  80249. var Buffer = /** @class */ (function () {
  80250. /**
  80251. * Constructor
  80252. * @param engine the engine
  80253. * @param data the data to use for this buffer
  80254. * @param updatable whether the data is updatable
  80255. * @param stride the stride (optional)
  80256. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80257. * @param instanced whether the buffer is instanced (optional)
  80258. * @param useBytes set to true if the stride in in bytes (optional)
  80259. */
  80260. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  80261. if (stride === void 0) { stride = 0; }
  80262. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  80263. if (instanced === void 0) { instanced = false; }
  80264. if (useBytes === void 0) { useBytes = false; }
  80265. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  80266. this._engine = engine.getScene().getEngine();
  80267. }
  80268. else {
  80269. this._engine = engine;
  80270. }
  80271. this._updatable = updatable;
  80272. this._instanced = instanced;
  80273. this._data = data;
  80274. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  80275. if (!postponeInternalCreation) { // by default
  80276. this.create();
  80277. }
  80278. }
  80279. /**
  80280. * Create a new VertexBuffer based on the current buffer
  80281. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80282. * @param offset defines offset in the buffer (0 by default)
  80283. * @param size defines the size in floats of attributes (position is 3 for instance)
  80284. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80285. * @param instanced defines if the vertex buffer contains indexed data
  80286. * @param useBytes defines if the offset and stride are in bytes
  80287. * @returns the new vertex buffer
  80288. */
  80289. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  80290. if (useBytes === void 0) { useBytes = false; }
  80291. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  80292. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  80293. // a lot of these parameters are ignored as they are overriden by the buffer
  80294. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  80295. };
  80296. // Properties
  80297. /**
  80298. * Gets a boolean indicating if the Buffer is updatable?
  80299. * @returns true if the buffer is updatable
  80300. */
  80301. Buffer.prototype.isUpdatable = function () {
  80302. return this._updatable;
  80303. };
  80304. /**
  80305. * Gets current buffer's data
  80306. * @returns a DataArray or null
  80307. */
  80308. Buffer.prototype.getData = function () {
  80309. return this._data;
  80310. };
  80311. /**
  80312. * Gets underlying native buffer
  80313. * @returns underlying native buffer
  80314. */
  80315. Buffer.prototype.getBuffer = function () {
  80316. return this._buffer;
  80317. };
  80318. /**
  80319. * Gets the stride in float32 units (i.e. byte stride / 4).
  80320. * May not be an integer if the byte stride is not divisible by 4.
  80321. * DEPRECATED. Use byteStride instead.
  80322. * @returns the stride in float32 units
  80323. */
  80324. Buffer.prototype.getStrideSize = function () {
  80325. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  80326. };
  80327. // Methods
  80328. /**
  80329. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80330. * @param data defines the data to store
  80331. */
  80332. Buffer.prototype.create = function (data) {
  80333. if (data === void 0) { data = null; }
  80334. if (!data && this._buffer) {
  80335. return; // nothing to do
  80336. }
  80337. data = data || this._data;
  80338. if (!data) {
  80339. return;
  80340. }
  80341. if (!this._buffer) { // create buffer
  80342. if (this._updatable) {
  80343. this._buffer = this._engine.createDynamicVertexBuffer(data);
  80344. this._data = data;
  80345. }
  80346. else {
  80347. this._buffer = this._engine.createVertexBuffer(data);
  80348. }
  80349. }
  80350. else if (this._updatable) { // update buffer
  80351. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  80352. this._data = data;
  80353. }
  80354. };
  80355. /** @hidden */
  80356. Buffer.prototype._rebuild = function () {
  80357. this._buffer = null;
  80358. this.create(this._data);
  80359. };
  80360. /**
  80361. * Update current buffer data
  80362. * @param data defines the data to store
  80363. */
  80364. Buffer.prototype.update = function (data) {
  80365. this.create(data);
  80366. };
  80367. /**
  80368. * Updates the data directly.
  80369. * @param data the new data
  80370. * @param offset the new offset
  80371. * @param vertexCount the vertex count (optional)
  80372. * @param useBytes set to true if the offset is in bytes
  80373. */
  80374. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  80375. if (useBytes === void 0) { useBytes = false; }
  80376. if (!this._buffer) {
  80377. return;
  80378. }
  80379. if (this._updatable) { // update buffer
  80380. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  80381. this._data = null;
  80382. }
  80383. };
  80384. /**
  80385. * Release all resources
  80386. */
  80387. Buffer.prototype.dispose = function () {
  80388. if (!this._buffer) {
  80389. return;
  80390. }
  80391. if (this._engine._releaseBuffer(this._buffer)) {
  80392. this._buffer = null;
  80393. }
  80394. };
  80395. return Buffer;
  80396. }());
  80397. /**
  80398. * Specialized buffer used to store vertex data
  80399. */
  80400. var VertexBuffer = /** @class */ (function () {
  80401. /**
  80402. * Constructor
  80403. * @param engine the engine
  80404. * @param data the data to use for this vertex buffer
  80405. * @param kind the vertex buffer kind
  80406. * @param updatable whether the data is updatable
  80407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80408. * @param stride the stride (optional)
  80409. * @param instanced whether the buffer is instanced (optional)
  80410. * @param offset the offset of the data (optional)
  80411. * @param size the number of components (optional)
  80412. * @param type the type of the component (optional)
  80413. * @param normalized whether the data contains normalized data (optional)
  80414. * @param useBytes set to true if stride and offset are in bytes (optional)
  80415. */
  80416. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  80417. if (normalized === void 0) { normalized = false; }
  80418. if (useBytes === void 0) { useBytes = false; }
  80419. if (data instanceof Buffer) {
  80420. this._buffer = data;
  80421. this._ownsBuffer = false;
  80422. }
  80423. else {
  80424. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  80425. this._ownsBuffer = true;
  80426. }
  80427. this._kind = kind;
  80428. if (type == undefined) {
  80429. var data_1 = this.getData();
  80430. this.type = VertexBuffer.FLOAT;
  80431. if (data_1 instanceof Int8Array) {
  80432. this.type = VertexBuffer.BYTE;
  80433. }
  80434. else if (data_1 instanceof Uint8Array) {
  80435. this.type = VertexBuffer.UNSIGNED_BYTE;
  80436. }
  80437. else if (data_1 instanceof Int16Array) {
  80438. this.type = VertexBuffer.SHORT;
  80439. }
  80440. else if (data_1 instanceof Uint16Array) {
  80441. this.type = VertexBuffer.UNSIGNED_SHORT;
  80442. }
  80443. else if (data_1 instanceof Int32Array) {
  80444. this.type = VertexBuffer.INT;
  80445. }
  80446. else if (data_1 instanceof Uint32Array) {
  80447. this.type = VertexBuffer.UNSIGNED_INT;
  80448. }
  80449. }
  80450. else {
  80451. this.type = type;
  80452. }
  80453. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  80454. if (useBytes) {
  80455. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  80456. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  80457. this.byteOffset = offset || 0;
  80458. }
  80459. else {
  80460. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  80461. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  80462. this.byteOffset = (offset || 0) * typeByteLength;
  80463. }
  80464. this.normalized = normalized;
  80465. this._instanced = instanced !== undefined ? instanced : false;
  80466. this._instanceDivisor = instanced ? 1 : 0;
  80467. }
  80468. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  80469. /**
  80470. * Gets or sets the instance divisor when in instanced mode
  80471. */
  80472. get: function () {
  80473. return this._instanceDivisor;
  80474. },
  80475. set: function (value) {
  80476. this._instanceDivisor = value;
  80477. if (value == 0) {
  80478. this._instanced = false;
  80479. }
  80480. else {
  80481. this._instanced = true;
  80482. }
  80483. },
  80484. enumerable: true,
  80485. configurable: true
  80486. });
  80487. /** @hidden */
  80488. VertexBuffer.prototype._rebuild = function () {
  80489. if (!this._buffer) {
  80490. return;
  80491. }
  80492. this._buffer._rebuild();
  80493. };
  80494. /**
  80495. * Returns the kind of the VertexBuffer (string)
  80496. * @returns a string
  80497. */
  80498. VertexBuffer.prototype.getKind = function () {
  80499. return this._kind;
  80500. };
  80501. // Properties
  80502. /**
  80503. * Gets a boolean indicating if the VertexBuffer is updatable?
  80504. * @returns true if the buffer is updatable
  80505. */
  80506. VertexBuffer.prototype.isUpdatable = function () {
  80507. return this._buffer.isUpdatable();
  80508. };
  80509. /**
  80510. * Gets current buffer's data
  80511. * @returns a DataArray or null
  80512. */
  80513. VertexBuffer.prototype.getData = function () {
  80514. return this._buffer.getData();
  80515. };
  80516. /**
  80517. * Gets underlying native buffer
  80518. * @returns underlying native buffer
  80519. */
  80520. VertexBuffer.prototype.getBuffer = function () {
  80521. return this._buffer.getBuffer();
  80522. };
  80523. /**
  80524. * Gets the stride in float32 units (i.e. byte stride / 4).
  80525. * May not be an integer if the byte stride is not divisible by 4.
  80526. * DEPRECATED. Use byteStride instead.
  80527. * @returns the stride in float32 units
  80528. */
  80529. VertexBuffer.prototype.getStrideSize = function () {
  80530. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  80531. };
  80532. /**
  80533. * Returns the offset as a multiple of the type byte length.
  80534. * DEPRECATED. Use byteOffset instead.
  80535. * @returns the offset in bytes
  80536. */
  80537. VertexBuffer.prototype.getOffset = function () {
  80538. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  80539. };
  80540. /**
  80541. * Returns the number of components per vertex attribute (integer)
  80542. * @returns the size in float
  80543. */
  80544. VertexBuffer.prototype.getSize = function () {
  80545. return this._size;
  80546. };
  80547. /**
  80548. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80549. * @returns true if this buffer is instanced
  80550. */
  80551. VertexBuffer.prototype.getIsInstanced = function () {
  80552. return this._instanced;
  80553. };
  80554. /**
  80555. * Returns the instancing divisor, zero for non-instanced (integer).
  80556. * @returns a number
  80557. */
  80558. VertexBuffer.prototype.getInstanceDivisor = function () {
  80559. return this._instanceDivisor;
  80560. };
  80561. // Methods
  80562. /**
  80563. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80564. * @param data defines the data to store
  80565. */
  80566. VertexBuffer.prototype.create = function (data) {
  80567. this._buffer.create(data);
  80568. };
  80569. /**
  80570. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80571. * This function will create a new buffer if the current one is not updatable
  80572. * @param data defines the data to store
  80573. */
  80574. VertexBuffer.prototype.update = function (data) {
  80575. this._buffer.update(data);
  80576. };
  80577. /**
  80578. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80579. * Returns the directly updated WebGLBuffer.
  80580. * @param data the new data
  80581. * @param offset the new offset
  80582. * @param useBytes set to true if the offset is in bytes
  80583. */
  80584. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  80585. if (useBytes === void 0) { useBytes = false; }
  80586. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  80587. };
  80588. /**
  80589. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80590. */
  80591. VertexBuffer.prototype.dispose = function () {
  80592. if (this._ownsBuffer) {
  80593. this._buffer.dispose();
  80594. }
  80595. };
  80596. /**
  80597. * Enumerates each value of this vertex buffer as numbers.
  80598. * @param count the number of values to enumerate
  80599. * @param callback the callback function called for each value
  80600. */
  80601. VertexBuffer.prototype.forEach = function (count, callback) {
  80602. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  80603. };
  80604. /**
  80605. * Deduces the stride given a kind.
  80606. * @param kind The kind string to deduce
  80607. * @returns The deduced stride
  80608. */
  80609. VertexBuffer.DeduceStride = function (kind) {
  80610. switch (kind) {
  80611. case VertexBuffer.UVKind:
  80612. case VertexBuffer.UV2Kind:
  80613. case VertexBuffer.UV3Kind:
  80614. case VertexBuffer.UV4Kind:
  80615. case VertexBuffer.UV5Kind:
  80616. case VertexBuffer.UV6Kind:
  80617. return 2;
  80618. case VertexBuffer.NormalKind:
  80619. case VertexBuffer.PositionKind:
  80620. return 3;
  80621. case VertexBuffer.ColorKind:
  80622. case VertexBuffer.MatricesIndicesKind:
  80623. case VertexBuffer.MatricesIndicesExtraKind:
  80624. case VertexBuffer.MatricesWeightsKind:
  80625. case VertexBuffer.MatricesWeightsExtraKind:
  80626. case VertexBuffer.TangentKind:
  80627. return 4;
  80628. default:
  80629. throw new Error("Invalid kind '" + kind + "'");
  80630. }
  80631. };
  80632. /**
  80633. * Gets the byte length of the given type.
  80634. * @param type the type
  80635. * @returns the number of bytes
  80636. */
  80637. VertexBuffer.GetTypeByteLength = function (type) {
  80638. switch (type) {
  80639. case VertexBuffer.BYTE:
  80640. case VertexBuffer.UNSIGNED_BYTE:
  80641. return 1;
  80642. case VertexBuffer.SHORT:
  80643. case VertexBuffer.UNSIGNED_SHORT:
  80644. return 2;
  80645. case VertexBuffer.INT:
  80646. case VertexBuffer.FLOAT:
  80647. return 4;
  80648. default:
  80649. throw new Error("Invalid type '" + type + "'");
  80650. }
  80651. };
  80652. /**
  80653. * Enumerates each value of the given parameters as numbers.
  80654. * @param data the data to enumerate
  80655. * @param byteOffset the byte offset of the data
  80656. * @param byteStride the byte stride of the data
  80657. * @param componentCount the number of components per element
  80658. * @param componentType the type of the component
  80659. * @param count the total number of components
  80660. * @param normalized whether the data is normalized
  80661. * @param callback the callback function called for each value
  80662. */
  80663. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  80664. if (data instanceof Array) {
  80665. var offset = byteOffset / 4;
  80666. var stride = byteStride / 4;
  80667. for (var index = 0; index < count; index += componentCount) {
  80668. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80669. callback(data[offset + componentIndex], index + componentIndex);
  80670. }
  80671. offset += stride;
  80672. }
  80673. }
  80674. else {
  80675. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  80676. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  80677. for (var index = 0; index < count; index += componentCount) {
  80678. var componentByteOffset = byteOffset;
  80679. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80680. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  80681. callback(value, index + componentIndex);
  80682. componentByteOffset += componentByteLength;
  80683. }
  80684. byteOffset += byteStride;
  80685. }
  80686. }
  80687. };
  80688. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  80689. switch (type) {
  80690. case VertexBuffer.BYTE: {
  80691. var value = dataView.getInt8(byteOffset);
  80692. if (normalized) {
  80693. value = Math.max(value / 127, -1);
  80694. }
  80695. return value;
  80696. }
  80697. case VertexBuffer.UNSIGNED_BYTE: {
  80698. var value = dataView.getUint8(byteOffset);
  80699. if (normalized) {
  80700. value = value / 255;
  80701. }
  80702. return value;
  80703. }
  80704. case VertexBuffer.SHORT: {
  80705. var value = dataView.getInt16(byteOffset, true);
  80706. if (normalized) {
  80707. value = Math.max(value / 16383, -1);
  80708. }
  80709. return value;
  80710. }
  80711. case VertexBuffer.UNSIGNED_SHORT: {
  80712. var value = dataView.getUint16(byteOffset, true);
  80713. if (normalized) {
  80714. value = value / 65535;
  80715. }
  80716. return value;
  80717. }
  80718. case VertexBuffer.FLOAT: {
  80719. return dataView.getFloat32(byteOffset, true);
  80720. }
  80721. default: {
  80722. throw new Error("Invalid component type " + type);
  80723. }
  80724. }
  80725. };
  80726. /**
  80727. * The byte type.
  80728. */
  80729. VertexBuffer.BYTE = 5120;
  80730. /**
  80731. * The unsigned byte type.
  80732. */
  80733. VertexBuffer.UNSIGNED_BYTE = 5121;
  80734. /**
  80735. * The short type.
  80736. */
  80737. VertexBuffer.SHORT = 5122;
  80738. /**
  80739. * The unsigned short type.
  80740. */
  80741. VertexBuffer.UNSIGNED_SHORT = 5123;
  80742. /**
  80743. * The integer type.
  80744. */
  80745. VertexBuffer.INT = 5124;
  80746. /**
  80747. * The unsigned integer type.
  80748. */
  80749. VertexBuffer.UNSIGNED_INT = 5125;
  80750. /**
  80751. * The float type.
  80752. */
  80753. VertexBuffer.FLOAT = 5126;
  80754. // Enums
  80755. /**
  80756. * Positions
  80757. */
  80758. VertexBuffer.PositionKind = "position";
  80759. /**
  80760. * Normals
  80761. */
  80762. VertexBuffer.NormalKind = "normal";
  80763. /**
  80764. * Tangents
  80765. */
  80766. VertexBuffer.TangentKind = "tangent";
  80767. /**
  80768. * Texture coordinates
  80769. */
  80770. VertexBuffer.UVKind = "uv";
  80771. /**
  80772. * Texture coordinates 2
  80773. */
  80774. VertexBuffer.UV2Kind = "uv2";
  80775. /**
  80776. * Texture coordinates 3
  80777. */
  80778. VertexBuffer.UV3Kind = "uv3";
  80779. /**
  80780. * Texture coordinates 4
  80781. */
  80782. VertexBuffer.UV4Kind = "uv4";
  80783. /**
  80784. * Texture coordinates 5
  80785. */
  80786. VertexBuffer.UV5Kind = "uv5";
  80787. /**
  80788. * Texture coordinates 6
  80789. */
  80790. VertexBuffer.UV6Kind = "uv6";
  80791. /**
  80792. * Colors
  80793. */
  80794. VertexBuffer.ColorKind = "color";
  80795. /**
  80796. * Matrix indices (for bones)
  80797. */
  80798. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  80799. /**
  80800. * Matrix weights (for bones)
  80801. */
  80802. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  80803. /**
  80804. * Additional matrix indices (for bones)
  80805. */
  80806. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  80807. /**
  80808. * Additional matrix weights (for bones)
  80809. */
  80810. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  80811. return VertexBuffer;
  80812. }());
  80813. /***/ }),
  80814. /***/ "./Meshes/csg.ts":
  80815. /*!***********************!*\
  80816. !*** ./Meshes/csg.ts ***!
  80817. \***********************/
  80818. /*! exports provided: CSG */
  80819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80820. "use strict";
  80821. __webpack_require__.r(__webpack_exports__);
  80822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  80823. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80824. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80825. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  80826. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  80827. /**
  80828. * Unique ID when we import meshes from Babylon to CSG
  80829. */
  80830. var currentCSGMeshId = 0;
  80831. /**
  80832. * Represents a vertex of a polygon. Use your own vertex class instead of this
  80833. * one to provide additional features like texture coordinates and vertex
  80834. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  80835. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  80836. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  80837. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  80838. * is not used anywhere else.
  80839. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  80840. */
  80841. var Vertex = /** @class */ (function () {
  80842. /**
  80843. * Initializes the vertex
  80844. * @param pos The position of the vertex
  80845. * @param normal The normal of the vertex
  80846. * @param uv The texture coordinate of the vertex
  80847. */
  80848. function Vertex(
  80849. /**
  80850. * The position of the vertex
  80851. */
  80852. pos,
  80853. /**
  80854. * The normal of the vertex
  80855. */
  80856. normal,
  80857. /**
  80858. * The texture coordinate of the vertex
  80859. */
  80860. uv) {
  80861. this.pos = pos;
  80862. this.normal = normal;
  80863. this.uv = uv;
  80864. }
  80865. /**
  80866. * Make a clone, or deep copy, of the vertex
  80867. * @returns A new Vertex
  80868. */
  80869. Vertex.prototype.clone = function () {
  80870. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  80871. };
  80872. /**
  80873. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  80874. * orientation of a polygon is flipped.
  80875. */
  80876. Vertex.prototype.flip = function () {
  80877. this.normal = this.normal.scale(-1);
  80878. };
  80879. /**
  80880. * Create a new vertex between this vertex and `other` by linearly
  80881. * interpolating all properties using a parameter of `t`. Subclasses should
  80882. * override this to interpolate additional properties.
  80883. * @param other the vertex to interpolate against
  80884. * @param t The factor used to linearly interpolate between the vertices
  80885. */
  80886. Vertex.prototype.interpolate = function (other, t) {
  80887. 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));
  80888. };
  80889. return Vertex;
  80890. }());
  80891. /**
  80892. * Represents a plane in 3D space.
  80893. */
  80894. var Plane = /** @class */ (function () {
  80895. /**
  80896. * Initializes the plane
  80897. * @param normal The normal for the plane
  80898. * @param w
  80899. */
  80900. function Plane(normal, w) {
  80901. this.normal = normal;
  80902. this.w = w;
  80903. }
  80904. /**
  80905. * Construct a plane from three points
  80906. * @param a Point a
  80907. * @param b Point b
  80908. * @param c Point c
  80909. */
  80910. Plane.FromPoints = function (a, b, c) {
  80911. var v0 = c.subtract(a);
  80912. var v1 = b.subtract(a);
  80913. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  80914. return null;
  80915. }
  80916. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  80917. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  80918. };
  80919. /**
  80920. * Clone, or make a deep copy of the plane
  80921. * @returns a new Plane
  80922. */
  80923. Plane.prototype.clone = function () {
  80924. return new Plane(this.normal.clone(), this.w);
  80925. };
  80926. /**
  80927. * Flip the face of the plane
  80928. */
  80929. Plane.prototype.flip = function () {
  80930. this.normal.scaleInPlace(-1);
  80931. this.w = -this.w;
  80932. };
  80933. /**
  80934. * Split `polygon` by this plane if needed, then put the polygon or polygon
  80935. * fragments in the appropriate lists. Coplanar polygons go into either
  80936. `* coplanarFront` or `coplanarBack` depending on their orientation with
  80937. * respect to this plane. Polygons in front or in back of this plane go into
  80938. * either `front` or `back`
  80939. * @param polygon The polygon to be split
  80940. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  80941. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  80942. * @param front Will contain the polygons in front of the plane
  80943. * @param back Will contain the polygons begind the plane
  80944. */
  80945. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  80946. var COPLANAR = 0;
  80947. var FRONT = 1;
  80948. var BACK = 2;
  80949. var SPANNING = 3;
  80950. // Classify each point as well as the entire polygon into one of the above
  80951. // four classes.
  80952. var polygonType = 0;
  80953. var types = [];
  80954. var i;
  80955. var t;
  80956. for (i = 0; i < polygon.vertices.length; i++) {
  80957. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  80958. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  80959. polygonType |= type;
  80960. types.push(type);
  80961. }
  80962. // Put the polygon in the correct list, splitting it when necessary
  80963. switch (polygonType) {
  80964. case COPLANAR:
  80965. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  80966. break;
  80967. case FRONT:
  80968. front.push(polygon);
  80969. break;
  80970. case BACK:
  80971. back.push(polygon);
  80972. break;
  80973. case SPANNING:
  80974. var f = [], b = [];
  80975. for (i = 0; i < polygon.vertices.length; i++) {
  80976. var j = (i + 1) % polygon.vertices.length;
  80977. var ti = types[i], tj = types[j];
  80978. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  80979. if (ti !== BACK) {
  80980. f.push(vi);
  80981. }
  80982. if (ti !== FRONT) {
  80983. b.push(ti !== BACK ? vi.clone() : vi);
  80984. }
  80985. if ((ti | tj) === SPANNING) {
  80986. 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));
  80987. var v = vi.interpolate(vj, t);
  80988. f.push(v);
  80989. b.push(v.clone());
  80990. }
  80991. }
  80992. var poly;
  80993. if (f.length >= 3) {
  80994. poly = new Polygon(f, polygon.shared);
  80995. if (poly.plane) {
  80996. front.push(poly);
  80997. }
  80998. }
  80999. if (b.length >= 3) {
  81000. poly = new Polygon(b, polygon.shared);
  81001. if (poly.plane) {
  81002. back.push(poly);
  81003. }
  81004. }
  81005. break;
  81006. }
  81007. };
  81008. /**
  81009. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  81010. * point is on the plane
  81011. */
  81012. Plane.EPSILON = 1e-5;
  81013. return Plane;
  81014. }());
  81015. /**
  81016. * Represents a convex polygon. The vertices used to initialize a polygon must
  81017. * be coplanar and form a convex loop.
  81018. *
  81019. * Each convex polygon has a `shared` property, which is shared between all
  81020. * polygons that are clones of each other or were split from the same polygon.
  81021. * This can be used to define per-polygon properties (such as surface color)
  81022. */
  81023. var Polygon = /** @class */ (function () {
  81024. /**
  81025. * Initializes the polygon
  81026. * @param vertices The vertices of the polygon
  81027. * @param shared The properties shared across all polygons
  81028. */
  81029. function Polygon(vertices, shared) {
  81030. this.vertices = vertices;
  81031. this.shared = shared;
  81032. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  81033. }
  81034. /**
  81035. * Clones, or makes a deep copy, or the polygon
  81036. */
  81037. Polygon.prototype.clone = function () {
  81038. var vertices = this.vertices.map(function (v) { return v.clone(); });
  81039. return new Polygon(vertices, this.shared);
  81040. };
  81041. /**
  81042. * Flips the faces of the polygon
  81043. */
  81044. Polygon.prototype.flip = function () {
  81045. this.vertices.reverse().map(function (v) { v.flip(); });
  81046. this.plane.flip();
  81047. };
  81048. return Polygon;
  81049. }());
  81050. /**
  81051. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  81052. * by picking a polygon to split along. That polygon (and all other coplanar
  81053. * polygons) are added directly to that node and the other polygons are added to
  81054. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  81055. * no distinction between internal and leaf nodes
  81056. */
  81057. var Node = /** @class */ (function () {
  81058. /**
  81059. * Initializes the node
  81060. * @param polygons A collection of polygons held in the node
  81061. */
  81062. function Node(polygons) {
  81063. this.plane = null;
  81064. this.front = null;
  81065. this.back = null;
  81066. this.polygons = new Array();
  81067. if (polygons) {
  81068. this.build(polygons);
  81069. }
  81070. }
  81071. /**
  81072. * Clones, or makes a deep copy, of the node
  81073. * @returns The cloned node
  81074. */
  81075. Node.prototype.clone = function () {
  81076. var node = new Node();
  81077. node.plane = this.plane && this.plane.clone();
  81078. node.front = this.front && this.front.clone();
  81079. node.back = this.back && this.back.clone();
  81080. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  81081. return node;
  81082. };
  81083. /**
  81084. * Convert solid space to empty space and empty space to solid space
  81085. */
  81086. Node.prototype.invert = function () {
  81087. for (var i = 0; i < this.polygons.length; i++) {
  81088. this.polygons[i].flip();
  81089. }
  81090. if (this.plane) {
  81091. this.plane.flip();
  81092. }
  81093. if (this.front) {
  81094. this.front.invert();
  81095. }
  81096. if (this.back) {
  81097. this.back.invert();
  81098. }
  81099. var temp = this.front;
  81100. this.front = this.back;
  81101. this.back = temp;
  81102. };
  81103. /**
  81104. * Recursively remove all polygons in `polygons` that are inside this BSP
  81105. * tree.
  81106. * @param polygons Polygons to remove from the BSP
  81107. * @returns Polygons clipped from the BSP
  81108. */
  81109. Node.prototype.clipPolygons = function (polygons) {
  81110. if (!this.plane) {
  81111. return polygons.slice();
  81112. }
  81113. var front = new Array(), back = new Array();
  81114. for (var i = 0; i < polygons.length; i++) {
  81115. this.plane.splitPolygon(polygons[i], front, back, front, back);
  81116. }
  81117. if (this.front) {
  81118. front = this.front.clipPolygons(front);
  81119. }
  81120. if (this.back) {
  81121. back = this.back.clipPolygons(back);
  81122. }
  81123. else {
  81124. back = [];
  81125. }
  81126. return front.concat(back);
  81127. };
  81128. /**
  81129. * Remove all polygons in this BSP tree that are inside the other BSP tree
  81130. * `bsp`.
  81131. * @param bsp BSP containing polygons to remove from this BSP
  81132. */
  81133. Node.prototype.clipTo = function (bsp) {
  81134. this.polygons = bsp.clipPolygons(this.polygons);
  81135. if (this.front) {
  81136. this.front.clipTo(bsp);
  81137. }
  81138. if (this.back) {
  81139. this.back.clipTo(bsp);
  81140. }
  81141. };
  81142. /**
  81143. * Return a list of all polygons in this BSP tree
  81144. * @returns List of all polygons in this BSP tree
  81145. */
  81146. Node.prototype.allPolygons = function () {
  81147. var polygons = this.polygons.slice();
  81148. if (this.front) {
  81149. polygons = polygons.concat(this.front.allPolygons());
  81150. }
  81151. if (this.back) {
  81152. polygons = polygons.concat(this.back.allPolygons());
  81153. }
  81154. return polygons;
  81155. };
  81156. /**
  81157. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  81158. * new polygons are filtered down to the bottom of the tree and become new
  81159. * nodes there. Each set of polygons is partitioned using the first polygon
  81160. * (no heuristic is used to pick a good split)
  81161. * @param polygons Polygons used to construct the BSP tree
  81162. */
  81163. Node.prototype.build = function (polygons) {
  81164. if (!polygons.length) {
  81165. return;
  81166. }
  81167. if (!this.plane) {
  81168. this.plane = polygons[0].plane.clone();
  81169. }
  81170. var front = new Array(), back = new Array();
  81171. for (var i = 0; i < polygons.length; i++) {
  81172. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  81173. }
  81174. if (front.length) {
  81175. if (!this.front) {
  81176. this.front = new Node();
  81177. }
  81178. this.front.build(front);
  81179. }
  81180. if (back.length) {
  81181. if (!this.back) {
  81182. this.back = new Node();
  81183. }
  81184. this.back.build(back);
  81185. }
  81186. };
  81187. return Node;
  81188. }());
  81189. /**
  81190. * Class for building Constructive Solid Geometry
  81191. */
  81192. var CSG = /** @class */ (function () {
  81193. function CSG() {
  81194. this.polygons = new Array();
  81195. }
  81196. /**
  81197. * Convert the Mesh to CSG
  81198. * @param mesh The Mesh to convert to CSG
  81199. * @returns A new CSG from the Mesh
  81200. */
  81201. CSG.FromMesh = function (mesh) {
  81202. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  81203. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  81204. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  81205. mesh.computeWorldMatrix(true);
  81206. matrix = mesh.getWorldMatrix();
  81207. meshPosition = mesh.position.clone();
  81208. meshRotation = mesh.rotation.clone();
  81209. if (mesh.rotationQuaternion) {
  81210. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  81211. }
  81212. meshScaling = mesh.scaling.clone();
  81213. }
  81214. else {
  81215. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  81216. }
  81217. 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);
  81218. var subMeshes = mesh.subMeshes;
  81219. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  81220. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  81221. vertices = [];
  81222. for (var j = 0; j < 3; j++) {
  81223. 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]);
  81224. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  81225. 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]);
  81226. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  81227. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  81228. vertex = new Vertex(position, normal, uv);
  81229. vertices.push(vertex);
  81230. }
  81231. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  81232. // To handle the case of degenerated triangle
  81233. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  81234. if (polygon.plane) {
  81235. polygons.push(polygon);
  81236. }
  81237. }
  81238. }
  81239. var csg = CSG.FromPolygons(polygons);
  81240. csg.matrix = matrix;
  81241. csg.position = meshPosition;
  81242. csg.rotation = meshRotation;
  81243. csg.scaling = meshScaling;
  81244. csg.rotationQuaternion = meshRotationQuaternion;
  81245. currentCSGMeshId++;
  81246. return csg;
  81247. };
  81248. /**
  81249. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  81250. * @param polygons Polygons used to construct a CSG solid
  81251. */
  81252. CSG.FromPolygons = function (polygons) {
  81253. var csg = new CSG();
  81254. csg.polygons = polygons;
  81255. return csg;
  81256. };
  81257. /**
  81258. * Clones, or makes a deep copy, of the CSG
  81259. * @returns A new CSG
  81260. */
  81261. CSG.prototype.clone = function () {
  81262. var csg = new CSG();
  81263. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  81264. csg.copyTransformAttributes(this);
  81265. return csg;
  81266. };
  81267. /**
  81268. * Unions this CSG with another CSG
  81269. * @param csg The CSG to union against this CSG
  81270. * @returns The unioned CSG
  81271. */
  81272. CSG.prototype.union = function (csg) {
  81273. var a = new Node(this.clone().polygons);
  81274. var b = new Node(csg.clone().polygons);
  81275. a.clipTo(b);
  81276. b.clipTo(a);
  81277. b.invert();
  81278. b.clipTo(a);
  81279. b.invert();
  81280. a.build(b.allPolygons());
  81281. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81282. };
  81283. /**
  81284. * Unions this CSG with another CSG in place
  81285. * @param csg The CSG to union against this CSG
  81286. */
  81287. CSG.prototype.unionInPlace = function (csg) {
  81288. var a = new Node(this.polygons);
  81289. var b = new Node(csg.polygons);
  81290. a.clipTo(b);
  81291. b.clipTo(a);
  81292. b.invert();
  81293. b.clipTo(a);
  81294. b.invert();
  81295. a.build(b.allPolygons());
  81296. this.polygons = a.allPolygons();
  81297. };
  81298. /**
  81299. * Subtracts this CSG with another CSG
  81300. * @param csg The CSG to subtract against this CSG
  81301. * @returns A new CSG
  81302. */
  81303. CSG.prototype.subtract = function (csg) {
  81304. var a = new Node(this.clone().polygons);
  81305. var b = new Node(csg.clone().polygons);
  81306. a.invert();
  81307. a.clipTo(b);
  81308. b.clipTo(a);
  81309. b.invert();
  81310. b.clipTo(a);
  81311. b.invert();
  81312. a.build(b.allPolygons());
  81313. a.invert();
  81314. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81315. };
  81316. /**
  81317. * Subtracts this CSG with another CSG in place
  81318. * @param csg The CSG to subtact against this CSG
  81319. */
  81320. CSG.prototype.subtractInPlace = function (csg) {
  81321. var a = new Node(this.polygons);
  81322. var b = new Node(csg.polygons);
  81323. a.invert();
  81324. a.clipTo(b);
  81325. b.clipTo(a);
  81326. b.invert();
  81327. b.clipTo(a);
  81328. b.invert();
  81329. a.build(b.allPolygons());
  81330. a.invert();
  81331. this.polygons = a.allPolygons();
  81332. };
  81333. /**
  81334. * Intersect this CSG with another CSG
  81335. * @param csg The CSG to intersect against this CSG
  81336. * @returns A new CSG
  81337. */
  81338. CSG.prototype.intersect = function (csg) {
  81339. var a = new Node(this.clone().polygons);
  81340. var b = new Node(csg.clone().polygons);
  81341. a.invert();
  81342. b.clipTo(a);
  81343. b.invert();
  81344. a.clipTo(b);
  81345. b.clipTo(a);
  81346. a.build(b.allPolygons());
  81347. a.invert();
  81348. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81349. };
  81350. /**
  81351. * Intersects this CSG with another CSG in place
  81352. * @param csg The CSG to intersect against this CSG
  81353. */
  81354. CSG.prototype.intersectInPlace = function (csg) {
  81355. var a = new Node(this.polygons);
  81356. var b = new Node(csg.polygons);
  81357. a.invert();
  81358. b.clipTo(a);
  81359. b.invert();
  81360. a.clipTo(b);
  81361. b.clipTo(a);
  81362. a.build(b.allPolygons());
  81363. a.invert();
  81364. this.polygons = a.allPolygons();
  81365. };
  81366. /**
  81367. * Return a new CSG solid with solid and empty space switched. This solid is
  81368. * not modified.
  81369. * @returns A new CSG solid with solid and empty space switched
  81370. */
  81371. CSG.prototype.inverse = function () {
  81372. var csg = this.clone();
  81373. csg.inverseInPlace();
  81374. return csg;
  81375. };
  81376. /**
  81377. * Inverses the CSG in place
  81378. */
  81379. CSG.prototype.inverseInPlace = function () {
  81380. this.polygons.map(function (p) { p.flip(); });
  81381. };
  81382. /**
  81383. * This is used to keep meshes transformations so they can be restored
  81384. * when we build back a Babylon Mesh
  81385. * NB : All CSG operations are performed in world coordinates
  81386. * @param csg The CSG to copy the transform attributes from
  81387. * @returns This CSG
  81388. */
  81389. CSG.prototype.copyTransformAttributes = function (csg) {
  81390. this.matrix = csg.matrix;
  81391. this.position = csg.position;
  81392. this.rotation = csg.rotation;
  81393. this.scaling = csg.scaling;
  81394. this.rotationQuaternion = csg.rotationQuaternion;
  81395. return this;
  81396. };
  81397. /**
  81398. * Build Raw mesh from CSG
  81399. * Coordinates here are in world space
  81400. * @param name The name of the mesh geometry
  81401. * @param scene The Scene
  81402. * @param keepSubMeshes Specifies if the submeshes should be kept
  81403. * @returns A new Mesh
  81404. */
  81405. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  81406. var matrix = this.matrix.clone();
  81407. matrix.invert();
  81408. 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;
  81409. if (keepSubMeshes) {
  81410. // Sort Polygons, since subMeshes are indices range
  81411. polygons.sort(function (a, b) {
  81412. if (a.shared.meshId === b.shared.meshId) {
  81413. return a.shared.subMeshId - b.shared.subMeshId;
  81414. }
  81415. else {
  81416. return a.shared.meshId - b.shared.meshId;
  81417. }
  81418. });
  81419. }
  81420. for (var i = 0, il = polygons.length; i < il; i++) {
  81421. polygon = polygons[i];
  81422. // Building SubMeshes
  81423. if (!subMesh_dict[polygon.shared.meshId]) {
  81424. subMesh_dict[polygon.shared.meshId] = {};
  81425. }
  81426. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  81427. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  81428. indexStart: +Infinity,
  81429. indexEnd: -Infinity,
  81430. materialIndex: polygon.shared.materialIndex
  81431. };
  81432. }
  81433. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  81434. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  81435. polygonIndices[0] = 0;
  81436. polygonIndices[1] = j - 1;
  81437. polygonIndices[2] = j;
  81438. for (var k = 0; k < 3; k++) {
  81439. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  81440. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  81441. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  81442. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  81443. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  81444. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  81445. // Check if 2 points can be merged
  81446. if (!(typeof vertex_idx !== 'undefined' &&
  81447. normals[vertex_idx * 3] === localNormal.x &&
  81448. normals[vertex_idx * 3 + 1] === localNormal.y &&
  81449. normals[vertex_idx * 3 + 2] === localNormal.z &&
  81450. uvs[vertex_idx * 2] === uv.x &&
  81451. uvs[vertex_idx * 2 + 1] === uv.y)) {
  81452. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  81453. uvs.push(uv.x, uv.y);
  81454. normals.push(normal.x, normal.y, normal.z);
  81455. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  81456. }
  81457. indices.push(vertex_idx);
  81458. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  81459. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  81460. currentIndex++;
  81461. }
  81462. }
  81463. }
  81464. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  81465. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  81466. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  81467. mesh.setIndices(indices, null);
  81468. if (keepSubMeshes) {
  81469. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  81470. var materialIndexOffset = 0, materialMaxIndex;
  81471. mesh.subMeshes = new Array();
  81472. for (var m in subMesh_dict) {
  81473. materialMaxIndex = -1;
  81474. for (var sm in subMesh_dict[m]) {
  81475. subMesh_obj = subMesh_dict[m][sm];
  81476. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  81477. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  81478. }
  81479. materialIndexOffset += ++materialMaxIndex;
  81480. }
  81481. }
  81482. return mesh;
  81483. };
  81484. /**
  81485. * Build Mesh from CSG taking material and transforms into account
  81486. * @param name The name of the Mesh
  81487. * @param material The material of the Mesh
  81488. * @param scene The Scene
  81489. * @param keepSubMeshes Specifies if submeshes should be kept
  81490. * @returns The new Mesh
  81491. */
  81492. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  81493. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  81494. mesh.material = material;
  81495. mesh.position.copyFrom(this.position);
  81496. mesh.rotation.copyFrom(this.rotation);
  81497. if (this.rotationQuaternion) {
  81498. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  81499. }
  81500. mesh.scaling.copyFrom(this.scaling);
  81501. mesh.computeWorldMatrix(true);
  81502. return mesh;
  81503. };
  81504. return CSG;
  81505. }());
  81506. /***/ }),
  81507. /***/ "./Meshes/geometry.ts":
  81508. /*!****************************!*\
  81509. !*** ./Meshes/geometry.ts ***!
  81510. \****************************/
  81511. /*! exports provided: Geometry */
  81512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81513. "use strict";
  81514. __webpack_require__.r(__webpack_exports__);
  81515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  81516. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81517. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81518. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81519. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  81520. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  81521. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81522. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81523. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81524. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  81525. /**
  81526. * Class used to store geometry data (vertex buffers + index buffer)
  81527. */
  81528. var Geometry = /** @class */ (function () {
  81529. /**
  81530. * Creates a new geometry
  81531. * @param id defines the unique ID
  81532. * @param scene defines the hosting scene
  81533. * @param vertexData defines the VertexData used to get geometry data
  81534. * @param updatable defines if geometry must be updatable (false by default)
  81535. * @param mesh defines the mesh that will be associated with the geometry
  81536. */
  81537. function Geometry(id, scene, vertexData, updatable, mesh) {
  81538. if (updatable === void 0) { updatable = false; }
  81539. if (mesh === void 0) { mesh = null; }
  81540. /**
  81541. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81542. */
  81543. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81544. this._totalVertices = 0;
  81545. this._isDisposed = false;
  81546. this._indexBufferIsUpdatable = false;
  81547. this.id = id;
  81548. this.uniqueId = scene.getUniqueId();
  81549. this._engine = scene.getEngine();
  81550. this._meshes = [];
  81551. this._scene = scene;
  81552. //Init vertex buffer cache
  81553. this._vertexBuffers = {};
  81554. this._indices = [];
  81555. this._updatable = updatable;
  81556. // vertexData
  81557. if (vertexData) {
  81558. this.setAllVerticesData(vertexData, updatable);
  81559. }
  81560. else {
  81561. this._totalVertices = 0;
  81562. this._indices = [];
  81563. }
  81564. if (this._engine.getCaps().vertexArrayObject) {
  81565. this._vertexArrayObjects = {};
  81566. }
  81567. // applyToMesh
  81568. if (mesh) {
  81569. this.applyToMesh(mesh);
  81570. mesh.computeWorldMatrix(true);
  81571. }
  81572. }
  81573. Object.defineProperty(Geometry.prototype, "boundingBias", {
  81574. /**
  81575. * 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
  81576. */
  81577. get: function () {
  81578. return this._boundingBias;
  81579. },
  81580. /**
  81581. * 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
  81582. */
  81583. set: function (value) {
  81584. if (this._boundingBias) {
  81585. this._boundingBias.copyFrom(value);
  81586. }
  81587. else {
  81588. this._boundingBias = value.clone();
  81589. }
  81590. this._updateBoundingInfo(true, null);
  81591. },
  81592. enumerable: true,
  81593. configurable: true
  81594. });
  81595. /**
  81596. * Static function used to attach a new empty geometry to a mesh
  81597. * @param mesh defines the mesh to attach the geometry to
  81598. * @returns the new Geometry
  81599. */
  81600. Geometry.CreateGeometryForMesh = function (mesh) {
  81601. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  81602. geometry.applyToMesh(mesh);
  81603. return geometry;
  81604. };
  81605. Object.defineProperty(Geometry.prototype, "extend", {
  81606. /**
  81607. * Gets the current extend of the geometry
  81608. */
  81609. get: function () {
  81610. return this._extend;
  81611. },
  81612. enumerable: true,
  81613. configurable: true
  81614. });
  81615. /**
  81616. * Gets the hosting scene
  81617. * @returns the hosting Scene
  81618. */
  81619. Geometry.prototype.getScene = function () {
  81620. return this._scene;
  81621. };
  81622. /**
  81623. * Gets the hosting engine
  81624. * @returns the hosting Engine
  81625. */
  81626. Geometry.prototype.getEngine = function () {
  81627. return this._engine;
  81628. };
  81629. /**
  81630. * Defines if the geometry is ready to use
  81631. * @returns true if the geometry is ready to be used
  81632. */
  81633. Geometry.prototype.isReady = function () {
  81634. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81635. };
  81636. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  81637. /**
  81638. * Gets a value indicating that the geometry should not be serialized
  81639. */
  81640. get: function () {
  81641. for (var index = 0; index < this._meshes.length; index++) {
  81642. if (!this._meshes[index].doNotSerialize) {
  81643. return false;
  81644. }
  81645. }
  81646. return true;
  81647. },
  81648. enumerable: true,
  81649. configurable: true
  81650. });
  81651. /** @hidden */
  81652. Geometry.prototype._rebuild = function () {
  81653. if (this._vertexArrayObjects) {
  81654. this._vertexArrayObjects = {};
  81655. }
  81656. // Index buffer
  81657. if (this._meshes.length !== 0 && this._indices) {
  81658. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  81659. }
  81660. // Vertex buffers
  81661. for (var key in this._vertexBuffers) {
  81662. var vertexBuffer = this._vertexBuffers[key];
  81663. vertexBuffer._rebuild();
  81664. }
  81665. };
  81666. /**
  81667. * Affects all geometry data in one call
  81668. * @param vertexData defines the geometry data
  81669. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81670. */
  81671. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  81672. vertexData.applyToGeometry(this, updatable);
  81673. this.notifyUpdate();
  81674. };
  81675. /**
  81676. * Set specific vertex data
  81677. * @param kind defines the data kind (Position, normal, etc...)
  81678. * @param data defines the vertex data to use
  81679. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81680. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81681. */
  81682. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81683. if (updatable === void 0) { updatable = false; }
  81684. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  81685. this.setVerticesBuffer(buffer);
  81686. };
  81687. /**
  81688. * Removes a specific vertex data
  81689. * @param kind defines the data kind (Position, normal, etc...)
  81690. */
  81691. Geometry.prototype.removeVerticesData = function (kind) {
  81692. if (this._vertexBuffers[kind]) {
  81693. this._vertexBuffers[kind].dispose();
  81694. delete this._vertexBuffers[kind];
  81695. }
  81696. };
  81697. /**
  81698. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81699. * @param buffer defines the vertex buffer to use
  81700. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81701. */
  81702. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  81703. if (totalVertices === void 0) { totalVertices = null; }
  81704. var kind = buffer.getKind();
  81705. if (this._vertexBuffers[kind]) {
  81706. this._vertexBuffers[kind].dispose();
  81707. }
  81708. this._vertexBuffers[kind] = buffer;
  81709. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81710. var data = buffer.getData();
  81711. if (totalVertices != null) {
  81712. this._totalVertices = totalVertices;
  81713. }
  81714. else {
  81715. if (data != null) {
  81716. this._totalVertices = data.length / (buffer.byteStride / 4);
  81717. }
  81718. }
  81719. this._updateExtend(data);
  81720. this._resetPointsArrayCache();
  81721. var meshes = this._meshes;
  81722. var numOfMeshes = meshes.length;
  81723. for (var index = 0; index < numOfMeshes; index++) {
  81724. var mesh = meshes[index];
  81725. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81726. mesh._createGlobalSubMesh(false);
  81727. mesh.computeWorldMatrix(true);
  81728. }
  81729. }
  81730. this.notifyUpdate(kind);
  81731. if (this._vertexArrayObjects) {
  81732. this._disposeVertexArrayObjects();
  81733. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  81734. }
  81735. };
  81736. /**
  81737. * Update a specific vertex buffer
  81738. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81739. * It will do nothing if the buffer is not updatable
  81740. * @param kind defines the data kind (Position, normal, etc...)
  81741. * @param data defines the data to use
  81742. * @param offset defines the offset in the target buffer where to store the data
  81743. * @param useBytes set to true if the offset is in bytes
  81744. */
  81745. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  81746. if (useBytes === void 0) { useBytes = false; }
  81747. var vertexBuffer = this.getVertexBuffer(kind);
  81748. if (!vertexBuffer) {
  81749. return;
  81750. }
  81751. vertexBuffer.updateDirectly(data, offset, useBytes);
  81752. this.notifyUpdate(kind);
  81753. };
  81754. /**
  81755. * Update a specific vertex buffer
  81756. * This function will create a new buffer if the current one is not updatable
  81757. * @param kind defines the data kind (Position, normal, etc...)
  81758. * @param data defines the data to use
  81759. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81760. */
  81761. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  81762. if (updateExtends === void 0) { updateExtends = false; }
  81763. var vertexBuffer = this.getVertexBuffer(kind);
  81764. if (!vertexBuffer) {
  81765. return;
  81766. }
  81767. vertexBuffer.update(data);
  81768. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81769. this._updateBoundingInfo(updateExtends, data);
  81770. }
  81771. this.notifyUpdate(kind);
  81772. };
  81773. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  81774. if (updateExtends) {
  81775. this._updateExtend(data);
  81776. }
  81777. this._resetPointsArrayCache();
  81778. if (updateExtends) {
  81779. var meshes = this._meshes;
  81780. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  81781. var mesh = meshes_1[_i];
  81782. if (mesh._boundingInfo) {
  81783. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  81784. }
  81785. else {
  81786. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81787. }
  81788. var subMeshes = mesh.subMeshes;
  81789. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  81790. var subMesh = subMeshes_1[_a];
  81791. subMesh.refreshBoundingInfo();
  81792. }
  81793. }
  81794. }
  81795. };
  81796. /** @hidden */
  81797. Geometry.prototype._bind = function (effect, indexToBind) {
  81798. if (!effect) {
  81799. return;
  81800. }
  81801. if (indexToBind === undefined) {
  81802. indexToBind = this._indexBuffer;
  81803. }
  81804. var vbs = this.getVertexBuffers();
  81805. if (!vbs) {
  81806. return;
  81807. }
  81808. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  81809. this._engine.bindBuffers(vbs, indexToBind, effect);
  81810. return;
  81811. }
  81812. // Using VAO
  81813. if (!this._vertexArrayObjects[effect.key]) {
  81814. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  81815. }
  81816. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  81817. };
  81818. /**
  81819. * Gets total number of vertices
  81820. * @returns the total number of vertices
  81821. */
  81822. Geometry.prototype.getTotalVertices = function () {
  81823. if (!this.isReady()) {
  81824. return 0;
  81825. }
  81826. return this._totalVertices;
  81827. };
  81828. /**
  81829. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81830. * @param kind defines the data kind (Position, normal, etc...)
  81831. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81832. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81833. * @returns a float array containing vertex data
  81834. */
  81835. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  81836. var vertexBuffer = this.getVertexBuffer(kind);
  81837. if (!vertexBuffer) {
  81838. return null;
  81839. }
  81840. var data = vertexBuffer.getData();
  81841. if (!data) {
  81842. return null;
  81843. }
  81844. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  81845. var count = this._totalVertices * vertexBuffer.getSize();
  81846. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  81847. var copy_1 = [];
  81848. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  81849. return copy_1;
  81850. }
  81851. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  81852. if (data instanceof Array) {
  81853. var offset = vertexBuffer.byteOffset / 4;
  81854. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  81855. }
  81856. else if (data instanceof ArrayBuffer) {
  81857. return new Float32Array(data, vertexBuffer.byteOffset, count);
  81858. }
  81859. else {
  81860. var offset = data.byteOffset + vertexBuffer.byteOffset;
  81861. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81862. var result = new Float32Array(count);
  81863. var source = new Float32Array(data.buffer, offset, count);
  81864. result.set(source);
  81865. return result;
  81866. }
  81867. return new Float32Array(data.buffer, offset, count);
  81868. }
  81869. }
  81870. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81871. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  81872. }
  81873. return data;
  81874. };
  81875. /**
  81876. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81877. * @param kind defines the data kind (Position, normal, etc...)
  81878. * @returns true if the vertex buffer with the specified kind is updatable
  81879. */
  81880. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  81881. var vb = this._vertexBuffers[kind];
  81882. if (!vb) {
  81883. return false;
  81884. }
  81885. return vb.isUpdatable();
  81886. };
  81887. /**
  81888. * Gets a specific vertex buffer
  81889. * @param kind defines the data kind (Position, normal, etc...)
  81890. * @returns a VertexBuffer
  81891. */
  81892. Geometry.prototype.getVertexBuffer = function (kind) {
  81893. if (!this.isReady()) {
  81894. return null;
  81895. }
  81896. return this._vertexBuffers[kind];
  81897. };
  81898. /**
  81899. * Returns all vertex buffers
  81900. * @return an object holding all vertex buffers indexed by kind
  81901. */
  81902. Geometry.prototype.getVertexBuffers = function () {
  81903. if (!this.isReady()) {
  81904. return null;
  81905. }
  81906. return this._vertexBuffers;
  81907. };
  81908. /**
  81909. * Gets a boolean indicating if specific vertex buffer is present
  81910. * @param kind defines the data kind (Position, normal, etc...)
  81911. * @returns true if data is present
  81912. */
  81913. Geometry.prototype.isVerticesDataPresent = function (kind) {
  81914. if (!this._vertexBuffers) {
  81915. if (this._delayInfo) {
  81916. return this._delayInfo.indexOf(kind) !== -1;
  81917. }
  81918. return false;
  81919. }
  81920. return this._vertexBuffers[kind] !== undefined;
  81921. };
  81922. /**
  81923. * Gets a list of all attached data kinds (Position, normal, etc...)
  81924. * @returns a list of string containing all kinds
  81925. */
  81926. Geometry.prototype.getVerticesDataKinds = function () {
  81927. var result = [];
  81928. var kind;
  81929. if (!this._vertexBuffers && this._delayInfo) {
  81930. for (kind in this._delayInfo) {
  81931. result.push(kind);
  81932. }
  81933. }
  81934. else {
  81935. for (kind in this._vertexBuffers) {
  81936. result.push(kind);
  81937. }
  81938. }
  81939. return result;
  81940. };
  81941. /**
  81942. * Update index buffer
  81943. * @param indices defines the indices to store in the index buffer
  81944. * @param offset defines the offset in the target buffer where to store the data
  81945. */
  81946. Geometry.prototype.updateIndices = function (indices, offset) {
  81947. if (!this._indexBuffer) {
  81948. return;
  81949. }
  81950. if (!this._indexBufferIsUpdatable) {
  81951. this.setIndices(indices, null, true);
  81952. }
  81953. else {
  81954. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  81955. this._indices = indices;
  81956. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  81957. if (needToUpdateSubMeshes) {
  81958. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81959. var mesh = _a[_i];
  81960. mesh._createGlobalSubMesh(true);
  81961. }
  81962. }
  81963. }
  81964. };
  81965. /**
  81966. * Creates a new index buffer
  81967. * @param indices defines the indices to store in the index buffer
  81968. * @param totalVertices defines the total number of vertices (could be null)
  81969. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81970. */
  81971. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  81972. if (totalVertices === void 0) { totalVertices = null; }
  81973. if (updatable === void 0) { updatable = false; }
  81974. if (this._indexBuffer) {
  81975. this._engine._releaseBuffer(this._indexBuffer);
  81976. }
  81977. this._disposeVertexArrayObjects();
  81978. this._indices = indices;
  81979. this._indexBufferIsUpdatable = updatable;
  81980. if (this._meshes.length !== 0 && this._indices) {
  81981. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  81982. }
  81983. if (totalVertices != undefined) { // including null and undefined
  81984. this._totalVertices = totalVertices;
  81985. }
  81986. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81987. var mesh = _a[_i];
  81988. mesh._createGlobalSubMesh(true);
  81989. }
  81990. this.notifyUpdate();
  81991. };
  81992. /**
  81993. * Return the total number of indices
  81994. * @returns the total number of indices
  81995. */
  81996. Geometry.prototype.getTotalIndices = function () {
  81997. if (!this.isReady()) {
  81998. return 0;
  81999. }
  82000. return this._indices.length;
  82001. };
  82002. /**
  82003. * Gets the index buffer array
  82004. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82005. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82006. * @returns the index buffer array
  82007. */
  82008. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  82009. if (!this.isReady()) {
  82010. return null;
  82011. }
  82012. var orig = this._indices;
  82013. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  82014. return orig;
  82015. }
  82016. else {
  82017. var len = orig.length;
  82018. var copy = [];
  82019. for (var i = 0; i < len; i++) {
  82020. copy.push(orig[i]);
  82021. }
  82022. return copy;
  82023. }
  82024. };
  82025. /**
  82026. * Gets the index buffer
  82027. * @return the index buffer
  82028. */
  82029. Geometry.prototype.getIndexBuffer = function () {
  82030. if (!this.isReady()) {
  82031. return null;
  82032. }
  82033. return this._indexBuffer;
  82034. };
  82035. /** @hidden */
  82036. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  82037. if (effect === void 0) { effect = null; }
  82038. if (!effect || !this._vertexArrayObjects) {
  82039. return;
  82040. }
  82041. if (this._vertexArrayObjects[effect.key]) {
  82042. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  82043. delete this._vertexArrayObjects[effect.key];
  82044. }
  82045. };
  82046. /**
  82047. * Release the associated resources for a specific mesh
  82048. * @param mesh defines the source mesh
  82049. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82050. */
  82051. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  82052. var meshes = this._meshes;
  82053. var index = meshes.indexOf(mesh);
  82054. if (index === -1) {
  82055. return;
  82056. }
  82057. meshes.splice(index, 1);
  82058. mesh._geometry = null;
  82059. if (meshes.length === 0 && shouldDispose) {
  82060. this.dispose();
  82061. }
  82062. };
  82063. /**
  82064. * Apply current geometry to a given mesh
  82065. * @param mesh defines the mesh to apply geometry to
  82066. */
  82067. Geometry.prototype.applyToMesh = function (mesh) {
  82068. if (mesh._geometry === this) {
  82069. return;
  82070. }
  82071. var previousGeometry = mesh._geometry;
  82072. if (previousGeometry) {
  82073. previousGeometry.releaseForMesh(mesh);
  82074. }
  82075. var meshes = this._meshes;
  82076. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  82077. mesh._geometry = this;
  82078. this._scene.pushGeometry(this);
  82079. meshes.push(mesh);
  82080. if (this.isReady()) {
  82081. this._applyToMesh(mesh);
  82082. }
  82083. else {
  82084. mesh._boundingInfo = this._boundingInfo;
  82085. }
  82086. };
  82087. Geometry.prototype._updateExtend = function (data) {
  82088. if (data === void 0) { data = null; }
  82089. if (!data) {
  82090. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82091. }
  82092. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  82093. };
  82094. Geometry.prototype._applyToMesh = function (mesh) {
  82095. var numOfMeshes = this._meshes.length;
  82096. // vertexBuffers
  82097. for (var kind in this._vertexBuffers) {
  82098. if (numOfMeshes === 1) {
  82099. this._vertexBuffers[kind].create();
  82100. }
  82101. var buffer = this._vertexBuffers[kind].getBuffer();
  82102. if (buffer) {
  82103. buffer.references = numOfMeshes;
  82104. }
  82105. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  82106. if (!this._extend) {
  82107. this._updateExtend();
  82108. }
  82109. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82110. mesh._createGlobalSubMesh(false);
  82111. //bounding info was just created again, world matrix should be applied again.
  82112. mesh._updateBoundingInfo();
  82113. }
  82114. }
  82115. // indexBuffer
  82116. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  82117. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  82118. }
  82119. if (this._indexBuffer) {
  82120. this._indexBuffer.references = numOfMeshes;
  82121. }
  82122. // morphTargets
  82123. mesh._syncGeometryWithMorphTargetManager();
  82124. // instances
  82125. mesh.synchronizeInstances();
  82126. };
  82127. Geometry.prototype.notifyUpdate = function (kind) {
  82128. if (this.onGeometryUpdated) {
  82129. this.onGeometryUpdated(this, kind);
  82130. }
  82131. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  82132. var mesh = _a[_i];
  82133. mesh._markSubMeshesAsAttributesDirty();
  82134. }
  82135. };
  82136. /**
  82137. * Load the geometry if it was flagged as delay loaded
  82138. * @param scene defines the hosting scene
  82139. * @param onLoaded defines a callback called when the geometry is loaded
  82140. */
  82141. Geometry.prototype.load = function (scene, onLoaded) {
  82142. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  82143. return;
  82144. }
  82145. if (this.isReady()) {
  82146. if (onLoaded) {
  82147. onLoaded();
  82148. }
  82149. return;
  82150. }
  82151. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  82152. this._queueLoad(scene, onLoaded);
  82153. };
  82154. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  82155. var _this = this;
  82156. if (!this.delayLoadingFile) {
  82157. return;
  82158. }
  82159. scene._addPendingData(this);
  82160. scene._loadFile(this.delayLoadingFile, function (data) {
  82161. if (!_this._delayLoadingFunction) {
  82162. return;
  82163. }
  82164. _this._delayLoadingFunction(JSON.parse(data), _this);
  82165. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  82166. _this._delayInfo = [];
  82167. scene._removePendingData(_this);
  82168. var meshes = _this._meshes;
  82169. var numOfMeshes = meshes.length;
  82170. for (var index = 0; index < numOfMeshes; index++) {
  82171. _this._applyToMesh(meshes[index]);
  82172. }
  82173. if (onLoaded) {
  82174. onLoaded();
  82175. }
  82176. }, undefined, true);
  82177. };
  82178. /**
  82179. * Invert the geometry to move from a right handed system to a left handed one.
  82180. */
  82181. Geometry.prototype.toLeftHanded = function () {
  82182. // Flip faces
  82183. var tIndices = this.getIndices(false);
  82184. if (tIndices != null && tIndices.length > 0) {
  82185. for (var i = 0; i < tIndices.length; i += 3) {
  82186. var tTemp = tIndices[i + 0];
  82187. tIndices[i + 0] = tIndices[i + 2];
  82188. tIndices[i + 2] = tTemp;
  82189. }
  82190. this.setIndices(tIndices);
  82191. }
  82192. // Negate position.z
  82193. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  82194. if (tPositions != null && tPositions.length > 0) {
  82195. for (var i = 0; i < tPositions.length; i += 3) {
  82196. tPositions[i + 2] = -tPositions[i + 2];
  82197. }
  82198. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  82199. }
  82200. // Negate normal.z
  82201. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  82202. if (tNormals != null && tNormals.length > 0) {
  82203. for (var i = 0; i < tNormals.length; i += 3) {
  82204. tNormals[i + 2] = -tNormals[i + 2];
  82205. }
  82206. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  82207. }
  82208. };
  82209. // Cache
  82210. /** @hidden */
  82211. Geometry.prototype._resetPointsArrayCache = function () {
  82212. this._positions = null;
  82213. };
  82214. /** @hidden */
  82215. Geometry.prototype._generatePointsArray = function () {
  82216. if (this._positions) {
  82217. return true;
  82218. }
  82219. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82220. if (!data || data.length === 0) {
  82221. return false;
  82222. }
  82223. this._positions = [];
  82224. for (var index = 0; index < data.length; index += 3) {
  82225. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  82226. }
  82227. return true;
  82228. };
  82229. /**
  82230. * Gets a value indicating if the geometry is disposed
  82231. * @returns true if the geometry was disposed
  82232. */
  82233. Geometry.prototype.isDisposed = function () {
  82234. return this._isDisposed;
  82235. };
  82236. Geometry.prototype._disposeVertexArrayObjects = function () {
  82237. if (this._vertexArrayObjects) {
  82238. for (var kind in this._vertexArrayObjects) {
  82239. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  82240. }
  82241. this._vertexArrayObjects = {};
  82242. }
  82243. };
  82244. /**
  82245. * Free all associated resources
  82246. */
  82247. Geometry.prototype.dispose = function () {
  82248. var meshes = this._meshes;
  82249. var numOfMeshes = meshes.length;
  82250. var index;
  82251. for (index = 0; index < numOfMeshes; index++) {
  82252. this.releaseForMesh(meshes[index]);
  82253. }
  82254. this._meshes = [];
  82255. this._disposeVertexArrayObjects();
  82256. for (var kind in this._vertexBuffers) {
  82257. this._vertexBuffers[kind].dispose();
  82258. }
  82259. this._vertexBuffers = {};
  82260. this._totalVertices = 0;
  82261. if (this._indexBuffer) {
  82262. this._engine._releaseBuffer(this._indexBuffer);
  82263. }
  82264. this._indexBuffer = null;
  82265. this._indices = [];
  82266. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  82267. this.delayLoadingFile = null;
  82268. this._delayLoadingFunction = null;
  82269. this._delayInfo = [];
  82270. this._boundingInfo = null;
  82271. this._scene.removeGeometry(this);
  82272. this._isDisposed = true;
  82273. };
  82274. /**
  82275. * Clone the current geometry into a new geometry
  82276. * @param id defines the unique ID of the new geometry
  82277. * @returns a new geometry object
  82278. */
  82279. Geometry.prototype.copy = function (id) {
  82280. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  82281. vertexData.indices = [];
  82282. var indices = this.getIndices();
  82283. if (indices) {
  82284. for (var index = 0; index < indices.length; index++) {
  82285. vertexData.indices.push(indices[index]);
  82286. }
  82287. }
  82288. var updatable = false;
  82289. var stopChecking = false;
  82290. var kind;
  82291. for (kind in this._vertexBuffers) {
  82292. // using slice() to make a copy of the array and not just reference it
  82293. var data = this.getVerticesData(kind);
  82294. if (data) {
  82295. if (data instanceof Float32Array) {
  82296. vertexData.set(new Float32Array(data), kind);
  82297. }
  82298. else {
  82299. vertexData.set(data.slice(0), kind);
  82300. }
  82301. if (!stopChecking) {
  82302. var vb = this.getVertexBuffer(kind);
  82303. if (vb) {
  82304. updatable = vb.isUpdatable();
  82305. stopChecking = !updatable;
  82306. }
  82307. }
  82308. }
  82309. }
  82310. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  82311. geometry.delayLoadState = this.delayLoadState;
  82312. geometry.delayLoadingFile = this.delayLoadingFile;
  82313. geometry._delayLoadingFunction = this._delayLoadingFunction;
  82314. for (kind in this._delayInfo) {
  82315. geometry._delayInfo = geometry._delayInfo || [];
  82316. geometry._delayInfo.push(kind);
  82317. }
  82318. // Bounding info
  82319. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82320. return geometry;
  82321. };
  82322. /**
  82323. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82324. * @return a JSON representation of the current geometry data (without the vertices data)
  82325. */
  82326. Geometry.prototype.serialize = function () {
  82327. var serializationObject = {};
  82328. serializationObject.id = this.id;
  82329. serializationObject.updatable = this._updatable;
  82330. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  82331. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  82332. }
  82333. return serializationObject;
  82334. };
  82335. Geometry.prototype.toNumberArray = function (origin) {
  82336. if (Array.isArray(origin)) {
  82337. return origin;
  82338. }
  82339. else {
  82340. return Array.prototype.slice.call(origin);
  82341. }
  82342. };
  82343. /**
  82344. * Serialize all vertices data into a JSON oject
  82345. * @returns a JSON representation of the current geometry data
  82346. */
  82347. Geometry.prototype.serializeVerticeData = function () {
  82348. var serializationObject = this.serialize();
  82349. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82350. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  82351. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82352. serializationObject.positions._updatable = true;
  82353. }
  82354. }
  82355. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82356. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  82357. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82358. serializationObject.normals._updatable = true;
  82359. }
  82360. }
  82361. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82362. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  82363. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82364. serializationObject.tangets._updatable = true;
  82365. }
  82366. }
  82367. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82368. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  82369. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82370. serializationObject.uvs._updatable = true;
  82371. }
  82372. }
  82373. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82374. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  82375. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82376. serializationObject.uv2s._updatable = true;
  82377. }
  82378. }
  82379. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82380. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  82381. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82382. serializationObject.uv3s._updatable = true;
  82383. }
  82384. }
  82385. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82386. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  82387. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82388. serializationObject.uv4s._updatable = true;
  82389. }
  82390. }
  82391. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82392. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  82393. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82394. serializationObject.uv5s._updatable = true;
  82395. }
  82396. }
  82397. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82398. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  82399. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82400. serializationObject.uv6s._updatable = true;
  82401. }
  82402. }
  82403. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82404. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  82405. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82406. serializationObject.colors._updatable = true;
  82407. }
  82408. }
  82409. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82410. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  82411. serializationObject.matricesIndices._isExpanded = true;
  82412. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82413. serializationObject.matricesIndices._updatable = true;
  82414. }
  82415. }
  82416. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82417. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  82418. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82419. serializationObject.matricesWeights._updatable = true;
  82420. }
  82421. }
  82422. serializationObject.indices = this.toNumberArray(this.getIndices());
  82423. return serializationObject;
  82424. };
  82425. // Statics
  82426. /**
  82427. * Extracts a clone of a mesh geometry
  82428. * @param mesh defines the source mesh
  82429. * @param id defines the unique ID of the new geometry object
  82430. * @returns the new geometry object
  82431. */
  82432. Geometry.ExtractFromMesh = function (mesh, id) {
  82433. var geometry = mesh._geometry;
  82434. if (!geometry) {
  82435. return null;
  82436. }
  82437. return geometry.copy(id);
  82438. };
  82439. /**
  82440. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82441. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82442. * Be aware Math.random() could cause collisions, but:
  82443. * "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"
  82444. * @returns a string containing a new GUID
  82445. */
  82446. Geometry.RandomId = function () {
  82447. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  82448. };
  82449. /** @hidden */
  82450. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  82451. var scene = mesh.getScene();
  82452. // Geometry
  82453. var geometryId = parsedGeometry.geometryId;
  82454. if (geometryId) {
  82455. var geometry = scene.getGeometryByID(geometryId);
  82456. if (geometry) {
  82457. geometry.applyToMesh(mesh);
  82458. }
  82459. }
  82460. else if (parsedGeometry instanceof ArrayBuffer) {
  82461. var binaryInfo = mesh._binaryInfo;
  82462. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  82463. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  82464. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  82465. }
  82466. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  82467. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  82468. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  82469. }
  82470. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  82471. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  82472. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  82473. }
  82474. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  82475. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  82476. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  82477. }
  82478. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  82479. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  82480. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  82481. }
  82482. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  82483. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  82484. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  82485. }
  82486. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  82487. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  82488. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  82489. }
  82490. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  82491. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  82492. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  82493. }
  82494. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  82495. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  82496. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  82497. }
  82498. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  82499. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  82500. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  82501. }
  82502. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  82503. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  82504. var floatIndices = [];
  82505. for (var i = 0; i < matricesIndicesData.length; i++) {
  82506. var index = matricesIndicesData[i];
  82507. floatIndices.push(index & 0x000000FF);
  82508. floatIndices.push((index & 0x0000FF00) >> 8);
  82509. floatIndices.push((index & 0x00FF0000) >> 16);
  82510. floatIndices.push(index >> 24);
  82511. }
  82512. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  82513. }
  82514. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  82515. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  82516. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  82517. }
  82518. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  82519. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  82520. mesh.setIndices(indicesData, null);
  82521. }
  82522. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  82523. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  82524. mesh.subMeshes = [];
  82525. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  82526. var materialIndex = subMeshesData[(i * 5) + 0];
  82527. var verticesStart = subMeshesData[(i * 5) + 1];
  82528. var verticesCount = subMeshesData[(i * 5) + 2];
  82529. var indexStart = subMeshesData[(i * 5) + 3];
  82530. var indexCount = subMeshesData[(i * 5) + 4];
  82531. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  82532. }
  82533. }
  82534. }
  82535. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  82536. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  82537. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  82538. if (parsedGeometry.tangents) {
  82539. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  82540. }
  82541. if (parsedGeometry.uvs) {
  82542. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  82543. }
  82544. if (parsedGeometry.uvs2) {
  82545. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  82546. }
  82547. if (parsedGeometry.uvs3) {
  82548. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  82549. }
  82550. if (parsedGeometry.uvs4) {
  82551. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  82552. }
  82553. if (parsedGeometry.uvs5) {
  82554. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  82555. }
  82556. if (parsedGeometry.uvs6) {
  82557. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  82558. }
  82559. if (parsedGeometry.colors) {
  82560. 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);
  82561. }
  82562. if (parsedGeometry.matricesIndices) {
  82563. if (!parsedGeometry.matricesIndices._isExpanded) {
  82564. var floatIndices = [];
  82565. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  82566. var matricesIndex = parsedGeometry.matricesIndices[i];
  82567. floatIndices.push(matricesIndex & 0x000000FF);
  82568. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82569. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82570. floatIndices.push(matricesIndex >> 24);
  82571. }
  82572. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  82573. }
  82574. else {
  82575. delete parsedGeometry.matricesIndices._isExpanded;
  82576. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  82577. }
  82578. }
  82579. if (parsedGeometry.matricesIndicesExtra) {
  82580. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  82581. var floatIndices = [];
  82582. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  82583. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  82584. floatIndices.push(matricesIndex & 0x000000FF);
  82585. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82586. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82587. floatIndices.push(matricesIndex >> 24);
  82588. }
  82589. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  82590. }
  82591. else {
  82592. delete parsedGeometry.matricesIndices._isExpanded;
  82593. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  82594. }
  82595. }
  82596. if (parsedGeometry.matricesWeights) {
  82597. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  82598. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  82599. }
  82600. if (parsedGeometry.matricesWeightsExtra) {
  82601. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  82602. }
  82603. mesh.setIndices(parsedGeometry.indices, null);
  82604. }
  82605. // SubMeshes
  82606. if (parsedGeometry.subMeshes) {
  82607. mesh.subMeshes = [];
  82608. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  82609. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  82610. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  82611. }
  82612. }
  82613. // Flat shading
  82614. if (mesh._shouldGenerateFlatShading) {
  82615. mesh.convertToFlatShadedMesh();
  82616. delete mesh._shouldGenerateFlatShading;
  82617. }
  82618. // Update
  82619. mesh.computeWorldMatrix(true);
  82620. scene.onMeshImportedObservable.notifyObservers(mesh);
  82621. };
  82622. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  82623. var epsilon = 1e-3;
  82624. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  82625. return;
  82626. }
  82627. var noInfluenceBoneIndex = 0.0;
  82628. if (parsedGeometry.skeletonId > -1) {
  82629. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  82630. if (!skeleton) {
  82631. return;
  82632. }
  82633. noInfluenceBoneIndex = skeleton.bones.length;
  82634. }
  82635. else {
  82636. return;
  82637. }
  82638. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82639. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  82640. var matricesWeights = parsedGeometry.matricesWeights;
  82641. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  82642. var influencers = parsedGeometry.numBoneInfluencer;
  82643. var size = matricesWeights.length;
  82644. for (var i = 0; i < size; i += 4) {
  82645. var weight = 0.0;
  82646. var firstZeroWeight = -1;
  82647. for (var j = 0; j < 4; j++) {
  82648. var w = matricesWeights[i + j];
  82649. weight += w;
  82650. if (w < epsilon && firstZeroWeight < 0) {
  82651. firstZeroWeight = j;
  82652. }
  82653. }
  82654. if (matricesWeightsExtra) {
  82655. for (var j = 0; j < 4; j++) {
  82656. var w = matricesWeightsExtra[i + j];
  82657. weight += w;
  82658. if (w < epsilon && firstZeroWeight < 0) {
  82659. firstZeroWeight = j + 4;
  82660. }
  82661. }
  82662. }
  82663. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  82664. firstZeroWeight = influencers - 1;
  82665. }
  82666. if (weight > epsilon) {
  82667. var mweight = 1.0 / weight;
  82668. for (var j = 0; j < 4; j++) {
  82669. matricesWeights[i + j] *= mweight;
  82670. }
  82671. if (matricesWeightsExtra) {
  82672. for (var j = 0; j < 4; j++) {
  82673. matricesWeightsExtra[i + j] *= mweight;
  82674. }
  82675. }
  82676. }
  82677. else {
  82678. if (firstZeroWeight >= 4) {
  82679. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  82680. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  82681. }
  82682. else {
  82683. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  82684. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  82685. }
  82686. }
  82687. }
  82688. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  82689. if (parsedGeometry.matricesWeightsExtra) {
  82690. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  82691. }
  82692. };
  82693. /**
  82694. * Create a new geometry from persisted data (Using .babylon file format)
  82695. * @param parsedVertexData defines the persisted data
  82696. * @param scene defines the hosting scene
  82697. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82698. * @returns the new geometry object
  82699. */
  82700. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  82701. if (scene.getGeometryByID(parsedVertexData.id)) {
  82702. return null; // null since geometry could be something else than a box...
  82703. }
  82704. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  82705. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  82706. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  82707. }
  82708. if (parsedVertexData.delayLoadingFile) {
  82709. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  82710. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  82711. 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));
  82712. geometry._delayInfo = [];
  82713. if (parsedVertexData.hasUVs) {
  82714. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  82715. }
  82716. if (parsedVertexData.hasUVs2) {
  82717. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  82718. }
  82719. if (parsedVertexData.hasUVs3) {
  82720. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  82721. }
  82722. if (parsedVertexData.hasUVs4) {
  82723. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  82724. }
  82725. if (parsedVertexData.hasUVs5) {
  82726. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  82727. }
  82728. if (parsedVertexData.hasUVs6) {
  82729. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  82730. }
  82731. if (parsedVertexData.hasColors) {
  82732. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  82733. }
  82734. if (parsedVertexData.hasMatricesIndices) {
  82735. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82736. }
  82737. if (parsedVertexData.hasMatricesWeights) {
  82738. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  82739. }
  82740. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  82741. }
  82742. else {
  82743. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  82744. }
  82745. scene.pushGeometry(geometry, true);
  82746. return geometry;
  82747. };
  82748. return Geometry;
  82749. }());
  82750. /***/ }),
  82751. /***/ "./Meshes/groundMesh.ts":
  82752. /*!******************************!*\
  82753. !*** ./Meshes/groundMesh.ts ***!
  82754. \******************************/
  82755. /*! exports provided: GroundMesh */
  82756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82757. "use strict";
  82758. __webpack_require__.r(__webpack_exports__);
  82759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  82760. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  82761. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82762. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82763. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82764. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  82765. return GroundMesh.Parse(parsedMesh, scene);
  82766. };
  82767. /**
  82768. * Mesh representing the gorund
  82769. */
  82770. var GroundMesh = /** @class */ (function (_super) {
  82771. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  82772. function GroundMesh(name, scene) {
  82773. var _this = _super.call(this, name, scene) || this;
  82774. /** If octree should be generated */
  82775. _this.generateOctree = false;
  82776. return _this;
  82777. }
  82778. /**
  82779. * "GroundMesh"
  82780. * @returns "GroundMesh"
  82781. */
  82782. GroundMesh.prototype.getClassName = function () {
  82783. return "GroundMesh";
  82784. };
  82785. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  82786. /**
  82787. * The minimum of x and y subdivisions
  82788. */
  82789. get: function () {
  82790. return Math.min(this._subdivisionsX, this._subdivisionsY);
  82791. },
  82792. enumerable: true,
  82793. configurable: true
  82794. });
  82795. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  82796. /**
  82797. * X subdivisions
  82798. */
  82799. get: function () {
  82800. return this._subdivisionsX;
  82801. },
  82802. enumerable: true,
  82803. configurable: true
  82804. });
  82805. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  82806. /**
  82807. * Y subdivisions
  82808. */
  82809. get: function () {
  82810. return this._subdivisionsY;
  82811. },
  82812. enumerable: true,
  82813. configurable: true
  82814. });
  82815. /**
  82816. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  82817. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  82818. * @param chunksCount the number of subdivisions for x and y
  82819. * @param octreeBlocksSize (Default: 32)
  82820. */
  82821. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  82822. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  82823. this._subdivisionsX = chunksCount;
  82824. this._subdivisionsY = chunksCount;
  82825. this.subdivide(chunksCount);
  82826. // Call the octree system optimization if it is defined.
  82827. var thisAsAny = this;
  82828. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  82829. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  82830. }
  82831. };
  82832. /**
  82833. * Returns a height (y) value in the Worl system :
  82834. * the ground altitude at the coordinates (x, z) expressed in the World system.
  82835. * @param x x coordinate
  82836. * @param z z coordinate
  82837. * @returns the ground y position if (x, z) are outside the ground surface.
  82838. */
  82839. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  82840. var world = this.getWorldMatrix();
  82841. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82842. world.invertToRef(invMat);
  82843. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82844. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  82845. x = tmpVect.x;
  82846. z = tmpVect.z;
  82847. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82848. return this.position.y;
  82849. }
  82850. if (!this._heightQuads || this._heightQuads.length == 0) {
  82851. this._initHeightQuads();
  82852. this._computeHeightQuads();
  82853. }
  82854. var facet = this._getFacetAt(x, z);
  82855. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  82856. // return y in the World system
  82857. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  82858. return tmpVect.y;
  82859. };
  82860. /**
  82861. * Returns a normalized vector (Vector3) orthogonal to the ground
  82862. * at the ground coordinates (x, z) expressed in the World system.
  82863. * @param x x coordinate
  82864. * @param z z coordinate
  82865. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  82866. */
  82867. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  82868. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  82869. this.getNormalAtCoordinatesToRef(x, z, normal);
  82870. return normal;
  82871. };
  82872. /**
  82873. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  82874. * at the ground coordinates (x, z) expressed in the World system.
  82875. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  82876. * @param x x coordinate
  82877. * @param z z coordinate
  82878. * @param ref vector to store the result
  82879. * @returns the GroundMesh.
  82880. */
  82881. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  82882. var world = this.getWorldMatrix();
  82883. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82884. world.invertToRef(tmpMat);
  82885. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82886. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  82887. x = tmpVect.x;
  82888. z = tmpVect.z;
  82889. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82890. return this;
  82891. }
  82892. if (!this._heightQuads || this._heightQuads.length == 0) {
  82893. this._initHeightQuads();
  82894. this._computeHeightQuads();
  82895. }
  82896. var facet = this._getFacetAt(x, z);
  82897. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  82898. return this;
  82899. };
  82900. /**
  82901. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  82902. * if the ground has been updated.
  82903. * This can be used in the render loop.
  82904. * @returns the GroundMesh.
  82905. */
  82906. GroundMesh.prototype.updateCoordinateHeights = function () {
  82907. if (!this._heightQuads || this._heightQuads.length == 0) {
  82908. this._initHeightQuads();
  82909. }
  82910. this._computeHeightQuads();
  82911. return this;
  82912. };
  82913. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  82914. GroundMesh.prototype._getFacetAt = function (x, z) {
  82915. // retrieve col and row from x, z coordinates in the ground local system
  82916. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  82917. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  82918. var quad = this._heightQuads[row * this._subdivisionsX + col];
  82919. var facet;
  82920. if (z < quad.slope.x * x + quad.slope.y) {
  82921. facet = quad.facet1;
  82922. }
  82923. else {
  82924. facet = quad.facet2;
  82925. }
  82926. return facet;
  82927. };
  82928. // Creates and populates the heightMap array with "facet" elements :
  82929. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  82930. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82931. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82932. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82933. // Returns the GroundMesh.
  82934. GroundMesh.prototype._initHeightQuads = function () {
  82935. var subdivisionsX = this._subdivisionsX;
  82936. var subdivisionsY = this._subdivisionsY;
  82937. this._heightQuads = new Array();
  82938. for (var row = 0; row < subdivisionsY; row++) {
  82939. for (var col = 0; col < subdivisionsX; col++) {
  82940. 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) };
  82941. this._heightQuads[row * subdivisionsX + col] = quad;
  82942. }
  82943. }
  82944. return this;
  82945. };
  82946. // Compute each quad element values and update the the heightMap array :
  82947. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82948. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82949. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82950. // Returns the GroundMesh.
  82951. GroundMesh.prototype._computeHeightQuads = function () {
  82952. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82953. if (!positions) {
  82954. return this;
  82955. }
  82956. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  82957. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  82958. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  82959. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  82960. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  82961. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  82962. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  82963. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  82964. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82965. var i = 0;
  82966. var j = 0;
  82967. var k = 0;
  82968. var cd = 0; // 2D slope coefficient : z = cd * x + h
  82969. var h = 0;
  82970. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  82971. var d2 = 0;
  82972. var subdivisionsX = this._subdivisionsX;
  82973. var subdivisionsY = this._subdivisionsY;
  82974. for (var row = 0; row < subdivisionsY; row++) {
  82975. for (var col = 0; col < subdivisionsX; col++) {
  82976. i = col * 3;
  82977. j = row * (subdivisionsX + 1) * 3;
  82978. k = (row + 1) * (subdivisionsX + 1) * 3;
  82979. v1.x = positions[j + i];
  82980. v1.y = positions[j + i + 1];
  82981. v1.z = positions[j + i + 2];
  82982. v2.x = positions[j + i + 3];
  82983. v2.y = positions[j + i + 4];
  82984. v2.z = positions[j + i + 5];
  82985. v3.x = positions[k + i];
  82986. v3.y = positions[k + i + 1];
  82987. v3.z = positions[k + i + 2];
  82988. v4.x = positions[k + i + 3];
  82989. v4.y = positions[k + i + 4];
  82990. v4.z = positions[k + i + 5];
  82991. // 2D slope V1V4
  82992. cd = (v4.z - v1.z) / (v4.x - v1.x);
  82993. h = v1.z - cd * v1.x; // v1 belongs to the slope
  82994. // facet equations :
  82995. // we compute each facet normal vector
  82996. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  82997. // we compute the value d by applying the equation to v1 which belongs to the plane
  82998. // then we store the facet equation in a Vector4
  82999. v2.subtractToRef(v1, v1v2);
  83000. v3.subtractToRef(v1, v1v3);
  83001. v4.subtractToRef(v1, v1v4);
  83002. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  83003. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  83004. norm1.normalize();
  83005. norm2.normalize();
  83006. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  83007. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  83008. var quad = this._heightQuads[row * subdivisionsX + col];
  83009. quad.slope.copyFromFloats(cd, h);
  83010. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  83011. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  83012. }
  83013. }
  83014. return this;
  83015. };
  83016. /**
  83017. * Serializes this ground mesh
  83018. * @param serializationObject object to write serialization to
  83019. */
  83020. GroundMesh.prototype.serialize = function (serializationObject) {
  83021. _super.prototype.serialize.call(this, serializationObject);
  83022. serializationObject.subdivisionsX = this._subdivisionsX;
  83023. serializationObject.subdivisionsY = this._subdivisionsY;
  83024. serializationObject.minX = this._minX;
  83025. serializationObject.maxX = this._maxX;
  83026. serializationObject.minZ = this._minZ;
  83027. serializationObject.maxZ = this._maxZ;
  83028. serializationObject.width = this._width;
  83029. serializationObject.height = this._height;
  83030. };
  83031. /**
  83032. * Parses a serialized ground mesh
  83033. * @param parsedMesh the serialized mesh
  83034. * @param scene the scene to create the ground mesh in
  83035. * @returns the created ground mesh
  83036. */
  83037. GroundMesh.Parse = function (parsedMesh, scene) {
  83038. var result = new GroundMesh(parsedMesh.name, scene);
  83039. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  83040. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  83041. result._minX = parsedMesh.minX;
  83042. result._maxX = parsedMesh.maxX;
  83043. result._minZ = parsedMesh.minZ;
  83044. result._maxZ = parsedMesh.maxZ;
  83045. result._width = parsedMesh.width;
  83046. result._height = parsedMesh.height;
  83047. return result;
  83048. };
  83049. return GroundMesh;
  83050. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83051. /***/ }),
  83052. /***/ "./Meshes/index.ts":
  83053. /*!*************************!*\
  83054. !*** ./Meshes/index.ts ***!
  83055. \*************************/
  83056. /*! 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, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  83057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83058. "use strict";
  83059. __webpack_require__.r(__webpack_exports__);
  83060. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  83062. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  83064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  83065. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  83066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  83067. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  83068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  83069. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  83071. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  83072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  83073. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  83074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_6__["InstancedMesh"]; });
  83075. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  83076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["LinesMesh"]; });
  83077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedLinesMesh"]; });
  83078. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  83079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["MeshLODLevel"]; });
  83080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_CreationDataStorage"]; });
  83081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_InstancesBatch"]; });
  83082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["Mesh"]; });
  83083. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]; });
  83085. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  83086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_10__["MeshBuilder"]; });
  83087. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  83088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationSettings"]; });
  83089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationQueue"]; });
  83090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationType"]; });
  83091. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  83092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__["SimplicationQueueSceneComponent"]; });
  83093. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  83094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["Polygon"]; });
  83095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["PolygonMeshBuilder"]; });
  83096. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["BaseSubMesh"]; });
  83098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["SubMesh"]; });
  83099. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  83100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_15__["TransformNode"]; });
  83101. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  83102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["BoxBuilder"]; });
  83103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["SphereBuilder"]; });
  83104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["CylinderBuilder"]; });
  83105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LinesBuilder"]; });
  83106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PlaneBuilder"]; });
  83107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DiscBuilder"]; });
  83108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["RibbonBuilder"]; });
  83109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusBuilder"]; });
  83110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusKnotBuilder"]; });
  83111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolygonBuilder"]; });
  83112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["ShapeBuilder"]; });
  83113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LatheBuilder"]; });
  83114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["GroundBuilder"]; });
  83115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TubeBuilder"]; });
  83116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolyhedronBuilder"]; });
  83117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  83118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  83119. /***/ }),
  83120. /***/ "./Meshes/instancedMesh.ts":
  83121. /*!*********************************!*\
  83122. !*** ./Meshes/instancedMesh.ts ***!
  83123. \*********************************/
  83124. /*! exports provided: InstancedMesh */
  83125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83126. "use strict";
  83127. __webpack_require__.r(__webpack_exports__);
  83128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  83129. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83130. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83131. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  83132. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83133. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83134. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  83135. return new InstancedMesh(name, mesh);
  83136. };
  83137. /**
  83138. * Creates an instance based on a source mesh.
  83139. */
  83140. var InstancedMesh = /** @class */ (function (_super) {
  83141. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  83142. function InstancedMesh(name, source) {
  83143. var _this = _super.call(this, name, source.getScene()) || this;
  83144. /** @hidden */
  83145. _this._indexInSourceMeshInstanceArray = -1;
  83146. source.addInstance(_this);
  83147. _this._sourceMesh = source;
  83148. _this.position.copyFrom(source.position);
  83149. _this.rotation.copyFrom(source.rotation);
  83150. _this.scaling.copyFrom(source.scaling);
  83151. if (source.rotationQuaternion) {
  83152. _this.rotationQuaternion = source.rotationQuaternion.clone();
  83153. }
  83154. _this.infiniteDistance = source.infiniteDistance;
  83155. _this.setPivotMatrix(source.getPivotMatrix());
  83156. _this.refreshBoundingInfo();
  83157. _this._syncSubMeshes();
  83158. return _this;
  83159. }
  83160. /**
  83161. * Returns the string "InstancedMesh".
  83162. */
  83163. InstancedMesh.prototype.getClassName = function () {
  83164. return "InstancedMesh";
  83165. };
  83166. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  83167. // Methods
  83168. /**
  83169. * If the source mesh receives shadows
  83170. */
  83171. get: function () {
  83172. return this._sourceMesh.receiveShadows;
  83173. },
  83174. enumerable: true,
  83175. configurable: true
  83176. });
  83177. Object.defineProperty(InstancedMesh.prototype, "material", {
  83178. /**
  83179. * The material of the source mesh
  83180. */
  83181. get: function () {
  83182. return this._sourceMesh.material;
  83183. },
  83184. enumerable: true,
  83185. configurable: true
  83186. });
  83187. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  83188. /**
  83189. * Visibility of the source mesh
  83190. */
  83191. get: function () {
  83192. return this._sourceMesh.visibility;
  83193. },
  83194. enumerable: true,
  83195. configurable: true
  83196. });
  83197. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  83198. /**
  83199. * Skeleton of the source mesh
  83200. */
  83201. get: function () {
  83202. return this._sourceMesh.skeleton;
  83203. },
  83204. enumerable: true,
  83205. configurable: true
  83206. });
  83207. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  83208. /**
  83209. * Rendering ground id of the source mesh
  83210. */
  83211. get: function () {
  83212. return this._sourceMesh.renderingGroupId;
  83213. },
  83214. set: function (value) {
  83215. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  83216. return;
  83217. }
  83218. //no-op with warning
  83219. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  83220. },
  83221. enumerable: true,
  83222. configurable: true
  83223. });
  83224. /**
  83225. * Returns the total number of vertices (integer).
  83226. */
  83227. InstancedMesh.prototype.getTotalVertices = function () {
  83228. return this._sourceMesh.getTotalVertices();
  83229. };
  83230. /**
  83231. * Returns a positive integer : the total number of indices in this mesh geometry.
  83232. * @returns the numner of indices or zero if the mesh has no geometry.
  83233. */
  83234. InstancedMesh.prototype.getTotalIndices = function () {
  83235. return this._sourceMesh.getTotalIndices();
  83236. };
  83237. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  83238. /**
  83239. * The source mesh of the instance
  83240. */
  83241. get: function () {
  83242. return this._sourceMesh;
  83243. },
  83244. enumerable: true,
  83245. configurable: true
  83246. });
  83247. /**
  83248. * Is this node ready to be used/rendered
  83249. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83250. * @return {boolean} is it ready
  83251. */
  83252. InstancedMesh.prototype.isReady = function (completeCheck) {
  83253. if (completeCheck === void 0) { completeCheck = false; }
  83254. return this._sourceMesh.isReady(completeCheck, true);
  83255. };
  83256. /**
  83257. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83258. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83259. * @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.
  83260. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83261. */
  83262. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  83263. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  83264. };
  83265. /**
  83266. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83267. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83268. * The `data` are either a numeric array either a Float32Array.
  83269. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83270. * 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).
  83271. * Note that a new underlying VertexBuffer object is created each call.
  83272. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83273. *
  83274. * Possible `kind` values :
  83275. * - VertexBuffer.PositionKind
  83276. * - VertexBuffer.UVKind
  83277. * - VertexBuffer.UV2Kind
  83278. * - VertexBuffer.UV3Kind
  83279. * - VertexBuffer.UV4Kind
  83280. * - VertexBuffer.UV5Kind
  83281. * - VertexBuffer.UV6Kind
  83282. * - VertexBuffer.ColorKind
  83283. * - VertexBuffer.MatricesIndicesKind
  83284. * - VertexBuffer.MatricesIndicesExtraKind
  83285. * - VertexBuffer.MatricesWeightsKind
  83286. * - VertexBuffer.MatricesWeightsExtraKind
  83287. *
  83288. * Returns the Mesh.
  83289. */
  83290. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  83291. if (this.sourceMesh) {
  83292. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  83293. }
  83294. return this.sourceMesh;
  83295. };
  83296. /**
  83297. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83298. * If the mesh has no geometry, it is simply returned as it is.
  83299. * The `data` are either a numeric array either a Float32Array.
  83300. * No new underlying VertexBuffer object is created.
  83301. * 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.
  83302. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83303. *
  83304. * Possible `kind` values :
  83305. * - VertexBuffer.PositionKind
  83306. * - VertexBuffer.UVKind
  83307. * - VertexBuffer.UV2Kind
  83308. * - VertexBuffer.UV3Kind
  83309. * - VertexBuffer.UV4Kind
  83310. * - VertexBuffer.UV5Kind
  83311. * - VertexBuffer.UV6Kind
  83312. * - VertexBuffer.ColorKind
  83313. * - VertexBuffer.MatricesIndicesKind
  83314. * - VertexBuffer.MatricesIndicesExtraKind
  83315. * - VertexBuffer.MatricesWeightsKind
  83316. * - VertexBuffer.MatricesWeightsExtraKind
  83317. *
  83318. * Returns the Mesh.
  83319. */
  83320. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  83321. if (this.sourceMesh) {
  83322. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  83323. }
  83324. return this.sourceMesh;
  83325. };
  83326. /**
  83327. * Sets the mesh indices.
  83328. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83329. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83330. * This method creates a new index buffer each call.
  83331. * Returns the Mesh.
  83332. */
  83333. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  83334. if (totalVertices === void 0) { totalVertices = null; }
  83335. if (this.sourceMesh) {
  83336. this.sourceMesh.setIndices(indices, totalVertices);
  83337. }
  83338. return this.sourceMesh;
  83339. };
  83340. /**
  83341. * Boolean : True if the mesh owns the requested kind of data.
  83342. */
  83343. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  83344. return this._sourceMesh.isVerticesDataPresent(kind);
  83345. };
  83346. /**
  83347. * Returns an array of indices (IndicesArray).
  83348. */
  83349. InstancedMesh.prototype.getIndices = function () {
  83350. return this._sourceMesh.getIndices();
  83351. };
  83352. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  83353. get: function () {
  83354. return this._sourceMesh._positions;
  83355. },
  83356. enumerable: true,
  83357. configurable: true
  83358. });
  83359. /**
  83360. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83361. * This means the mesh underlying bounding box and sphere are recomputed.
  83362. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83363. * @returns the current mesh
  83364. */
  83365. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  83366. if (applySkeleton === void 0) { applySkeleton = false; }
  83367. if (this._boundingInfo && this._boundingInfo.isLocked) {
  83368. return this;
  83369. }
  83370. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  83371. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  83372. return this;
  83373. };
  83374. /** @hidden */
  83375. InstancedMesh.prototype._preActivate = function () {
  83376. if (this._currentLOD) {
  83377. this._currentLOD._preActivate();
  83378. }
  83379. return this;
  83380. };
  83381. /** @hidden */
  83382. InstancedMesh.prototype._activate = function (renderId) {
  83383. if (this._currentLOD) {
  83384. this._currentLOD._registerInstanceForRenderId(this, renderId);
  83385. }
  83386. return this;
  83387. };
  83388. /**
  83389. * Returns the current associated LOD AbstractMesh.
  83390. */
  83391. InstancedMesh.prototype.getLOD = function (camera) {
  83392. if (!camera) {
  83393. return this;
  83394. }
  83395. var boundingInfo = this.getBoundingInfo();
  83396. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  83397. if (this._currentLOD === this.sourceMesh) {
  83398. return this;
  83399. }
  83400. return this._currentLOD;
  83401. };
  83402. /** @hidden */
  83403. InstancedMesh.prototype._syncSubMeshes = function () {
  83404. this.releaseSubMeshes();
  83405. if (this._sourceMesh.subMeshes) {
  83406. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  83407. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  83408. }
  83409. }
  83410. return this;
  83411. };
  83412. /** @hidden */
  83413. InstancedMesh.prototype._generatePointsArray = function () {
  83414. return this._sourceMesh._generatePointsArray();
  83415. };
  83416. /**
  83417. * Creates a new InstancedMesh from the current mesh.
  83418. * - name (string) : the cloned mesh name
  83419. * - newParent (optional Node) : the optional Node to parent the clone to.
  83420. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83421. *
  83422. * Returns the clone.
  83423. */
  83424. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83425. var result = this._sourceMesh.createInstance(name);
  83426. // Deep copy
  83427. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  83428. // Bounding info
  83429. this.refreshBoundingInfo();
  83430. // Parent
  83431. if (newParent) {
  83432. result.parent = newParent;
  83433. }
  83434. if (!doNotCloneChildren) {
  83435. // Children
  83436. for (var index = 0; index < this.getScene().meshes.length; index++) {
  83437. var mesh = this.getScene().meshes[index];
  83438. if (mesh.parent === this) {
  83439. mesh.clone(mesh.name, result);
  83440. }
  83441. }
  83442. }
  83443. result.computeWorldMatrix(true);
  83444. return result;
  83445. };
  83446. /**
  83447. * Disposes the InstancedMesh.
  83448. * Returns nothing.
  83449. */
  83450. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83451. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83452. // Remove from mesh
  83453. this._sourceMesh.removeInstance(this);
  83454. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83455. };
  83456. return InstancedMesh;
  83457. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  83458. /***/ }),
  83459. /***/ "./Meshes/linesMesh.ts":
  83460. /*!*****************************!*\
  83461. !*** ./Meshes/linesMesh.ts ***!
  83462. \*****************************/
  83463. /*! exports provided: LinesMesh, InstancedLinesMesh */
  83464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83465. "use strict";
  83466. __webpack_require__.r(__webpack_exports__);
  83467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  83468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  83469. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83470. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83471. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83472. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83473. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  83474. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83475. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  83476. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  83477. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  83478. /**
  83479. * Line mesh
  83480. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83481. */
  83482. var LinesMesh = /** @class */ (function (_super) {
  83483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  83484. /**
  83485. * Creates a new LinesMesh
  83486. * @param name defines the name
  83487. * @param scene defines the hosting scene
  83488. * @param parent defines the parent mesh if any
  83489. * @param source defines the optional source LinesMesh used to clone data from
  83490. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83491. * When false, achieved by calling a clone(), also passing False.
  83492. * This will make creation of children, recursive.
  83493. * @param useVertexColor defines if this LinesMesh supports vertex color
  83494. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83495. */
  83496. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  83497. /**
  83498. * If vertex color should be applied to the mesh
  83499. */
  83500. useVertexColor,
  83501. /**
  83502. * If vertex alpha should be applied to the mesh
  83503. */
  83504. useVertexAlpha) {
  83505. if (scene === void 0) { scene = null; }
  83506. if (parent === void 0) { parent = null; }
  83507. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  83508. _this.useVertexColor = useVertexColor;
  83509. _this.useVertexAlpha = useVertexAlpha;
  83510. /**
  83511. * Color of the line (Default: White)
  83512. */
  83513. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  83514. /**
  83515. * Alpha of the line (Default: 1)
  83516. */
  83517. _this.alpha = 1;
  83518. if (source) {
  83519. _this.color = source.color.clone();
  83520. _this.alpha = source.alpha;
  83521. _this.useVertexColor = source.useVertexColor;
  83522. _this.useVertexAlpha = source.useVertexAlpha;
  83523. }
  83524. _this.intersectionThreshold = 0.1;
  83525. var defines = [];
  83526. var options = {
  83527. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  83528. uniforms: ["world", "viewProjection"],
  83529. needAlphaBlending: true,
  83530. defines: defines
  83531. };
  83532. if (useVertexAlpha === false) {
  83533. options.needAlphaBlending = false;
  83534. }
  83535. if (!useVertexColor) {
  83536. options.uniforms.push("color");
  83537. }
  83538. else {
  83539. options.defines.push("#define VERTEXCOLOR");
  83540. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  83541. }
  83542. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  83543. return _this;
  83544. }
  83545. /**
  83546. * Returns the string "LineMesh"
  83547. */
  83548. LinesMesh.prototype.getClassName = function () {
  83549. return "LinesMesh";
  83550. };
  83551. Object.defineProperty(LinesMesh.prototype, "material", {
  83552. /**
  83553. * @hidden
  83554. */
  83555. get: function () {
  83556. return this._colorShader;
  83557. },
  83558. /**
  83559. * @hidden
  83560. */
  83561. set: function (value) {
  83562. // Do nothing
  83563. },
  83564. enumerable: true,
  83565. configurable: true
  83566. });
  83567. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  83568. /**
  83569. * @hidden
  83570. */
  83571. get: function () {
  83572. return false;
  83573. },
  83574. enumerable: true,
  83575. configurable: true
  83576. });
  83577. /** @hidden */
  83578. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  83579. if (!this._geometry) {
  83580. return this;
  83581. }
  83582. // VBOs
  83583. this._geometry._bind(this._colorShader.getEffect());
  83584. // Color
  83585. if (!this.useVertexColor) {
  83586. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  83587. }
  83588. return this;
  83589. };
  83590. /** @hidden */
  83591. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  83592. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  83593. return this;
  83594. }
  83595. var engine = this.getScene().getEngine();
  83596. // Draw order
  83597. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  83598. return this;
  83599. };
  83600. /**
  83601. * Disposes of the line mesh
  83602. * @param doNotRecurse If children should be disposed
  83603. */
  83604. LinesMesh.prototype.dispose = function (doNotRecurse) {
  83605. this._colorShader.dispose(false, false, true);
  83606. _super.prototype.dispose.call(this, doNotRecurse);
  83607. };
  83608. /**
  83609. * Returns a new LineMesh object cloned from the current one.
  83610. */
  83611. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83612. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  83613. };
  83614. /**
  83615. * Creates a new InstancedLinesMesh object from the mesh model.
  83616. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83617. * @param name defines the name of the new instance
  83618. * @returns a new InstancedLinesMesh
  83619. */
  83620. LinesMesh.prototype.createInstance = function (name) {
  83621. return new InstancedLinesMesh(name, this);
  83622. };
  83623. return LinesMesh;
  83624. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83625. /**
  83626. * Creates an instance based on a source LinesMesh
  83627. */
  83628. var InstancedLinesMesh = /** @class */ (function (_super) {
  83629. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  83630. function InstancedLinesMesh(name, source) {
  83631. var _this = _super.call(this, name, source) || this;
  83632. _this.intersectionThreshold = source.intersectionThreshold;
  83633. return _this;
  83634. }
  83635. /**
  83636. * Returns the string "InstancedLinesMesh".
  83637. */
  83638. InstancedLinesMesh.prototype.getClassName = function () {
  83639. return "InstancedLinesMesh";
  83640. };
  83641. return InstancedLinesMesh;
  83642. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  83643. /***/ }),
  83644. /***/ "./Meshes/mesh.ts":
  83645. /*!************************!*\
  83646. !*** ./Meshes/mesh.ts ***!
  83647. \************************/
  83648. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  83649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83650. "use strict";
  83651. __webpack_require__.r(__webpack_exports__);
  83652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  83653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  83654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  83655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  83656. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83657. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  83658. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83659. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83660. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  83661. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83662. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  83663. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83664. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83665. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83666. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83667. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83668. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83669. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83670. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  83671. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  83672. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83673. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  83674. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83675. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  83676. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  83677. /**
  83678. * Class used to represent a specific level of detail of a mesh
  83679. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  83680. */
  83681. var MeshLODLevel = /** @class */ (function () {
  83682. /**
  83683. * Creates a new LOD level
  83684. * @param distance defines the distance where this level should star being displayed
  83685. * @param mesh defines the mesh to use to render this level
  83686. */
  83687. function MeshLODLevel(
  83688. /** Defines the distance where this level should star being displayed */
  83689. distance,
  83690. /** Defines the mesh to use to render this level */
  83691. mesh) {
  83692. this.distance = distance;
  83693. this.mesh = mesh;
  83694. }
  83695. return MeshLODLevel;
  83696. }());
  83697. /**
  83698. * @hidden
  83699. **/
  83700. var _CreationDataStorage = /** @class */ (function () {
  83701. function _CreationDataStorage() {
  83702. }
  83703. return _CreationDataStorage;
  83704. }());
  83705. /**
  83706. * @hidden
  83707. **/
  83708. var _InstanceDataStorage = /** @class */ (function () {
  83709. function _InstanceDataStorage() {
  83710. this.visibleInstances = {};
  83711. this.renderIdForInstances = new Array();
  83712. this.batchCache = new _InstancesBatch();
  83713. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  83714. }
  83715. return _InstanceDataStorage;
  83716. }());
  83717. /**
  83718. * @hidden
  83719. **/
  83720. var _InstancesBatch = /** @class */ (function () {
  83721. function _InstancesBatch() {
  83722. this.mustReturn = false;
  83723. this.visibleInstances = new Array();
  83724. this.renderSelf = new Array();
  83725. }
  83726. return _InstancesBatch;
  83727. }());
  83728. /**
  83729. * Class used to represent renderable models
  83730. */
  83731. var Mesh = /** @class */ (function (_super) {
  83732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  83733. /**
  83734. * @constructor
  83735. * @param name The value used by scene.getMeshByName() to do a lookup.
  83736. * @param scene The scene to add this mesh to.
  83737. * @param parent The parent of this mesh, if it has one
  83738. * @param source An optional Mesh from which geometry is shared, cloned.
  83739. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83740. * When false, achieved by calling a clone(), also passing False.
  83741. * This will make creation of children, recursive.
  83742. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83743. */
  83744. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  83745. if (scene === void 0) { scene = null; }
  83746. if (parent === void 0) { parent = null; }
  83747. if (source === void 0) { source = null; }
  83748. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  83749. var _this = _super.call(this, name, scene) || this;
  83750. // Members
  83751. /**
  83752. * Gets the delay loading state of the mesh (when delay loading is turned on)
  83753. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  83754. */
  83755. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  83756. /**
  83757. * Gets the list of instances created from this mesh
  83758. * it is not supposed to be modified manually.
  83759. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  83760. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83761. */
  83762. _this.instances = new Array();
  83763. _this._LODLevels = new Array();
  83764. /** @hidden */
  83765. _this._instanceDataStorage = new _InstanceDataStorage();
  83766. // Use by builder only to know what orientation were the mesh build in.
  83767. /** @hidden */
  83768. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  83769. /**
  83770. * Use this property to change the original side orientation defined at construction time
  83771. */
  83772. _this.overrideMaterialSideOrientation = null;
  83773. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  83774. // Will be used to save a source mesh reference, If any
  83775. _this._source = null;
  83776. /** @hidden */
  83777. _this._isMesh = true;
  83778. scene = _this.getScene();
  83779. if (source) {
  83780. // Geometry
  83781. if (source._geometry) {
  83782. source._geometry.applyToMesh(_this);
  83783. }
  83784. // Deep copy
  83785. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  83786. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  83787. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  83788. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  83789. "onDisposeObservable"
  83790. ], ["_poseMatrix"]);
  83791. // Source mesh
  83792. _this._source = source;
  83793. if (scene.useClonedMeshhMap) {
  83794. if (!source.meshMap) {
  83795. source.meshMap = {};
  83796. }
  83797. source.meshMap[_this.uniqueId] = _this;
  83798. }
  83799. // Construction Params
  83800. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  83801. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  83802. _this._creationDataStorage = source._creationDataStorage;
  83803. // Animation ranges
  83804. if (_this._source._ranges) {
  83805. var ranges = _this._source._ranges;
  83806. for (var name in ranges) {
  83807. if (!ranges.hasOwnProperty(name)) {
  83808. continue;
  83809. }
  83810. if (!ranges[name]) {
  83811. continue;
  83812. }
  83813. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  83814. }
  83815. }
  83816. // Metadata
  83817. if (source.metadata && source.metadata.clone) {
  83818. _this.metadata = source.metadata.clone();
  83819. }
  83820. else {
  83821. _this.metadata = source.metadata;
  83822. }
  83823. // Tags
  83824. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  83825. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  83826. }
  83827. // Parent
  83828. _this.parent = source.parent;
  83829. // Pivot
  83830. _this.setPivotMatrix(source.getPivotMatrix());
  83831. _this.id = name + "." + source.id;
  83832. // Material
  83833. _this.material = source.material;
  83834. var index;
  83835. if (!doNotCloneChildren) {
  83836. // Children
  83837. var directDescendants = source.getDescendants(true);
  83838. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  83839. var child = directDescendants[index_1];
  83840. if (child.clone) {
  83841. child.clone(name + "." + child.name, _this);
  83842. }
  83843. }
  83844. }
  83845. // Physics clone
  83846. var physicsEngine = _this.getScene().getPhysicsEngine();
  83847. if (clonePhysicsImpostor && physicsEngine) {
  83848. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  83849. if (impostor) {
  83850. _this.physicsImpostor = impostor.clone(_this);
  83851. }
  83852. }
  83853. // Particles
  83854. for (index = 0; index < scene.particleSystems.length; index++) {
  83855. var system = scene.particleSystems[index];
  83856. if (system.emitter === source) {
  83857. system.clone(system.name, _this);
  83858. }
  83859. }
  83860. _this.refreshBoundingInfo();
  83861. _this.computeWorldMatrix(true);
  83862. }
  83863. // Parent
  83864. if (parent !== null) {
  83865. _this.parent = parent;
  83866. }
  83867. return _this;
  83868. }
  83869. /**
  83870. * Gets the default side orientation.
  83871. * @param orientation the orientation to value to attempt to get
  83872. * @returns the default orientation
  83873. * @hidden
  83874. */
  83875. Mesh._GetDefaultSideOrientation = function (orientation) {
  83876. if (orientation == Mesh.DOUBLESIDE) {
  83877. return Mesh.DOUBLESIDE;
  83878. }
  83879. if (orientation === undefined || orientation === null) {
  83880. return Mesh.FRONTSIDE;
  83881. }
  83882. return orientation;
  83883. };
  83884. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  83885. /**
  83886. * An event triggered before rendering the mesh
  83887. */
  83888. get: function () {
  83889. if (!this._onBeforeRenderObservable) {
  83890. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83891. }
  83892. return this._onBeforeRenderObservable;
  83893. },
  83894. enumerable: true,
  83895. configurable: true
  83896. });
  83897. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  83898. /**
  83899. * An event triggered before binding the mesh
  83900. */
  83901. get: function () {
  83902. if (!this._onBeforeBindObservable) {
  83903. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83904. }
  83905. return this._onBeforeBindObservable;
  83906. },
  83907. enumerable: true,
  83908. configurable: true
  83909. });
  83910. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  83911. /**
  83912. * An event triggered after rendering the mesh
  83913. */
  83914. get: function () {
  83915. if (!this._onAfterRenderObservable) {
  83916. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83917. }
  83918. return this._onAfterRenderObservable;
  83919. },
  83920. enumerable: true,
  83921. configurable: true
  83922. });
  83923. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  83924. /**
  83925. * An event triggered before drawing the mesh
  83926. */
  83927. get: function () {
  83928. if (!this._onBeforeDrawObservable) {
  83929. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83930. }
  83931. return this._onBeforeDrawObservable;
  83932. },
  83933. enumerable: true,
  83934. configurable: true
  83935. });
  83936. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  83937. /**
  83938. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  83939. */
  83940. set: function (callback) {
  83941. if (this._onBeforeDrawObserver) {
  83942. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  83943. }
  83944. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  83945. },
  83946. enumerable: true,
  83947. configurable: true
  83948. });
  83949. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  83950. /**
  83951. * Gets or sets the morph target manager
  83952. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  83953. */
  83954. get: function () {
  83955. return this._morphTargetManager;
  83956. },
  83957. set: function (value) {
  83958. if (this._morphTargetManager === value) {
  83959. return;
  83960. }
  83961. this._morphTargetManager = value;
  83962. this._syncGeometryWithMorphTargetManager();
  83963. },
  83964. enumerable: true,
  83965. configurable: true
  83966. });
  83967. Object.defineProperty(Mesh.prototype, "source", {
  83968. /**
  83969. * Gets the source mesh (the one used to clone this one from)
  83970. */
  83971. get: function () {
  83972. return this._source;
  83973. },
  83974. enumerable: true,
  83975. configurable: true
  83976. });
  83977. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  83978. /**
  83979. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83980. */
  83981. get: function () {
  83982. return this._unIndexed;
  83983. },
  83984. set: function (value) {
  83985. if (this._unIndexed !== value) {
  83986. this._unIndexed = value;
  83987. this._markSubMeshesAsAttributesDirty();
  83988. }
  83989. },
  83990. enumerable: true,
  83991. configurable: true
  83992. });
  83993. // Methods
  83994. /**
  83995. * Gets the class name
  83996. * @returns the string "Mesh".
  83997. */
  83998. Mesh.prototype.getClassName = function () {
  83999. return "Mesh";
  84000. };
  84001. /**
  84002. * Returns a description of this mesh
  84003. * @param fullDetails define if full details about this mesh must be used
  84004. * @returns a descriptive string representing this mesh
  84005. */
  84006. Mesh.prototype.toString = function (fullDetails) {
  84007. var ret = _super.prototype.toString.call(this, fullDetails);
  84008. ret += ", n vertices: " + this.getTotalVertices();
  84009. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  84010. if (this.animations) {
  84011. for (var i = 0; i < this.animations.length; i++) {
  84012. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  84013. }
  84014. }
  84015. if (fullDetails) {
  84016. if (this._geometry) {
  84017. var ib = this.getIndices();
  84018. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84019. if (vb && ib) {
  84020. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  84021. }
  84022. }
  84023. else {
  84024. ret += ", flat shading: UNKNOWN";
  84025. }
  84026. }
  84027. return ret;
  84028. };
  84029. /** @hidden */
  84030. Mesh.prototype._unBindEffect = function () {
  84031. _super.prototype._unBindEffect.call(this);
  84032. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  84033. var instance = _a[_i];
  84034. instance._unBindEffect();
  84035. }
  84036. };
  84037. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  84038. /**
  84039. * Gets a boolean indicating if this mesh has LOD
  84040. */
  84041. get: function () {
  84042. return this._LODLevels.length > 0;
  84043. },
  84044. enumerable: true,
  84045. configurable: true
  84046. });
  84047. /**
  84048. * Gets the list of MeshLODLevel associated with the current mesh
  84049. * @returns an array of MeshLODLevel
  84050. */
  84051. Mesh.prototype.getLODLevels = function () {
  84052. return this._LODLevels;
  84053. };
  84054. Mesh.prototype._sortLODLevels = function () {
  84055. this._LODLevels.sort(function (a, b) {
  84056. if (a.distance < b.distance) {
  84057. return 1;
  84058. }
  84059. if (a.distance > b.distance) {
  84060. return -1;
  84061. }
  84062. return 0;
  84063. });
  84064. };
  84065. /**
  84066. * Add a mesh as LOD level triggered at the given distance.
  84067. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84068. * @param distance The distance from the center of the object to show this level
  84069. * @param mesh The mesh to be added as LOD level (can be null)
  84070. * @return This mesh (for chaining)
  84071. */
  84072. Mesh.prototype.addLODLevel = function (distance, mesh) {
  84073. if (mesh && mesh._masterMesh) {
  84074. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  84075. return this;
  84076. }
  84077. var level = new MeshLODLevel(distance, mesh);
  84078. this._LODLevels.push(level);
  84079. if (mesh) {
  84080. mesh._masterMesh = this;
  84081. }
  84082. this._sortLODLevels();
  84083. return this;
  84084. };
  84085. /**
  84086. * Returns the LOD level mesh at the passed distance or null if not found.
  84087. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84088. * @param distance The distance from the center of the object to show this level
  84089. * @returns a Mesh or `null`
  84090. */
  84091. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  84092. for (var index = 0; index < this._LODLevels.length; index++) {
  84093. var level = this._LODLevels[index];
  84094. if (level.distance === distance) {
  84095. return level.mesh;
  84096. }
  84097. }
  84098. return null;
  84099. };
  84100. /**
  84101. * Remove a mesh from the LOD array
  84102. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84103. * @param mesh defines the mesh to be removed
  84104. * @return This mesh (for chaining)
  84105. */
  84106. Mesh.prototype.removeLODLevel = function (mesh) {
  84107. for (var index = 0; index < this._LODLevels.length; index++) {
  84108. if (this._LODLevels[index].mesh === mesh) {
  84109. this._LODLevels.splice(index, 1);
  84110. if (mesh) {
  84111. mesh._masterMesh = null;
  84112. }
  84113. }
  84114. }
  84115. this._sortLODLevels();
  84116. return this;
  84117. };
  84118. /**
  84119. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  84120. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84121. * @param camera defines the camera to use to compute distance
  84122. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  84123. * @return This mesh (for chaining)
  84124. */
  84125. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  84126. if (!this._LODLevels || this._LODLevels.length === 0) {
  84127. return this;
  84128. }
  84129. var bSphere;
  84130. if (boundingSphere) {
  84131. bSphere = boundingSphere;
  84132. }
  84133. else {
  84134. var boundingInfo = this.getBoundingInfo();
  84135. bSphere = boundingInfo.boundingSphere;
  84136. }
  84137. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  84138. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  84139. if (this.onLODLevelSelection) {
  84140. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  84141. }
  84142. return this;
  84143. }
  84144. for (var index = 0; index < this._LODLevels.length; index++) {
  84145. var level = this._LODLevels[index];
  84146. if (level.distance < distanceToCamera) {
  84147. if (level.mesh) {
  84148. level.mesh._preActivate();
  84149. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  84150. }
  84151. if (this.onLODLevelSelection) {
  84152. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  84153. }
  84154. return level.mesh;
  84155. }
  84156. }
  84157. if (this.onLODLevelSelection) {
  84158. this.onLODLevelSelection(distanceToCamera, this, this);
  84159. }
  84160. return this;
  84161. };
  84162. Object.defineProperty(Mesh.prototype, "geometry", {
  84163. /**
  84164. * Gets the mesh internal Geometry object
  84165. */
  84166. get: function () {
  84167. return this._geometry;
  84168. },
  84169. enumerable: true,
  84170. configurable: true
  84171. });
  84172. /**
  84173. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  84174. * @returns the total number of vertices
  84175. */
  84176. Mesh.prototype.getTotalVertices = function () {
  84177. if (this._geometry === null || this._geometry === undefined) {
  84178. return 0;
  84179. }
  84180. return this._geometry.getTotalVertices();
  84181. };
  84182. /**
  84183. * Returns the content of an associated vertex buffer
  84184. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84185. * - VertexBuffer.PositionKind
  84186. * - VertexBuffer.UVKind
  84187. * - VertexBuffer.UV2Kind
  84188. * - VertexBuffer.UV3Kind
  84189. * - VertexBuffer.UV4Kind
  84190. * - VertexBuffer.UV5Kind
  84191. * - VertexBuffer.UV6Kind
  84192. * - VertexBuffer.ColorKind
  84193. * - VertexBuffer.MatricesIndicesKind
  84194. * - VertexBuffer.MatricesIndicesExtraKind
  84195. * - VertexBuffer.MatricesWeightsKind
  84196. * - VertexBuffer.MatricesWeightsExtraKind
  84197. * @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
  84198. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  84199. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  84200. */
  84201. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  84202. if (!this._geometry) {
  84203. return null;
  84204. }
  84205. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  84206. };
  84207. /**
  84208. * Returns the mesh VertexBuffer object from the requested `kind`
  84209. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84210. * - VertexBuffer.PositionKind
  84211. * - VertexBuffer.UVKind
  84212. * - VertexBuffer.UV2Kind
  84213. * - VertexBuffer.UV3Kind
  84214. * - VertexBuffer.UV4Kind
  84215. * - VertexBuffer.UV5Kind
  84216. * - VertexBuffer.UV6Kind
  84217. * - VertexBuffer.ColorKind
  84218. * - VertexBuffer.MatricesIndicesKind
  84219. * - VertexBuffer.MatricesIndicesExtraKind
  84220. * - VertexBuffer.MatricesWeightsKind
  84221. * - VertexBuffer.MatricesWeightsExtraKind
  84222. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  84223. */
  84224. Mesh.prototype.getVertexBuffer = function (kind) {
  84225. if (!this._geometry) {
  84226. return null;
  84227. }
  84228. return this._geometry.getVertexBuffer(kind);
  84229. };
  84230. /**
  84231. * Tests if a specific vertex buffer is associated with this mesh
  84232. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84233. * - VertexBuffer.PositionKind
  84234. * - VertexBuffer.UVKind
  84235. * - VertexBuffer.UV2Kind
  84236. * - VertexBuffer.UV3Kind
  84237. * - VertexBuffer.UV4Kind
  84238. * - VertexBuffer.UV5Kind
  84239. * - VertexBuffer.UV6Kind
  84240. * - VertexBuffer.ColorKind
  84241. * - VertexBuffer.MatricesIndicesKind
  84242. * - VertexBuffer.MatricesIndicesExtraKind
  84243. * - VertexBuffer.MatricesWeightsKind
  84244. * - VertexBuffer.MatricesWeightsExtraKind
  84245. * @returns a boolean
  84246. */
  84247. Mesh.prototype.isVerticesDataPresent = function (kind) {
  84248. if (!this._geometry) {
  84249. if (this._delayInfo) {
  84250. return this._delayInfo.indexOf(kind) !== -1;
  84251. }
  84252. return false;
  84253. }
  84254. return this._geometry.isVerticesDataPresent(kind);
  84255. };
  84256. /**
  84257. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  84258. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84259. * - VertexBuffer.PositionKind
  84260. * - VertexBuffer.UVKind
  84261. * - VertexBuffer.UV2Kind
  84262. * - VertexBuffer.UV3Kind
  84263. * - VertexBuffer.UV4Kind
  84264. * - VertexBuffer.UV5Kind
  84265. * - VertexBuffer.UV6Kind
  84266. * - VertexBuffer.ColorKind
  84267. * - VertexBuffer.MatricesIndicesKind
  84268. * - VertexBuffer.MatricesIndicesExtraKind
  84269. * - VertexBuffer.MatricesWeightsKind
  84270. * - VertexBuffer.MatricesWeightsExtraKind
  84271. * @returns a boolean
  84272. */
  84273. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  84274. if (!this._geometry) {
  84275. if (this._delayInfo) {
  84276. return this._delayInfo.indexOf(kind) !== -1;
  84277. }
  84278. return false;
  84279. }
  84280. return this._geometry.isVertexBufferUpdatable(kind);
  84281. };
  84282. /**
  84283. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  84284. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84285. * - VertexBuffer.PositionKind
  84286. * - VertexBuffer.UVKind
  84287. * - VertexBuffer.UV2Kind
  84288. * - VertexBuffer.UV3Kind
  84289. * - VertexBuffer.UV4Kind
  84290. * - VertexBuffer.UV5Kind
  84291. * - VertexBuffer.UV6Kind
  84292. * - VertexBuffer.ColorKind
  84293. * - VertexBuffer.MatricesIndicesKind
  84294. * - VertexBuffer.MatricesIndicesExtraKind
  84295. * - VertexBuffer.MatricesWeightsKind
  84296. * - VertexBuffer.MatricesWeightsExtraKind
  84297. * @returns an array of strings
  84298. */
  84299. Mesh.prototype.getVerticesDataKinds = function () {
  84300. if (!this._geometry) {
  84301. var result = new Array();
  84302. if (this._delayInfo) {
  84303. this._delayInfo.forEach(function (kind) {
  84304. result.push(kind);
  84305. });
  84306. }
  84307. return result;
  84308. }
  84309. return this._geometry.getVerticesDataKinds();
  84310. };
  84311. /**
  84312. * Returns a positive integer : the total number of indices in this mesh geometry.
  84313. * @returns the numner of indices or zero if the mesh has no geometry.
  84314. */
  84315. Mesh.prototype.getTotalIndices = function () {
  84316. if (!this._geometry) {
  84317. return 0;
  84318. }
  84319. return this._geometry.getTotalIndices();
  84320. };
  84321. /**
  84322. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84323. * @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.
  84324. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84325. * @returns the indices array or an empty array if the mesh has no geometry
  84326. */
  84327. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84328. if (!this._geometry) {
  84329. return [];
  84330. }
  84331. return this._geometry.getIndices(copyWhenShared, forceCopy);
  84332. };
  84333. Object.defineProperty(Mesh.prototype, "isBlocked", {
  84334. get: function () {
  84335. return this._masterMesh !== null && this._masterMesh !== undefined;
  84336. },
  84337. enumerable: true,
  84338. configurable: true
  84339. });
  84340. /**
  84341. * Determine if the current mesh is ready to be rendered
  84342. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84343. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  84344. * @returns true if all associated assets are ready (material, textures, shaders)
  84345. */
  84346. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  84347. if (completeCheck === void 0) { completeCheck = false; }
  84348. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  84349. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  84350. return false;
  84351. }
  84352. if (!_super.prototype.isReady.call(this, completeCheck)) {
  84353. return false;
  84354. }
  84355. if (!this.subMeshes || this.subMeshes.length === 0) {
  84356. return true;
  84357. }
  84358. if (!completeCheck) {
  84359. return true;
  84360. }
  84361. var engine = this.getEngine();
  84362. var scene = this.getScene();
  84363. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  84364. this.computeWorldMatrix();
  84365. var mat = this.material || scene.defaultMaterial;
  84366. if (mat) {
  84367. if (mat._storeEffectOnSubMeshes) {
  84368. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84369. var subMesh = _a[_i];
  84370. var effectiveMaterial = subMesh.getMaterial();
  84371. if (effectiveMaterial) {
  84372. if (effectiveMaterial._storeEffectOnSubMeshes) {
  84373. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84374. return false;
  84375. }
  84376. }
  84377. else {
  84378. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84379. return false;
  84380. }
  84381. }
  84382. }
  84383. }
  84384. }
  84385. else {
  84386. if (!mat.isReady(this, hardwareInstancedRendering)) {
  84387. return false;
  84388. }
  84389. }
  84390. }
  84391. // Shadows
  84392. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  84393. var light = _c[_b];
  84394. var generator = light.getShadowGenerator();
  84395. if (generator) {
  84396. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  84397. var subMesh = _e[_d];
  84398. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  84399. return false;
  84400. }
  84401. }
  84402. }
  84403. }
  84404. // LOD
  84405. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  84406. var lod = _g[_f];
  84407. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  84408. return false;
  84409. }
  84410. }
  84411. return true;
  84412. };
  84413. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  84414. /**
  84415. * 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.
  84416. */
  84417. get: function () {
  84418. return this._areNormalsFrozen;
  84419. },
  84420. enumerable: true,
  84421. configurable: true
  84422. });
  84423. /**
  84424. * 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.
  84425. * @returns the current mesh
  84426. */
  84427. Mesh.prototype.freezeNormals = function () {
  84428. this._areNormalsFrozen = true;
  84429. return this;
  84430. };
  84431. /**
  84432. * 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
  84433. * @returns the current mesh
  84434. */
  84435. Mesh.prototype.unfreezeNormals = function () {
  84436. this._areNormalsFrozen = false;
  84437. return this;
  84438. };
  84439. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  84440. /**
  84441. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  84442. */
  84443. set: function (count) {
  84444. this._instanceDataStorage.overridenInstanceCount = count;
  84445. },
  84446. enumerable: true,
  84447. configurable: true
  84448. });
  84449. // Methods
  84450. /** @hidden */
  84451. Mesh.prototype._preActivate = function () {
  84452. var sceneRenderId = this.getScene().getRenderId();
  84453. if (this._preActivateId === sceneRenderId) {
  84454. return this;
  84455. }
  84456. this._preActivateId = sceneRenderId;
  84457. this._instanceDataStorage.visibleInstances = null;
  84458. return this;
  84459. };
  84460. /** @hidden */
  84461. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  84462. if (this._instanceDataStorage.visibleInstances) {
  84463. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  84464. }
  84465. return this;
  84466. };
  84467. /** @hidden */
  84468. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  84469. if (!this._instanceDataStorage.visibleInstances) {
  84470. this._instanceDataStorage.visibleInstances = {
  84471. defaultRenderId: renderId,
  84472. selfDefaultRenderId: this._renderId
  84473. };
  84474. }
  84475. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  84476. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  84477. }
  84478. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  84479. return this;
  84480. };
  84481. /**
  84482. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84483. * This means the mesh underlying bounding box and sphere are recomputed.
  84484. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84485. * @returns the current mesh
  84486. */
  84487. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  84488. if (applySkeleton === void 0) { applySkeleton = false; }
  84489. if (this._boundingInfo && this._boundingInfo.isLocked) {
  84490. return this;
  84491. }
  84492. var bias = this.geometry ? this.geometry.boundingBias : null;
  84493. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  84494. return this;
  84495. };
  84496. /** @hidden */
  84497. Mesh.prototype._createGlobalSubMesh = function (force) {
  84498. var totalVertices = this.getTotalVertices();
  84499. if (!totalVertices || !this.getIndices()) {
  84500. return null;
  84501. }
  84502. // Check if we need to recreate the submeshes
  84503. if (this.subMeshes && this.subMeshes.length > 0) {
  84504. var ib = this.getIndices();
  84505. if (!ib) {
  84506. return null;
  84507. }
  84508. var totalIndices = ib.length;
  84509. var needToRecreate = false;
  84510. if (force) {
  84511. needToRecreate = true;
  84512. }
  84513. else {
  84514. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84515. var submesh = _a[_i];
  84516. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  84517. needToRecreate = true;
  84518. break;
  84519. }
  84520. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  84521. needToRecreate = true;
  84522. break;
  84523. }
  84524. }
  84525. }
  84526. if (!needToRecreate) {
  84527. return this.subMeshes[0];
  84528. }
  84529. }
  84530. this.releaseSubMeshes();
  84531. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  84532. };
  84533. /**
  84534. * This function will subdivide the mesh into multiple submeshes
  84535. * @param count defines the expected number of submeshes
  84536. */
  84537. Mesh.prototype.subdivide = function (count) {
  84538. if (count < 1) {
  84539. return;
  84540. }
  84541. var totalIndices = this.getTotalIndices();
  84542. var subdivisionSize = (totalIndices / count) | 0;
  84543. var offset = 0;
  84544. // Ensure that subdivisionSize is a multiple of 3
  84545. while (subdivisionSize % 3 !== 0) {
  84546. subdivisionSize++;
  84547. }
  84548. this.releaseSubMeshes();
  84549. for (var index = 0; index < count; index++) {
  84550. if (offset >= totalIndices) {
  84551. break;
  84552. }
  84553. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  84554. offset += subdivisionSize;
  84555. }
  84556. this.synchronizeInstances();
  84557. };
  84558. /**
  84559. * Copy a FloatArray into a specific associated vertex buffer
  84560. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84561. * - VertexBuffer.PositionKind
  84562. * - VertexBuffer.UVKind
  84563. * - VertexBuffer.UV2Kind
  84564. * - VertexBuffer.UV3Kind
  84565. * - VertexBuffer.UV4Kind
  84566. * - VertexBuffer.UV5Kind
  84567. * - VertexBuffer.UV6Kind
  84568. * - VertexBuffer.ColorKind
  84569. * - VertexBuffer.MatricesIndicesKind
  84570. * - VertexBuffer.MatricesIndicesExtraKind
  84571. * - VertexBuffer.MatricesWeightsKind
  84572. * - VertexBuffer.MatricesWeightsExtraKind
  84573. * @param data defines the data source
  84574. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84575. * @param stride defines the data stride size (can be null)
  84576. * @returns the current mesh
  84577. */
  84578. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84579. if (updatable === void 0) { updatable = false; }
  84580. if (!this._geometry) {
  84581. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84582. vertexData.set(data, kind);
  84583. var scene = this.getScene();
  84584. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84585. }
  84586. else {
  84587. this._geometry.setVerticesData(kind, data, updatable, stride);
  84588. }
  84589. return this;
  84590. };
  84591. /**
  84592. * Flags an associated vertex buffer as updatable
  84593. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  84594. * - VertexBuffer.PositionKind
  84595. * - VertexBuffer.UVKind
  84596. * - VertexBuffer.UV2Kind
  84597. * - VertexBuffer.UV3Kind
  84598. * - VertexBuffer.UV4Kind
  84599. * - VertexBuffer.UV5Kind
  84600. * - VertexBuffer.UV6Kind
  84601. * - VertexBuffer.ColorKind
  84602. * - VertexBuffer.MatricesIndicesKind
  84603. * - VertexBuffer.MatricesIndicesExtraKind
  84604. * - VertexBuffer.MatricesWeightsKind
  84605. * - VertexBuffer.MatricesWeightsExtraKind
  84606. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84607. */
  84608. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  84609. if (updatable === void 0) { updatable = true; }
  84610. var vb = this.getVertexBuffer(kind);
  84611. if (!vb || vb.isUpdatable() === updatable) {
  84612. return;
  84613. }
  84614. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  84615. };
  84616. /**
  84617. * Sets the mesh global Vertex Buffer
  84618. * @param buffer defines the buffer to use
  84619. * @returns the current mesh
  84620. */
  84621. Mesh.prototype.setVerticesBuffer = function (buffer) {
  84622. if (!this._geometry) {
  84623. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  84624. }
  84625. this._geometry.setVerticesBuffer(buffer);
  84626. return this;
  84627. };
  84628. /**
  84629. * Update a specific associated vertex buffer
  84630. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84631. * - VertexBuffer.PositionKind
  84632. * - VertexBuffer.UVKind
  84633. * - VertexBuffer.UV2Kind
  84634. * - VertexBuffer.UV3Kind
  84635. * - VertexBuffer.UV4Kind
  84636. * - VertexBuffer.UV5Kind
  84637. * - VertexBuffer.UV6Kind
  84638. * - VertexBuffer.ColorKind
  84639. * - VertexBuffer.MatricesIndicesKind
  84640. * - VertexBuffer.MatricesIndicesExtraKind
  84641. * - VertexBuffer.MatricesWeightsKind
  84642. * - VertexBuffer.MatricesWeightsExtraKind
  84643. * @param data defines the data source
  84644. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84645. * @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)
  84646. * @returns the current mesh
  84647. */
  84648. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  84649. if (!this._geometry) {
  84650. return this;
  84651. }
  84652. if (!makeItUnique) {
  84653. this._geometry.updateVerticesData(kind, data, updateExtends);
  84654. }
  84655. else {
  84656. this.makeGeometryUnique();
  84657. this.updateVerticesData(kind, data, updateExtends, false);
  84658. }
  84659. return this;
  84660. };
  84661. /**
  84662. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  84663. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  84664. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  84665. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  84666. * @returns the current mesh
  84667. */
  84668. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  84669. if (computeNormals === void 0) { computeNormals = true; }
  84670. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84671. if (!positions) {
  84672. return this;
  84673. }
  84674. positionFunction(positions);
  84675. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  84676. if (computeNormals) {
  84677. var indices = this.getIndices();
  84678. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  84679. if (!normals) {
  84680. return this;
  84681. }
  84682. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  84683. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  84684. }
  84685. return this;
  84686. };
  84687. /**
  84688. * Creates a un-shared specific occurence of the geometry for the mesh.
  84689. * @returns the current mesh
  84690. */
  84691. Mesh.prototype.makeGeometryUnique = function () {
  84692. if (!this._geometry) {
  84693. return this;
  84694. }
  84695. var oldGeometry = this._geometry;
  84696. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  84697. oldGeometry.releaseForMesh(this, true);
  84698. geometry.applyToMesh(this);
  84699. return this;
  84700. };
  84701. /**
  84702. * Set the index buffer of this mesh
  84703. * @param indices defines the source data
  84704. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  84705. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  84706. * @returns the current mesh
  84707. */
  84708. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  84709. if (totalVertices === void 0) { totalVertices = null; }
  84710. if (updatable === void 0) { updatable = false; }
  84711. if (!this._geometry) {
  84712. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84713. vertexData.indices = indices;
  84714. var scene = this.getScene();
  84715. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84716. }
  84717. else {
  84718. this._geometry.setIndices(indices, totalVertices, updatable);
  84719. }
  84720. return this;
  84721. };
  84722. /**
  84723. * Update the current index buffer
  84724. * @param indices defines the source data
  84725. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84726. * @returns the current mesh
  84727. */
  84728. Mesh.prototype.updateIndices = function (indices, offset) {
  84729. if (!this._geometry) {
  84730. return this;
  84731. }
  84732. this._geometry.updateIndices(indices, offset);
  84733. return this;
  84734. };
  84735. /**
  84736. * Invert the geometry to move from a right handed system to a left handed one.
  84737. * @returns the current mesh
  84738. */
  84739. Mesh.prototype.toLeftHanded = function () {
  84740. if (!this._geometry) {
  84741. return this;
  84742. }
  84743. this._geometry.toLeftHanded();
  84744. return this;
  84745. };
  84746. /** @hidden */
  84747. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  84748. if (!this._geometry) {
  84749. return this;
  84750. }
  84751. var engine = this.getScene().getEngine();
  84752. // Wireframe
  84753. var indexToBind;
  84754. if (this._unIndexed) {
  84755. indexToBind = null;
  84756. }
  84757. else {
  84758. switch (fillMode) {
  84759. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  84760. indexToBind = null;
  84761. break;
  84762. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  84763. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  84764. break;
  84765. default:
  84766. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  84767. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  84768. break;
  84769. }
  84770. }
  84771. // VBOs
  84772. this._geometry._bind(effect, indexToBind);
  84773. return this;
  84774. };
  84775. /** @hidden */
  84776. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  84777. if (alternate === void 0) { alternate = false; }
  84778. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84779. return this;
  84780. }
  84781. if (this._onBeforeDrawObservable) {
  84782. this._onBeforeDrawObservable.notifyObservers(this);
  84783. }
  84784. var scene = this.getScene();
  84785. var engine = scene.getEngine();
  84786. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  84787. // or triangles as points
  84788. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  84789. }
  84790. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  84791. // Triangles as wireframe
  84792. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  84793. }
  84794. else {
  84795. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  84796. }
  84797. if (scene._isAlternateRenderingEnabled && !alternate) {
  84798. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  84799. if (!effect || !scene.activeCamera) {
  84800. return this;
  84801. }
  84802. scene._switchToAlternateCameraConfiguration(true);
  84803. this._effectiveMaterial.bindView(effect);
  84804. this._effectiveMaterial.bindViewProjection(effect);
  84805. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  84806. this._draw(subMesh, fillMode, instancesCount, true);
  84807. engine.setViewport(scene.activeCamera.viewport);
  84808. scene._switchToAlternateCameraConfiguration(false);
  84809. this._effectiveMaterial.bindView(effect);
  84810. this._effectiveMaterial.bindViewProjection(effect);
  84811. }
  84812. return this;
  84813. };
  84814. /**
  84815. * Registers for this mesh a javascript function called just before the rendering process
  84816. * @param func defines the function to call before rendering this mesh
  84817. * @returns the current mesh
  84818. */
  84819. Mesh.prototype.registerBeforeRender = function (func) {
  84820. this.onBeforeRenderObservable.add(func);
  84821. return this;
  84822. };
  84823. /**
  84824. * Disposes a previously registered javascript function called before the rendering
  84825. * @param func defines the function to remove
  84826. * @returns the current mesh
  84827. */
  84828. Mesh.prototype.unregisterBeforeRender = function (func) {
  84829. this.onBeforeRenderObservable.removeCallback(func);
  84830. return this;
  84831. };
  84832. /**
  84833. * Registers for this mesh a javascript function called just after the rendering is complete
  84834. * @param func defines the function to call after rendering this mesh
  84835. * @returns the current mesh
  84836. */
  84837. Mesh.prototype.registerAfterRender = function (func) {
  84838. this.onAfterRenderObservable.add(func);
  84839. return this;
  84840. };
  84841. /**
  84842. * Disposes a previously registered javascript function called after the rendering.
  84843. * @param func defines the function to remove
  84844. * @returns the current mesh
  84845. */
  84846. Mesh.prototype.unregisterAfterRender = function (func) {
  84847. this.onAfterRenderObservable.removeCallback(func);
  84848. return this;
  84849. };
  84850. /** @hidden */
  84851. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  84852. var scene = this.getScene();
  84853. var batchCache = this._instanceDataStorage.batchCache;
  84854. batchCache.mustReturn = false;
  84855. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  84856. batchCache.visibleInstances[subMeshId] = null;
  84857. if (this._instanceDataStorage.visibleInstances) {
  84858. var visibleInstances = this._instanceDataStorage.visibleInstances;
  84859. var currentRenderId = scene.getRenderId();
  84860. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  84861. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  84862. var selfRenderId = this._renderId;
  84863. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  84864. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  84865. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  84866. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  84867. }
  84868. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  84869. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  84870. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  84871. batchCache.mustReturn = true;
  84872. return batchCache;
  84873. }
  84874. if (currentRenderId !== selfRenderId) {
  84875. batchCache.renderSelf[subMeshId] = false;
  84876. }
  84877. }
  84878. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  84879. }
  84880. return batchCache;
  84881. };
  84882. /** @hidden */
  84883. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  84884. var visibleInstances = batch.visibleInstances[subMesh._id];
  84885. if (!visibleInstances) {
  84886. return this;
  84887. }
  84888. var matricesCount = visibleInstances.length + 1;
  84889. var bufferSize = matricesCount * 16 * 4;
  84890. var instanceStorage = this._instanceDataStorage;
  84891. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  84892. var instancesBuffer = instanceStorage.instancesBuffer;
  84893. while (instanceStorage.instancesBufferSize < bufferSize) {
  84894. instanceStorage.instancesBufferSize *= 2;
  84895. }
  84896. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84897. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  84898. }
  84899. var offset = 0;
  84900. var instancesCount = 0;
  84901. var world = this.getWorldMatrix();
  84902. if (batch.renderSelf[subMesh._id]) {
  84903. world.copyToArray(instanceStorage.instancesData, offset);
  84904. offset += 16;
  84905. instancesCount++;
  84906. }
  84907. if (visibleInstances) {
  84908. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  84909. var instance = visibleInstances[instanceIndex];
  84910. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  84911. offset += 16;
  84912. instancesCount++;
  84913. }
  84914. }
  84915. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84916. if (instancesBuffer) {
  84917. instancesBuffer.dispose();
  84918. }
  84919. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  84920. instanceStorage.instancesBuffer = instancesBuffer;
  84921. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  84922. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  84923. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  84924. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  84925. }
  84926. else {
  84927. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  84928. }
  84929. this._bind(subMesh, effect, fillMode);
  84930. this._draw(subMesh, fillMode, instancesCount);
  84931. engine.unbindInstanceAttributes();
  84932. return this;
  84933. };
  84934. /** @hidden */
  84935. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  84936. var scene = this.getScene();
  84937. var engine = scene.getEngine();
  84938. if (hardwareInstancedRendering) {
  84939. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  84940. }
  84941. else {
  84942. if (batch.renderSelf[subMesh._id]) {
  84943. // Draw
  84944. if (onBeforeDraw) {
  84945. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  84946. }
  84947. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  84948. }
  84949. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  84950. if (visibleInstancesForSubMesh) {
  84951. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  84952. var instance = visibleInstancesForSubMesh[instanceIndex];
  84953. // World
  84954. var world = instance.getWorldMatrix();
  84955. if (onBeforeDraw) {
  84956. onBeforeDraw(true, world, effectiveMaterial);
  84957. }
  84958. // Draw
  84959. this._draw(subMesh, fillMode);
  84960. }
  84961. }
  84962. }
  84963. return this;
  84964. };
  84965. /**
  84966. * 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
  84967. * @param subMesh defines the subMesh to render
  84968. * @param enableAlphaMode defines if alpha mode can be changed
  84969. * @returns the current mesh
  84970. */
  84971. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  84972. if (this._checkOcclusionQuery()) {
  84973. return this;
  84974. }
  84975. var scene = this.getScene();
  84976. // Managing instances
  84977. var batch = this._getInstancesRenderList(subMesh._id);
  84978. if (batch.mustReturn) {
  84979. return this;
  84980. }
  84981. // Checking geometry state
  84982. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84983. return this;
  84984. }
  84985. if (this._onBeforeRenderObservable) {
  84986. this._onBeforeRenderObservable.notifyObservers(this);
  84987. }
  84988. var engine = scene.getEngine();
  84989. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  84990. // Material
  84991. var material = subMesh.getMaterial();
  84992. if (!material) {
  84993. return this;
  84994. }
  84995. this._effectiveMaterial = material;
  84996. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84997. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84998. return this;
  84999. }
  85000. }
  85001. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  85002. return this;
  85003. }
  85004. // Alpha mode
  85005. if (enableAlphaMode) {
  85006. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  85007. }
  85008. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  85009. var step = _a[_i];
  85010. step.action(this, subMesh, batch);
  85011. }
  85012. var effect;
  85013. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85014. effect = subMesh.effect;
  85015. }
  85016. else {
  85017. effect = this._effectiveMaterial.getEffect();
  85018. }
  85019. if (!effect) {
  85020. return this;
  85021. }
  85022. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  85023. var sideOrientation = this.overrideMaterialSideOrientation;
  85024. if (sideOrientation == null) {
  85025. sideOrientation = this._effectiveMaterial.sideOrientation;
  85026. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  85027. 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);
  85028. }
  85029. }
  85030. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  85031. if (this._effectiveMaterial.forceDepthWrite) {
  85032. engine.setDepthWrite(true);
  85033. }
  85034. // Bind
  85035. 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);
  85036. if (this._onBeforeBindObservable) {
  85037. this._onBeforeBindObservable.notifyObservers(this);
  85038. }
  85039. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  85040. this._bind(subMesh, effect, fillMode);
  85041. }
  85042. var world = effectiveMesh.getWorldMatrix();
  85043. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85044. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  85045. }
  85046. else {
  85047. this._effectiveMaterial.bind(world, this);
  85048. }
  85049. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  85050. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  85051. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  85052. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  85053. }
  85054. // Draw
  85055. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  85056. // Unbind
  85057. this._effectiveMaterial.unbind();
  85058. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  85059. var step = _c[_b];
  85060. step.action(this, subMesh, batch);
  85061. }
  85062. if (this._onAfterRenderObservable) {
  85063. this._onAfterRenderObservable.notifyObservers(this);
  85064. }
  85065. return this;
  85066. };
  85067. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  85068. if (isInstance && effectiveMaterial) {
  85069. effectiveMaterial.bindOnlyWorldMatrix(world);
  85070. }
  85071. };
  85072. /**
  85073. * Renormalize the mesh and patch it up if there are no weights
  85074. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  85075. * However in the case of zero weights then we set just a single influence to 1.
  85076. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  85077. */
  85078. Mesh.prototype.cleanMatrixWeights = function () {
  85079. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  85080. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  85081. this.normalizeSkinWeightsAndExtra();
  85082. }
  85083. else {
  85084. this.normalizeSkinFourWeights();
  85085. }
  85086. }
  85087. };
  85088. // faster 4 weight version.
  85089. Mesh.prototype.normalizeSkinFourWeights = function () {
  85090. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85091. var numWeights = matricesWeights.length;
  85092. for (var a = 0; a < numWeights; a += 4) {
  85093. // accumulate weights
  85094. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  85095. // check for invalid weight and just set it to 1.
  85096. if (t === 0) {
  85097. matricesWeights[a] = 1;
  85098. }
  85099. else {
  85100. // renormalize so everything adds to 1 use reciprical
  85101. var recip = 1 / t;
  85102. matricesWeights[a] *= recip;
  85103. matricesWeights[a + 1] *= recip;
  85104. matricesWeights[a + 2] *= recip;
  85105. matricesWeights[a + 3] *= recip;
  85106. }
  85107. }
  85108. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85109. };
  85110. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  85111. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  85112. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85113. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85114. var numWeights = matricesWeights.length;
  85115. for (var a = 0; a < numWeights; a += 4) {
  85116. // accumulate weights
  85117. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  85118. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  85119. // check for invalid weight and just set it to 1.
  85120. if (t === 0) {
  85121. matricesWeights[a] = 1;
  85122. }
  85123. else {
  85124. // renormalize so everything adds to 1 use reciprical
  85125. var recip = 1 / t;
  85126. matricesWeights[a] *= recip;
  85127. matricesWeights[a + 1] *= recip;
  85128. matricesWeights[a + 2] *= recip;
  85129. matricesWeights[a + 3] *= recip;
  85130. // same goes for extras
  85131. matricesWeightsExtra[a] *= recip;
  85132. matricesWeightsExtra[a + 1] *= recip;
  85133. matricesWeightsExtra[a + 2] *= recip;
  85134. matricesWeightsExtra[a + 3] *= recip;
  85135. }
  85136. }
  85137. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85138. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  85139. };
  85140. /**
  85141. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  85142. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  85143. * the user know there was an issue with importing the mesh
  85144. * @returns a validation object with skinned, valid and report string
  85145. */
  85146. Mesh.prototype.validateSkinning = function () {
  85147. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85148. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85149. if (matricesWeights === null || this.skeleton == null) {
  85150. return { skinned: false, valid: true, report: "not skinned" };
  85151. }
  85152. var numWeights = matricesWeights.length;
  85153. var numberNotSorted = 0;
  85154. var missingWeights = 0;
  85155. var maxUsedWeights = 0;
  85156. var numberNotNormalized = 0;
  85157. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  85158. var usedWeightCounts = new Array();
  85159. for (var a = 0; a <= numInfluences; a++) {
  85160. usedWeightCounts[a] = 0;
  85161. }
  85162. var toleranceEpsilon = 0.001;
  85163. for (var a = 0; a < numWeights; a += 4) {
  85164. var lastWeight = matricesWeights[a];
  85165. var t = lastWeight;
  85166. var usedWeights = t === 0 ? 0 : 1;
  85167. for (var b = 1; b < numInfluences; b++) {
  85168. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  85169. if (d > lastWeight) {
  85170. numberNotSorted++;
  85171. }
  85172. if (d !== 0) {
  85173. usedWeights++;
  85174. }
  85175. t += d;
  85176. lastWeight = d;
  85177. }
  85178. // count the buffer weights usage
  85179. usedWeightCounts[usedWeights]++;
  85180. // max influences
  85181. if (usedWeights > maxUsedWeights) {
  85182. maxUsedWeights = usedWeights;
  85183. }
  85184. // check for invalid weight and just set it to 1.
  85185. if (t === 0) {
  85186. missingWeights++;
  85187. }
  85188. else {
  85189. // renormalize so everything adds to 1 use reciprical
  85190. var recip = 1 / t;
  85191. var tolerance = 0;
  85192. for (b = 0; b < numInfluences; b++) {
  85193. if (b < 4) {
  85194. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  85195. }
  85196. else {
  85197. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  85198. }
  85199. }
  85200. // arbitary epsilon value for dicdating not normalized
  85201. if (tolerance > toleranceEpsilon) {
  85202. numberNotNormalized++;
  85203. }
  85204. }
  85205. }
  85206. // validate bone indices are in range of the skeleton
  85207. var numBones = this.skeleton.bones.length;
  85208. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  85209. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  85210. var numBadBoneIndices = 0;
  85211. for (var a = 0; a < numWeights; a++) {
  85212. for (var b = 0; b < numInfluences; b++) {
  85213. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  85214. if (index >= numBones || index < 0) {
  85215. numBadBoneIndices++;
  85216. }
  85217. }
  85218. }
  85219. // log mesh stats
  85220. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  85221. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  85222. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  85223. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  85224. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  85225. };
  85226. /** @hidden */
  85227. Mesh.prototype._checkDelayState = function () {
  85228. var scene = this.getScene();
  85229. if (this._geometry) {
  85230. this._geometry.load(scene);
  85231. }
  85232. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  85233. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  85234. this._queueLoad(scene);
  85235. }
  85236. return this;
  85237. };
  85238. Mesh.prototype._queueLoad = function (scene) {
  85239. var _this = this;
  85240. scene._addPendingData(this);
  85241. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  85242. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  85243. if (data instanceof ArrayBuffer) {
  85244. _this._delayLoadingFunction(data, _this);
  85245. }
  85246. else {
  85247. _this._delayLoadingFunction(JSON.parse(data), _this);
  85248. }
  85249. _this.instances.forEach(function (instance) {
  85250. instance._syncSubMeshes();
  85251. });
  85252. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  85253. scene._removePendingData(_this);
  85254. }, function () { }, scene.offlineProvider, getBinaryData);
  85255. return this;
  85256. };
  85257. /**
  85258. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  85259. * A mesh is in the frustum if its bounding box intersects the frustum
  85260. * @param frustumPlanes defines the frustum to test
  85261. * @returns true if the mesh is in the frustum planes
  85262. */
  85263. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  85264. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  85265. return false;
  85266. }
  85267. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  85268. return false;
  85269. }
  85270. this._checkDelayState();
  85271. return true;
  85272. };
  85273. /**
  85274. * Sets the mesh material by the material or multiMaterial `id` property
  85275. * @param id is a string identifying the material or the multiMaterial
  85276. * @returns the current mesh
  85277. */
  85278. Mesh.prototype.setMaterialByID = function (id) {
  85279. var materials = this.getScene().materials;
  85280. var index;
  85281. for (index = materials.length - 1; index > -1; index--) {
  85282. if (materials[index].id === id) {
  85283. this.material = materials[index];
  85284. return this;
  85285. }
  85286. }
  85287. // Multi
  85288. var multiMaterials = this.getScene().multiMaterials;
  85289. for (index = multiMaterials.length - 1; index > -1; index--) {
  85290. if (multiMaterials[index].id === id) {
  85291. this.material = multiMaterials[index];
  85292. return this;
  85293. }
  85294. }
  85295. return this;
  85296. };
  85297. /**
  85298. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  85299. * @returns an array of IAnimatable
  85300. */
  85301. Mesh.prototype.getAnimatables = function () {
  85302. var results = new Array();
  85303. if (this.material) {
  85304. results.push(this.material);
  85305. }
  85306. if (this.skeleton) {
  85307. results.push(this.skeleton);
  85308. }
  85309. return results;
  85310. };
  85311. /**
  85312. * Modifies the mesh geometry according to the passed transformation matrix.
  85313. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  85314. * The mesh normals are modified using the same transformation.
  85315. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85316. * @param transform defines the transform matrix to use
  85317. * @see http://doc.babylonjs.com/resources/baking_transformations
  85318. * @returns the current mesh
  85319. */
  85320. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  85321. // Position
  85322. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  85323. return this;
  85324. }
  85325. var submeshes = this.subMeshes.splice(0);
  85326. this._resetPointsArrayCache();
  85327. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85328. var temp = new Array();
  85329. var index;
  85330. for (index = 0; index < data.length; index += 3) {
  85331. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  85332. }
  85333. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  85334. // Normals
  85335. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  85336. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85337. temp = [];
  85338. for (index = 0; index < data.length; index += 3) {
  85339. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  85340. }
  85341. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  85342. }
  85343. // flip faces?
  85344. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  85345. this.flipFaces();
  85346. }
  85347. // Restore submeshes
  85348. this.releaseSubMeshes();
  85349. this.subMeshes = submeshes;
  85350. return this;
  85351. };
  85352. /**
  85353. * Modifies the mesh geometry according to its own current World Matrix.
  85354. * The mesh World Matrix is then reset.
  85355. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  85356. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85357. * @see http://doc.babylonjs.com/resources/baking_transformations
  85358. * @returns the current mesh
  85359. */
  85360. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  85361. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  85362. this.scaling.copyFromFloats(1, 1, 1);
  85363. this.position.copyFromFloats(0, 0, 0);
  85364. this.rotation.copyFromFloats(0, 0, 0);
  85365. //only if quaternion is already set
  85366. if (this.rotationQuaternion) {
  85367. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  85368. }
  85369. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  85370. return this;
  85371. };
  85372. Object.defineProperty(Mesh.prototype, "_positions", {
  85373. // Cache
  85374. /** @hidden */
  85375. get: function () {
  85376. if (this._geometry) {
  85377. return this._geometry._positions;
  85378. }
  85379. return null;
  85380. },
  85381. enumerable: true,
  85382. configurable: true
  85383. });
  85384. /** @hidden */
  85385. Mesh.prototype._resetPointsArrayCache = function () {
  85386. if (this._geometry) {
  85387. this._geometry._resetPointsArrayCache();
  85388. }
  85389. return this;
  85390. };
  85391. /** @hidden */
  85392. Mesh.prototype._generatePointsArray = function () {
  85393. if (this._geometry) {
  85394. return this._geometry._generatePointsArray();
  85395. }
  85396. return false;
  85397. };
  85398. /**
  85399. * Returns a new Mesh object generated from the current mesh properties.
  85400. * This method must not get confused with createInstance()
  85401. * @param name is a string, the name given to the new mesh
  85402. * @param newParent can be any Node object (default `null`)
  85403. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  85404. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  85405. * @returns a new mesh
  85406. */
  85407. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  85408. if (name === void 0) { name = ""; }
  85409. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85410. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  85411. };
  85412. /**
  85413. * Releases resources associated with this mesh.
  85414. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85415. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85416. */
  85417. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85418. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85419. this.morphTargetManager = null;
  85420. if (this._geometry) {
  85421. this._geometry.releaseForMesh(this, true);
  85422. }
  85423. if (this._onBeforeDrawObservable) {
  85424. this._onBeforeDrawObservable.clear();
  85425. }
  85426. if (this._onBeforeBindObservable) {
  85427. this._onBeforeBindObservable.clear();
  85428. }
  85429. if (this._onBeforeRenderObservable) {
  85430. this._onBeforeRenderObservable.clear();
  85431. }
  85432. if (this._onAfterRenderObservable) {
  85433. this._onAfterRenderObservable.clear();
  85434. }
  85435. // Sources
  85436. if (this._scene.useClonedMeshhMap) {
  85437. if (this.meshMap) {
  85438. for (var uniqueId in this.meshMap) {
  85439. var mesh = this.meshMap[uniqueId];
  85440. if (mesh) {
  85441. mesh._source = null;
  85442. this.meshMap[uniqueId] = undefined;
  85443. }
  85444. }
  85445. }
  85446. if (this._source && this._source.meshMap) {
  85447. this._source.meshMap[this.uniqueId] = undefined;
  85448. }
  85449. }
  85450. else {
  85451. var meshes = this.getScene().meshes;
  85452. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85453. var abstractMesh = meshes_1[_i];
  85454. var mesh = abstractMesh;
  85455. if (mesh._source && mesh._source === this) {
  85456. mesh._source = null;
  85457. }
  85458. }
  85459. }
  85460. this._source = null;
  85461. // Instances
  85462. if (this._instanceDataStorage.instancesBuffer) {
  85463. this._instanceDataStorage.instancesBuffer.dispose();
  85464. this._instanceDataStorage.instancesBuffer = null;
  85465. }
  85466. while (this.instances.length) {
  85467. this.instances[0].dispose();
  85468. }
  85469. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85470. };
  85471. /**
  85472. * Modifies the mesh geometry according to a displacement map.
  85473. * 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.
  85474. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85475. * @param url is a string, the URL from the image file is to be downloaded.
  85476. * @param minHeight is the lower limit of the displacement.
  85477. * @param maxHeight is the upper limit of the displacement.
  85478. * @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.
  85479. * @param uvOffset is an optional vector2 used to offset UV.
  85480. * @param uvScale is an optional vector2 used to scale UV.
  85481. * @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.
  85482. * @returns the Mesh.
  85483. */
  85484. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  85485. var _this = this;
  85486. if (forceUpdate === void 0) { forceUpdate = false; }
  85487. var scene = this.getScene();
  85488. var onload = function (img) {
  85489. // Getting height map data
  85490. var canvas = document.createElement("canvas");
  85491. var context = canvas.getContext("2d");
  85492. var heightMapWidth = img.width;
  85493. var heightMapHeight = img.height;
  85494. canvas.width = heightMapWidth;
  85495. canvas.height = heightMapHeight;
  85496. context.drawImage(img, 0, 0);
  85497. // Create VertexData from map data
  85498. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  85499. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  85500. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  85501. //execute success callback, if set
  85502. if (onSuccess) {
  85503. onSuccess(_this);
  85504. }
  85505. };
  85506. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  85507. return this;
  85508. };
  85509. /**
  85510. * Modifies the mesh geometry according to a displacementMap buffer.
  85511. * 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.
  85512. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85513. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  85514. * @param heightMapWidth is the width of the buffer image.
  85515. * @param heightMapHeight is the height of the buffer image.
  85516. * @param minHeight is the lower limit of the displacement.
  85517. * @param maxHeight is the upper limit of the displacement.
  85518. * @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.
  85519. * @param uvOffset is an optional vector2 used to offset UV.
  85520. * @param uvScale is an optional vector2 used to scale UV.
  85521. * @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.
  85522. * @returns the Mesh.
  85523. */
  85524. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  85525. if (forceUpdate === void 0) { forceUpdate = false; }
  85526. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  85527. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  85528. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  85529. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  85530. return this;
  85531. }
  85532. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  85533. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85534. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  85535. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85536. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85537. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85538. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85539. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  85540. for (var index = 0; index < positions.length; index += 3) {
  85541. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  85542. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  85543. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  85544. // Compute height
  85545. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  85546. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  85547. var pos = (u + v * heightMapWidth) * 4;
  85548. var r = buffer[pos] / 255.0;
  85549. var g = buffer[pos + 1] / 255.0;
  85550. var b = buffer[pos + 2] / 255.0;
  85551. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  85552. normal.normalize();
  85553. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  85554. position = position.add(normal);
  85555. position.toArray(positions, index);
  85556. }
  85557. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  85558. if (forceUpdate) {
  85559. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85560. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85561. }
  85562. else {
  85563. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85564. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85565. }
  85566. return this;
  85567. };
  85568. /**
  85569. * Modify the mesh to get a flat shading rendering.
  85570. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  85571. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  85572. * @returns current mesh
  85573. */
  85574. Mesh.prototype.convertToFlatShadedMesh = function () {
  85575. var kinds = this.getVerticesDataKinds();
  85576. var vbs = {};
  85577. var data = {};
  85578. var newdata = {};
  85579. var updatableNormals = false;
  85580. var kindIndex;
  85581. var kind;
  85582. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85583. kind = kinds[kindIndex];
  85584. var vertexBuffer = this.getVertexBuffer(kind);
  85585. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  85586. updatableNormals = vertexBuffer.isUpdatable();
  85587. kinds.splice(kindIndex, 1);
  85588. kindIndex--;
  85589. continue;
  85590. }
  85591. vbs[kind] = vertexBuffer;
  85592. data[kind] = vbs[kind].getData();
  85593. newdata[kind] = [];
  85594. }
  85595. // Save previous submeshes
  85596. var previousSubmeshes = this.subMeshes.slice(0);
  85597. var indices = this.getIndices();
  85598. var totalIndices = this.getTotalIndices();
  85599. // Generating unique vertices per face
  85600. var index;
  85601. for (index = 0; index < totalIndices; index++) {
  85602. var vertexIndex = indices[index];
  85603. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85604. kind = kinds[kindIndex];
  85605. var stride = vbs[kind].getStrideSize();
  85606. for (var offset = 0; offset < stride; offset++) {
  85607. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85608. }
  85609. }
  85610. }
  85611. // Updating faces & normal
  85612. var normals = [];
  85613. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  85614. for (index = 0; index < totalIndices; index += 3) {
  85615. indices[index] = index;
  85616. indices[index + 1] = index + 1;
  85617. indices[index + 2] = index + 2;
  85618. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  85619. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  85620. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  85621. var p1p2 = p1.subtract(p2);
  85622. var p3p2 = p3.subtract(p2);
  85623. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  85624. // Store same normals for every vertex
  85625. for (var localIndex = 0; localIndex < 3; localIndex++) {
  85626. normals.push(normal.x);
  85627. normals.push(normal.y);
  85628. normals.push(normal.z);
  85629. }
  85630. }
  85631. this.setIndices(indices);
  85632. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  85633. // Updating vertex buffers
  85634. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85635. kind = kinds[kindIndex];
  85636. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85637. }
  85638. // Updating submeshes
  85639. this.releaseSubMeshes();
  85640. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85641. var previousOne = previousSubmeshes[submeshIndex];
  85642. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85643. }
  85644. this.synchronizeInstances();
  85645. return this;
  85646. };
  85647. /**
  85648. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  85649. * In other words, more vertices, no more indices and a single bigger VBO.
  85650. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  85651. * @returns current mesh
  85652. */
  85653. Mesh.prototype.convertToUnIndexedMesh = function () {
  85654. var kinds = this.getVerticesDataKinds();
  85655. var vbs = {};
  85656. var data = {};
  85657. var newdata = {};
  85658. var kindIndex;
  85659. var kind;
  85660. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85661. kind = kinds[kindIndex];
  85662. var vertexBuffer = this.getVertexBuffer(kind);
  85663. vbs[kind] = vertexBuffer;
  85664. data[kind] = vbs[kind].getData();
  85665. newdata[kind] = [];
  85666. }
  85667. // Save previous submeshes
  85668. var previousSubmeshes = this.subMeshes.slice(0);
  85669. var indices = this.getIndices();
  85670. var totalIndices = this.getTotalIndices();
  85671. // Generating unique vertices per face
  85672. var index;
  85673. for (index = 0; index < totalIndices; index++) {
  85674. var vertexIndex = indices[index];
  85675. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85676. kind = kinds[kindIndex];
  85677. var stride = vbs[kind].getStrideSize();
  85678. for (var offset = 0; offset < stride; offset++) {
  85679. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85680. }
  85681. }
  85682. }
  85683. // Updating indices
  85684. for (index = 0; index < totalIndices; index += 3) {
  85685. indices[index] = index;
  85686. indices[index + 1] = index + 1;
  85687. indices[index + 2] = index + 2;
  85688. }
  85689. this.setIndices(indices);
  85690. // Updating vertex buffers
  85691. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85692. kind = kinds[kindIndex];
  85693. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85694. }
  85695. // Updating submeshes
  85696. this.releaseSubMeshes();
  85697. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85698. var previousOne = previousSubmeshes[submeshIndex];
  85699. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85700. }
  85701. this._unIndexed = true;
  85702. this.synchronizeInstances();
  85703. return this;
  85704. };
  85705. /**
  85706. * Inverses facet orientations.
  85707. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  85708. * @param flipNormals will also inverts the normals
  85709. * @returns current mesh
  85710. */
  85711. Mesh.prototype.flipFaces = function (flipNormals) {
  85712. if (flipNormals === void 0) { flipNormals = false; }
  85713. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  85714. var i;
  85715. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  85716. for (i = 0; i < vertex_data.normals.length; i++) {
  85717. vertex_data.normals[i] *= -1;
  85718. }
  85719. }
  85720. if (vertex_data.indices) {
  85721. var temp;
  85722. for (i = 0; i < vertex_data.indices.length; i += 3) {
  85723. // reassign indices
  85724. temp = vertex_data.indices[i + 1];
  85725. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  85726. vertex_data.indices[i + 2] = temp;
  85727. }
  85728. }
  85729. vertex_data.applyToMesh(this);
  85730. return this;
  85731. };
  85732. // Instances
  85733. /** @hidden */
  85734. Mesh._instancedMeshFactory = function (name, mesh) {
  85735. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  85736. };
  85737. /** @hidden */
  85738. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  85739. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  85740. };
  85741. /**
  85742. * Creates a new InstancedMesh object from the mesh model.
  85743. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85744. * @param name defines the name of the new instance
  85745. * @returns a new InstancedMesh
  85746. */
  85747. Mesh.prototype.createInstance = function (name) {
  85748. return Mesh._instancedMeshFactory(name, this);
  85749. };
  85750. /**
  85751. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  85752. * After this call, all the mesh instances have the same submeshes than the current mesh.
  85753. * @returns the current mesh
  85754. */
  85755. Mesh.prototype.synchronizeInstances = function () {
  85756. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  85757. var instance = this.instances[instanceIndex];
  85758. instance._syncSubMeshes();
  85759. }
  85760. return this;
  85761. };
  85762. /**
  85763. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  85764. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  85765. * This should be used together with the simplification to avoid disappearing triangles.
  85766. * @param successCallback an optional success callback to be called after the optimization finished.
  85767. * @returns the current mesh
  85768. */
  85769. Mesh.prototype.optimizeIndices = function (successCallback) {
  85770. var _this = this;
  85771. var indices = this.getIndices();
  85772. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85773. if (!positions || !indices) {
  85774. return this;
  85775. }
  85776. var vectorPositions = new Array();
  85777. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  85778. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  85779. }
  85780. var dupes = new Array();
  85781. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  85782. var realPos = vectorPositions.length - 1 - iteration;
  85783. var testedPosition = vectorPositions[realPos];
  85784. for (var j = 0; j < realPos; ++j) {
  85785. var againstPosition = vectorPositions[j];
  85786. if (testedPosition.equals(againstPosition)) {
  85787. dupes[realPos] = j;
  85788. break;
  85789. }
  85790. }
  85791. }, function () {
  85792. for (var i = 0; i < indices.length; ++i) {
  85793. indices[i] = dupes[indices[i]] || indices[i];
  85794. }
  85795. //indices are now reordered
  85796. var originalSubMeshes = _this.subMeshes.slice(0);
  85797. _this.setIndices(indices);
  85798. _this.subMeshes = originalSubMeshes;
  85799. if (successCallback) {
  85800. successCallback(_this);
  85801. }
  85802. });
  85803. return this;
  85804. };
  85805. /**
  85806. * Serialize current mesh
  85807. * @param serializationObject defines the object which will receive the serialization data
  85808. */
  85809. Mesh.prototype.serialize = function (serializationObject) {
  85810. serializationObject.name = this.name;
  85811. serializationObject.id = this.id;
  85812. serializationObject.type = this.getClassName();
  85813. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  85814. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  85815. }
  85816. serializationObject.position = this.position.asArray();
  85817. if (this.rotationQuaternion) {
  85818. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  85819. }
  85820. else if (this.rotation) {
  85821. serializationObject.rotation = this.rotation.asArray();
  85822. }
  85823. serializationObject.scaling = this.scaling.asArray();
  85824. if (this._postMultiplyPivotMatrix) {
  85825. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  85826. }
  85827. else {
  85828. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  85829. }
  85830. serializationObject.isEnabled = this.isEnabled(false);
  85831. serializationObject.isVisible = this.isVisible;
  85832. serializationObject.infiniteDistance = this.infiniteDistance;
  85833. serializationObject.pickable = this.isPickable;
  85834. serializationObject.receiveShadows = this.receiveShadows;
  85835. serializationObject.billboardMode = this.billboardMode;
  85836. serializationObject.visibility = this.visibility;
  85837. serializationObject.checkCollisions = this.checkCollisions;
  85838. serializationObject.isBlocker = this.isBlocker;
  85839. // Parent
  85840. if (this.parent) {
  85841. serializationObject.parentId = this.parent.id;
  85842. }
  85843. // Geometry
  85844. serializationObject.isUnIndexed = this.isUnIndexed;
  85845. var geometry = this._geometry;
  85846. if (geometry) {
  85847. var geometryId = geometry.id;
  85848. serializationObject.geometryId = geometryId;
  85849. // SubMeshes
  85850. serializationObject.subMeshes = [];
  85851. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  85852. var subMesh = this.subMeshes[subIndex];
  85853. serializationObject.subMeshes.push({
  85854. materialIndex: subMesh.materialIndex,
  85855. verticesStart: subMesh.verticesStart,
  85856. verticesCount: subMesh.verticesCount,
  85857. indexStart: subMesh.indexStart,
  85858. indexCount: subMesh.indexCount
  85859. });
  85860. }
  85861. }
  85862. // Material
  85863. if (this.material) {
  85864. serializationObject.materialId = this.material.id;
  85865. }
  85866. else {
  85867. this.material = null;
  85868. }
  85869. // Morph targets
  85870. if (this.morphTargetManager) {
  85871. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  85872. }
  85873. // Skeleton
  85874. if (this.skeleton) {
  85875. serializationObject.skeletonId = this.skeleton.id;
  85876. }
  85877. // Physics
  85878. //TODO implement correct serialization for physics impostors.
  85879. var impostor = this.getPhysicsImpostor();
  85880. if (impostor) {
  85881. serializationObject.physicsMass = impostor.getParam("mass");
  85882. serializationObject.physicsFriction = impostor.getParam("friction");
  85883. serializationObject.physicsRestitution = impostor.getParam("mass");
  85884. serializationObject.physicsImpostor = impostor.type;
  85885. }
  85886. // Metadata
  85887. if (this.metadata) {
  85888. serializationObject.metadata = this.metadata;
  85889. }
  85890. // Instances
  85891. serializationObject.instances = [];
  85892. for (var index = 0; index < this.instances.length; index++) {
  85893. var instance = this.instances[index];
  85894. if (instance.doNotSerialize) {
  85895. continue;
  85896. }
  85897. var serializationInstance = {
  85898. name: instance.name,
  85899. id: instance.id,
  85900. position: instance.position.asArray(),
  85901. scaling: instance.scaling.asArray()
  85902. };
  85903. if (instance.parent) {
  85904. serializationInstance.parentId = instance.parent.id;
  85905. }
  85906. if (instance.rotationQuaternion) {
  85907. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  85908. }
  85909. else if (instance.rotation) {
  85910. serializationInstance.rotation = instance.rotation.asArray();
  85911. }
  85912. serializationObject.instances.push(serializationInstance);
  85913. // Animations
  85914. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  85915. serializationInstance.ranges = instance.serializeAnimationRanges();
  85916. }
  85917. //
  85918. // Animations
  85919. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  85920. serializationObject.ranges = this.serializeAnimationRanges();
  85921. // Layer mask
  85922. serializationObject.layerMask = this.layerMask;
  85923. // Alpha
  85924. serializationObject.alphaIndex = this.alphaIndex;
  85925. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  85926. // Overlay
  85927. serializationObject.overlayAlpha = this.overlayAlpha;
  85928. serializationObject.overlayColor = this.overlayColor.asArray();
  85929. serializationObject.renderOverlay = this.renderOverlay;
  85930. // Fog
  85931. serializationObject.applyFog = this.applyFog;
  85932. // Action Manager
  85933. if (this.actionManager) {
  85934. serializationObject.actions = this.actionManager.serialize(this.name);
  85935. }
  85936. };
  85937. /** @hidden */
  85938. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  85939. if (!this.geometry) {
  85940. return;
  85941. }
  85942. this._markSubMeshesAsAttributesDirty();
  85943. var morphTargetManager = this._morphTargetManager;
  85944. if (morphTargetManager && morphTargetManager.vertexCount) {
  85945. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  85946. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  85947. this.morphTargetManager = null;
  85948. return;
  85949. }
  85950. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  85951. var morphTarget = morphTargetManager.getActiveTarget(index);
  85952. var positions = morphTarget.getPositions();
  85953. if (!positions) {
  85954. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  85955. return;
  85956. }
  85957. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  85958. var normals = morphTarget.getNormals();
  85959. if (normals) {
  85960. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  85961. }
  85962. var tangents = morphTarget.getTangents();
  85963. if (tangents) {
  85964. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  85965. }
  85966. }
  85967. }
  85968. else {
  85969. var index = 0;
  85970. // Positions
  85971. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  85972. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  85973. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  85974. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  85975. }
  85976. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  85977. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  85978. }
  85979. index++;
  85980. }
  85981. }
  85982. };
  85983. /**
  85984. * Returns a new Mesh object parsed from the source provided.
  85985. * @param parsedMesh is the source
  85986. * @param scene defines the hosting scene
  85987. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  85988. * @returns a new Mesh
  85989. */
  85990. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  85991. var mesh;
  85992. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  85993. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  85994. }
  85995. else {
  85996. mesh = new Mesh(parsedMesh.name, scene);
  85997. }
  85998. mesh.id = parsedMesh.id;
  85999. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  86000. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  86001. }
  86002. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  86003. if (parsedMesh.metadata !== undefined) {
  86004. mesh.metadata = parsedMesh.metadata;
  86005. }
  86006. if (parsedMesh.rotationQuaternion) {
  86007. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  86008. }
  86009. else if (parsedMesh.rotation) {
  86010. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  86011. }
  86012. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  86013. if (parsedMesh.localMatrix) {
  86014. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  86015. }
  86016. else if (parsedMesh.pivotMatrix) {
  86017. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  86018. }
  86019. mesh.setEnabled(parsedMesh.isEnabled);
  86020. mesh.isVisible = parsedMesh.isVisible;
  86021. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  86022. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  86023. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  86024. if (parsedMesh.applyFog !== undefined) {
  86025. mesh.applyFog = parsedMesh.applyFog;
  86026. }
  86027. if (parsedMesh.pickable !== undefined) {
  86028. mesh.isPickable = parsedMesh.pickable;
  86029. }
  86030. if (parsedMesh.alphaIndex !== undefined) {
  86031. mesh.alphaIndex = parsedMesh.alphaIndex;
  86032. }
  86033. mesh.receiveShadows = parsedMesh.receiveShadows;
  86034. mesh.billboardMode = parsedMesh.billboardMode;
  86035. if (parsedMesh.visibility !== undefined) {
  86036. mesh.visibility = parsedMesh.visibility;
  86037. }
  86038. mesh.checkCollisions = parsedMesh.checkCollisions;
  86039. if (parsedMesh.isBlocker !== undefined) {
  86040. mesh.isBlocker = parsedMesh.isBlocker;
  86041. }
  86042. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  86043. // freezeWorldMatrix
  86044. if (parsedMesh.freezeWorldMatrix) {
  86045. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  86046. }
  86047. // Parent
  86048. if (parsedMesh.parentId) {
  86049. mesh._waitingParentId = parsedMesh.parentId;
  86050. }
  86051. // Actions
  86052. if (parsedMesh.actions !== undefined) {
  86053. mesh._waitingActions = parsedMesh.actions;
  86054. }
  86055. // Overlay
  86056. if (parsedMesh.overlayAlpha !== undefined) {
  86057. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  86058. }
  86059. if (parsedMesh.overlayColor !== undefined) {
  86060. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  86061. }
  86062. if (parsedMesh.renderOverlay !== undefined) {
  86063. mesh.renderOverlay = parsedMesh.renderOverlay;
  86064. }
  86065. // Geometry
  86066. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  86067. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  86068. if (parsedMesh.delayLoadingFile) {
  86069. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  86070. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  86071. 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));
  86072. if (parsedMesh._binaryInfo) {
  86073. mesh._binaryInfo = parsedMesh._binaryInfo;
  86074. }
  86075. mesh._delayInfo = [];
  86076. if (parsedMesh.hasUVs) {
  86077. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  86078. }
  86079. if (parsedMesh.hasUVs2) {
  86080. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  86081. }
  86082. if (parsedMesh.hasUVs3) {
  86083. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  86084. }
  86085. if (parsedMesh.hasUVs4) {
  86086. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  86087. }
  86088. if (parsedMesh.hasUVs5) {
  86089. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  86090. }
  86091. if (parsedMesh.hasUVs6) {
  86092. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  86093. }
  86094. if (parsedMesh.hasColors) {
  86095. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  86096. }
  86097. if (parsedMesh.hasMatricesIndices) {
  86098. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86099. }
  86100. if (parsedMesh.hasMatricesWeights) {
  86101. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86102. }
  86103. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  86104. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  86105. mesh._checkDelayState();
  86106. }
  86107. }
  86108. else {
  86109. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  86110. }
  86111. // Material
  86112. if (parsedMesh.materialId) {
  86113. mesh.setMaterialByID(parsedMesh.materialId);
  86114. }
  86115. else {
  86116. mesh.material = null;
  86117. }
  86118. // Morph targets
  86119. if (parsedMesh.morphTargetManagerId > -1) {
  86120. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  86121. }
  86122. // Skeleton
  86123. if (parsedMesh.skeletonId > -1) {
  86124. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  86125. if (parsedMesh.numBoneInfluencers) {
  86126. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  86127. }
  86128. }
  86129. // Animations
  86130. if (parsedMesh.animations) {
  86131. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  86132. var parsedAnimation = parsedMesh.animations[animationIndex];
  86133. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  86134. if (internalClass) {
  86135. mesh.animations.push(internalClass.Parse(parsedAnimation));
  86136. }
  86137. }
  86138. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  86139. }
  86140. if (parsedMesh.autoAnimate) {
  86141. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  86142. }
  86143. // Layer Mask
  86144. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  86145. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  86146. }
  86147. else {
  86148. mesh.layerMask = 0x0FFFFFFF;
  86149. }
  86150. // Physics
  86151. if (parsedMesh.physicsImpostor) {
  86152. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  86153. }
  86154. // Instances
  86155. if (parsedMesh.instances) {
  86156. for (var index = 0; index < parsedMesh.instances.length; index++) {
  86157. var parsedInstance = parsedMesh.instances[index];
  86158. var instance = mesh.createInstance(parsedInstance.name);
  86159. if (parsedInstance.id) {
  86160. instance.id = parsedInstance.id;
  86161. }
  86162. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  86163. if (parsedInstance.tags) {
  86164. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  86165. }
  86166. else {
  86167. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  86168. }
  86169. }
  86170. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  86171. if (parsedInstance.parentId) {
  86172. instance._waitingParentId = parsedInstance.parentId;
  86173. }
  86174. if (parsedInstance.rotationQuaternion) {
  86175. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  86176. }
  86177. else if (parsedInstance.rotation) {
  86178. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  86179. }
  86180. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  86181. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  86182. instance.checkCollisions = parsedInstance.checkCollisions;
  86183. }
  86184. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  86185. instance.isPickable = parsedInstance.pickable;
  86186. }
  86187. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  86188. instance.showBoundingBox = parsedInstance.showBoundingBox;
  86189. }
  86190. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86191. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  86192. }
  86193. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86194. instance.alphaIndex = parsedInstance.alphaIndex;
  86195. }
  86196. // Physics
  86197. if (parsedInstance.physicsImpostor) {
  86198. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  86199. }
  86200. // Animation
  86201. if (parsedInstance.animations) {
  86202. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  86203. parsedAnimation = parsedInstance.animations[animationIndex];
  86204. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  86205. if (internalClass) {
  86206. instance.animations.push(internalClass.Parse(parsedAnimation));
  86207. }
  86208. }
  86209. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  86210. if (parsedInstance.autoAnimate) {
  86211. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  86212. }
  86213. }
  86214. }
  86215. }
  86216. return mesh;
  86217. };
  86218. /**
  86219. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  86220. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86221. * @param name defines the name of the mesh to create
  86222. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  86223. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  86224. * @param closePath creates a seam between the first and the last points of each path of the path array
  86225. * @param offset is taken in account only if the `pathArray` is containing a single path
  86226. * @param scene defines the hosting scene
  86227. * @param updatable defines if the mesh must be flagged as updatable
  86228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86229. * @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)
  86230. * @returns a new Mesh
  86231. */
  86232. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  86233. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86234. };
  86235. /**
  86236. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  86237. * @param name defines the name of the mesh to create
  86238. * @param radius sets the radius size (float) of the polygon (default 0.5)
  86239. * @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
  86240. * @param scene defines the hosting scene
  86241. * @param updatable defines if the mesh must be flagged as updatable
  86242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86243. * @returns a new Mesh
  86244. */
  86245. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  86246. if (scene === void 0) { scene = null; }
  86247. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86248. };
  86249. /**
  86250. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  86251. * @param name defines the name of the mesh to create
  86252. * @param size sets the size (float) of each box side (default 1)
  86253. * @param scene defines the hosting scene
  86254. * @param updatable defines if the mesh must be flagged as updatable
  86255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86256. * @returns a new Mesh
  86257. */
  86258. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  86259. if (scene === void 0) { scene = null; }
  86260. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86261. };
  86262. /**
  86263. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  86264. * @param name defines the name of the mesh to create
  86265. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  86266. * @param diameter sets the diameter size (float) of the sphere (default 1)
  86267. * @param scene defines the hosting scene
  86268. * @param updatable defines if the mesh must be flagged as updatable
  86269. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86270. * @returns a new Mesh
  86271. */
  86272. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  86273. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86274. };
  86275. /**
  86276. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  86277. * @param name defines the name of the mesh to create
  86278. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  86279. * @param diameterTop set the top cap diameter (floats, default 1)
  86280. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  86281. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  86282. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  86283. * @param scene defines the hosting scene
  86284. * @param updatable defines if the mesh must be flagged as updatable
  86285. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86286. * @returns a new Mesh
  86287. */
  86288. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  86289. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86290. };
  86291. // Torus (Code from SharpDX.org)
  86292. /**
  86293. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  86294. * @param name defines the name of the mesh to create
  86295. * @param diameter sets the diameter size (float) of the torus (default 1)
  86296. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  86297. * @param tessellation sets the number of torus sides (postive integer, default 16)
  86298. * @param scene defines the hosting scene
  86299. * @param updatable defines if the mesh must be flagged as updatable
  86300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86301. * @returns a new Mesh
  86302. */
  86303. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  86304. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86305. };
  86306. /**
  86307. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  86308. * @param name defines the name of the mesh to create
  86309. * @param radius sets the global radius size (float) of the torus knot (default 2)
  86310. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  86311. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  86312. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  86313. * @param p the number of windings on X axis (positive integers, default 2)
  86314. * @param q the number of windings on Y axis (positive integers, default 3)
  86315. * @param scene defines the hosting scene
  86316. * @param updatable defines if the mesh must be flagged as updatable
  86317. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86318. * @returns a new Mesh
  86319. */
  86320. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  86321. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86322. };
  86323. /**
  86324. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  86325. * @param name defines the name of the mesh to create
  86326. * @param points is an array successive Vector3
  86327. * @param scene defines the hosting scene
  86328. * @param updatable defines if the mesh must be flagged as updatable
  86329. * @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).
  86330. * @returns a new Mesh
  86331. */
  86332. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  86333. if (scene === void 0) { scene = null; }
  86334. if (updatable === void 0) { updatable = false; }
  86335. if (instance === void 0) { instance = null; }
  86336. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86337. };
  86338. /**
  86339. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  86340. * @param name defines the name of the mesh to create
  86341. * @param points is an array successive Vector3
  86342. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  86343. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86344. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  86345. * @param scene defines the hosting scene
  86346. * @param updatable defines if the mesh must be flagged as updatable
  86347. * @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)
  86348. * @returns a new Mesh
  86349. */
  86350. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  86351. if (scene === void 0) { scene = null; }
  86352. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86353. };
  86354. /**
  86355. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  86356. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  86357. * 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.
  86358. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86359. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86360. * Remember you can only change the shape positions, not their number when updating a polygon.
  86361. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  86362. * @param name defines the name of the mesh to create
  86363. * @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
  86364. * @param scene defines the hosting scene
  86365. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86366. * @param updatable defines if the mesh must be flagged as updatable
  86367. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86368. * @param earcutInjection can be used to inject your own earcut reference
  86369. * @returns a new Mesh
  86370. */
  86371. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  86372. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86373. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86374. };
  86375. /**
  86376. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  86377. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  86378. * @param name defines the name of the mesh to create
  86379. * @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
  86380. * @param depth defines the height of extrusion
  86381. * @param scene defines the hosting scene
  86382. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86383. * @param updatable defines if the mesh must be flagged as updatable
  86384. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86385. * @param earcutInjection can be used to inject your own earcut reference
  86386. * @returns a new Mesh
  86387. */
  86388. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  86389. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86390. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86391. };
  86392. /**
  86393. * Creates an extruded shape mesh.
  86394. * 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
  86395. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86396. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86397. * @param name defines the name of the mesh to create
  86398. * @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
  86399. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86400. * @param scale is the value to scale the shape
  86401. * @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
  86402. * @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
  86403. * @param scene defines the hosting scene
  86404. * @param updatable defines if the mesh must be flagged as updatable
  86405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86406. * @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)
  86407. * @returns a new Mesh
  86408. */
  86409. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  86410. if (scene === void 0) { scene = null; }
  86411. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86412. };
  86413. /**
  86414. * Creates an custom extruded shape mesh.
  86415. * The custom extrusion is a parametric shape.
  86416. * It has no predefined shape. Its final shape will depend on the input parameters.
  86417. * Please consider using the same method from the MeshBuilder class instead
  86418. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86419. * @param name defines the name of the mesh to create
  86420. * @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
  86421. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86422. * @param scaleFunction is a custom Javascript function called on each path point
  86423. * @param rotationFunction is a custom Javascript function called on each path point
  86424. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86425. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  86426. * @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
  86427. * @param scene defines the hosting scene
  86428. * @param updatable defines if the mesh must be flagged as updatable
  86429. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86430. * @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)
  86431. * @returns a new Mesh
  86432. */
  86433. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  86434. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86435. };
  86436. /**
  86437. * Creates lathe mesh.
  86438. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  86439. * Please consider using the same method from the MeshBuilder class instead
  86440. * @param name defines the name of the mesh to create
  86441. * @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
  86442. * @param radius is the radius value of the lathe
  86443. * @param tessellation is the side number of the lathe.
  86444. * @param scene defines the hosting scene
  86445. * @param updatable defines if the mesh must be flagged as updatable
  86446. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86447. * @returns a new Mesh
  86448. */
  86449. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  86450. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86451. };
  86452. /**
  86453. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  86454. * @param name defines the name of the mesh to create
  86455. * @param size sets the size (float) of both sides of the plane at once (default 1)
  86456. * @param scene defines the hosting scene
  86457. * @param updatable defines if the mesh must be flagged as updatable
  86458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86459. * @returns a new Mesh
  86460. */
  86461. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  86462. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86463. };
  86464. /**
  86465. * Creates a ground mesh.
  86466. * Please consider using the same method from the MeshBuilder class instead
  86467. * @param name defines the name of the mesh to create
  86468. * @param width set the width of the ground
  86469. * @param height set the height of the ground
  86470. * @param subdivisions sets the number of subdivisions per side
  86471. * @param scene defines the hosting scene
  86472. * @param updatable defines if the mesh must be flagged as updatable
  86473. * @returns a new Mesh
  86474. */
  86475. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  86476. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86477. };
  86478. /**
  86479. * Creates a tiled ground mesh.
  86480. * Please consider using the same method from the MeshBuilder class instead
  86481. * @param name defines the name of the mesh to create
  86482. * @param xmin set the ground minimum X coordinate
  86483. * @param zmin set the ground minimum Y coordinate
  86484. * @param xmax set the ground maximum X coordinate
  86485. * @param zmax set the ground maximum Z coordinate
  86486. * @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
  86487. * @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
  86488. * @param scene defines the hosting scene
  86489. * @param updatable defines if the mesh must be flagged as updatable
  86490. * @returns a new Mesh
  86491. */
  86492. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  86493. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86494. };
  86495. /**
  86496. * Creates a ground mesh from a height map.
  86497. * Please consider using the same method from the MeshBuilder class instead
  86498. * @see http://doc.babylonjs.com/babylon101/height_map
  86499. * @param name defines the name of the mesh to create
  86500. * @param url sets the URL of the height map image resource
  86501. * @param width set the ground width size
  86502. * @param height set the ground height size
  86503. * @param subdivisions sets the number of subdivision per side
  86504. * @param minHeight is the minimum altitude on the ground
  86505. * @param maxHeight is the maximum altitude on the ground
  86506. * @param scene defines the hosting scene
  86507. * @param updatable defines if the mesh must be flagged as updatable
  86508. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  86509. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  86510. * @returns a new Mesh
  86511. */
  86512. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86513. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86514. };
  86515. /**
  86516. * Creates a tube mesh.
  86517. * The tube is a parametric shape.
  86518. * It has no predefined shape. Its final shape will depend on the input parameters.
  86519. * Please consider using the same method from the MeshBuilder class instead
  86520. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86521. * @param name defines the name of the mesh to create
  86522. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  86523. * @param radius sets the tube radius size
  86524. * @param tessellation is the number of sides on the tubular surface
  86525. * @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
  86526. * @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
  86527. * @param scene defines the hosting scene
  86528. * @param updatable defines if the mesh must be flagged as updatable
  86529. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86530. * @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)
  86531. * @returns a new Mesh
  86532. */
  86533. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  86534. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86535. };
  86536. /**
  86537. * Creates a polyhedron mesh.
  86538. * Please consider using the same method from the MeshBuilder class instead.
  86539. * * 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
  86540. * * The parameter `size` (positive float, default 1) sets the polygon size
  86541. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  86542. * * 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`
  86543. * * 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
  86544. * * 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)`)
  86545. * * 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
  86546. * * 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
  86547. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86548. * * 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
  86549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86550. * @param name defines the name of the mesh to create
  86551. * @param options defines the options used to create the mesh
  86552. * @param scene defines the hosting scene
  86553. * @returns a new Mesh
  86554. */
  86555. Mesh.CreatePolyhedron = function (name, options, scene) {
  86556. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86557. };
  86558. /**
  86559. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  86560. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  86561. * * 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`)
  86562. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  86563. * * 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
  86564. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86565. * * 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
  86566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86567. * @param name defines the name of the mesh
  86568. * @param options defines the options used to create the mesh
  86569. * @param scene defines the hosting scene
  86570. * @returns a new Mesh
  86571. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  86572. */
  86573. Mesh.CreateIcoSphere = function (name, options, scene) {
  86574. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86575. };
  86576. /**
  86577. * Creates a decal mesh.
  86578. * Please consider using the same method from the MeshBuilder class instead.
  86579. * A decal is a mesh usually applied as a model onto the surface of another mesh
  86580. * @param name defines the name of the mesh
  86581. * @param sourceMesh defines the mesh receiving the decal
  86582. * @param position sets the position of the decal in world coordinates
  86583. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  86584. * @param size sets the decal scaling
  86585. * @param angle sets the angle to rotate the decal
  86586. * @returns a new Mesh
  86587. */
  86588. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  86589. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86590. };
  86591. // Skeletons
  86592. /**
  86593. * Prepare internal position array for software CPU skinning
  86594. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  86595. */
  86596. Mesh.prototype.setPositionsForCPUSkinning = function () {
  86597. if (!this._sourcePositions) {
  86598. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86599. if (!source) {
  86600. return this._sourcePositions;
  86601. }
  86602. this._sourcePositions = new Float32Array(source);
  86603. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86604. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  86605. }
  86606. }
  86607. return this._sourcePositions;
  86608. };
  86609. /**
  86610. * Prepare internal normal array for software CPU skinning
  86611. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  86612. */
  86613. Mesh.prototype.setNormalsForCPUSkinning = function () {
  86614. if (!this._sourceNormals) {
  86615. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86616. if (!source) {
  86617. return this._sourceNormals;
  86618. }
  86619. this._sourceNormals = new Float32Array(source);
  86620. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86621. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  86622. }
  86623. }
  86624. return this._sourceNormals;
  86625. };
  86626. /**
  86627. * Updates the vertex buffer by applying transformation from the bones
  86628. * @param skeleton defines the skeleton to apply to current mesh
  86629. * @returns the current mesh
  86630. */
  86631. Mesh.prototype.applySkeleton = function (skeleton) {
  86632. if (!this.geometry) {
  86633. return this;
  86634. }
  86635. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  86636. return this;
  86637. }
  86638. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  86639. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86640. return this;
  86641. }
  86642. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86643. return this;
  86644. }
  86645. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  86646. return this;
  86647. }
  86648. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  86649. return this;
  86650. }
  86651. if (!this._sourcePositions) {
  86652. var submeshes = this.subMeshes.slice();
  86653. this.setPositionsForCPUSkinning();
  86654. this.subMeshes = submeshes;
  86655. }
  86656. if (!this._sourceNormals) {
  86657. this.setNormalsForCPUSkinning();
  86658. }
  86659. // positionsData checks for not being Float32Array will only pass at most once
  86660. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86661. if (!positionsData) {
  86662. return this;
  86663. }
  86664. if (!(positionsData instanceof Float32Array)) {
  86665. positionsData = new Float32Array(positionsData);
  86666. }
  86667. // normalsData checks for not being Float32Array will only pass at most once
  86668. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86669. if (!normalsData) {
  86670. return this;
  86671. }
  86672. if (!(normalsData instanceof Float32Array)) {
  86673. normalsData = new Float32Array(normalsData);
  86674. }
  86675. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86676. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86677. if (!matricesWeightsData || !matricesIndicesData) {
  86678. return this;
  86679. }
  86680. var needExtras = this.numBoneInfluencers > 4;
  86681. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  86682. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  86683. var skeletonMatrices = skeleton.getTransformMatrices(this);
  86684. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86685. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86686. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86687. var matWeightIdx = 0;
  86688. var inf;
  86689. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  86690. var weight;
  86691. for (inf = 0; inf < 4; inf++) {
  86692. weight = matricesWeightsData[matWeightIdx + inf];
  86693. if (weight > 0) {
  86694. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86695. finalMatrix.addToSelf(tempMatrix);
  86696. }
  86697. }
  86698. if (needExtras) {
  86699. for (inf = 0; inf < 4; inf++) {
  86700. weight = matricesWeightsExtraData[matWeightIdx + inf];
  86701. if (weight > 0) {
  86702. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86703. finalMatrix.addToSelf(tempMatrix);
  86704. }
  86705. }
  86706. }
  86707. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  86708. tempVector3.toArray(positionsData, index);
  86709. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  86710. tempVector3.toArray(normalsData, index);
  86711. finalMatrix.reset();
  86712. }
  86713. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  86714. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  86715. return this;
  86716. };
  86717. // Tools
  86718. /**
  86719. * 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
  86720. * @param meshes defines the list of meshes to scan
  86721. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  86722. */
  86723. Mesh.MinMax = function (meshes) {
  86724. var minVector = null;
  86725. var maxVector = null;
  86726. meshes.forEach(function (mesh) {
  86727. var boundingInfo = mesh.getBoundingInfo();
  86728. var boundingBox = boundingInfo.boundingBox;
  86729. if (!minVector || !maxVector) {
  86730. minVector = boundingBox.minimumWorld;
  86731. maxVector = boundingBox.maximumWorld;
  86732. }
  86733. else {
  86734. minVector.minimizeInPlace(boundingBox.minimumWorld);
  86735. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  86736. }
  86737. });
  86738. if (!minVector || !maxVector) {
  86739. return {
  86740. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  86741. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  86742. };
  86743. }
  86744. return {
  86745. min: minVector,
  86746. max: maxVector
  86747. };
  86748. };
  86749. /**
  86750. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  86751. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  86752. * @returns a vector3
  86753. */
  86754. Mesh.Center = function (meshesOrMinMaxVector) {
  86755. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  86756. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  86757. };
  86758. /**
  86759. * Merge the array of meshes into a single mesh for performance reasons.
  86760. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  86761. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  86762. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  86763. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  86764. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  86765. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  86766. * @returns a new mesh
  86767. */
  86768. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  86769. if (disposeSource === void 0) { disposeSource = true; }
  86770. var index;
  86771. if (!allow32BitsIndices) {
  86772. var totalVertices = 0;
  86773. // Counting vertices
  86774. for (index = 0; index < meshes.length; index++) {
  86775. if (meshes[index]) {
  86776. totalVertices += meshes[index].getTotalVertices();
  86777. if (totalVertices > 65536) {
  86778. _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");
  86779. return null;
  86780. }
  86781. }
  86782. }
  86783. }
  86784. if (multiMultiMaterials) {
  86785. var newMultiMaterial = null;
  86786. var subIndex;
  86787. var matIndex;
  86788. subdivideWithSubMeshes = false;
  86789. }
  86790. var materialArray = new Array();
  86791. var materialIndexArray = new Array();
  86792. // Merge
  86793. var vertexData = null;
  86794. var otherVertexData;
  86795. var indiceArray = new Array();
  86796. var source = null;
  86797. for (index = 0; index < meshes.length; index++) {
  86798. if (meshes[index]) {
  86799. var mesh = meshes[index];
  86800. var wm = mesh.computeWorldMatrix(true);
  86801. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  86802. otherVertexData.transform(wm);
  86803. if (vertexData) {
  86804. vertexData.merge(otherVertexData, allow32BitsIndices);
  86805. }
  86806. else {
  86807. vertexData = otherVertexData;
  86808. source = mesh;
  86809. }
  86810. if (subdivideWithSubMeshes) {
  86811. indiceArray.push(mesh.getTotalIndices());
  86812. }
  86813. if (multiMultiMaterials) {
  86814. if (mesh.material) {
  86815. var material = mesh.material;
  86816. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  86817. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  86818. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  86819. materialArray.push(material.subMaterials[matIndex]);
  86820. }
  86821. }
  86822. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86823. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  86824. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86825. }
  86826. }
  86827. else {
  86828. if (materialArray.indexOf(material) < 0) {
  86829. materialArray.push(material);
  86830. }
  86831. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86832. materialIndexArray.push(materialArray.indexOf(material));
  86833. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86834. }
  86835. }
  86836. }
  86837. else {
  86838. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86839. materialIndexArray.push(0);
  86840. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86841. }
  86842. }
  86843. }
  86844. }
  86845. }
  86846. source = source;
  86847. if (!meshSubclass) {
  86848. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  86849. }
  86850. vertexData.applyToMesh(meshSubclass);
  86851. // Setting properties
  86852. meshSubclass.checkCollisions = source.checkCollisions;
  86853. // Cleaning
  86854. if (disposeSource) {
  86855. for (index = 0; index < meshes.length; index++) {
  86856. if (meshes[index]) {
  86857. meshes[index].dispose();
  86858. }
  86859. }
  86860. }
  86861. // Subdivide
  86862. if (subdivideWithSubMeshes || multiMultiMaterials) {
  86863. //-- removal of global submesh
  86864. meshSubclass.releaseSubMeshes();
  86865. index = 0;
  86866. var offset = 0;
  86867. //-- apply subdivision according to index table
  86868. while (index < indiceArray.length) {
  86869. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  86870. offset += indiceArray[index];
  86871. index++;
  86872. }
  86873. }
  86874. if (multiMultiMaterials) {
  86875. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  86876. newMultiMaterial.subMaterials = materialArray;
  86877. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  86878. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  86879. }
  86880. meshSubclass.material = newMultiMaterial;
  86881. }
  86882. else {
  86883. meshSubclass.material = source.material;
  86884. }
  86885. return meshSubclass;
  86886. };
  86887. /** @hidden */
  86888. Mesh.prototype.addInstance = function (instance) {
  86889. instance._indexInSourceMeshInstanceArray = this.instances.length;
  86890. this.instances.push(instance);
  86891. };
  86892. /** @hidden */
  86893. Mesh.prototype.removeInstance = function (instance) {
  86894. // Remove from mesh
  86895. var index = instance._indexInSourceMeshInstanceArray;
  86896. if (index != -1) {
  86897. if (index !== this.instances.length - 1) {
  86898. var last = this.instances[this.instances.length - 1];
  86899. this.instances[index] = last;
  86900. last._indexInSourceMeshInstanceArray = index;
  86901. }
  86902. instance._indexInSourceMeshInstanceArray = -1;
  86903. this.instances.pop();
  86904. }
  86905. };
  86906. // Consts
  86907. /**
  86908. * Mesh side orientation : usually the external or front surface
  86909. */
  86910. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  86911. /**
  86912. * Mesh side orientation : usually the internal or back surface
  86913. */
  86914. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  86915. /**
  86916. * Mesh side orientation : both internal and external or front and back surfaces
  86917. */
  86918. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  86919. /**
  86920. * Mesh side orientation : by default, `FRONTSIDE`
  86921. */
  86922. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  86923. /**
  86924. * Mesh cap setting : no cap
  86925. */
  86926. Mesh.NO_CAP = 0;
  86927. /**
  86928. * Mesh cap setting : one cap at the beginning of the mesh
  86929. */
  86930. Mesh.CAP_START = 1;
  86931. /**
  86932. * Mesh cap setting : one cap at the end of the mesh
  86933. */
  86934. Mesh.CAP_END = 2;
  86935. /**
  86936. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  86937. */
  86938. Mesh.CAP_ALL = 3;
  86939. // Statics
  86940. /** @hidden */
  86941. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  86942. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  86943. };
  86944. return Mesh;
  86945. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  86946. /***/ }),
  86947. /***/ "./Meshes/mesh.vertexData.ts":
  86948. /*!***********************************!*\
  86949. !*** ./Meshes/mesh.vertexData.ts ***!
  86950. \***********************************/
  86951. /*! exports provided: VertexData */
  86952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86953. "use strict";
  86954. __webpack_require__.r(__webpack_exports__);
  86955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  86956. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86957. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86958. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  86959. /**
  86960. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86961. */
  86962. var VertexData = /** @class */ (function () {
  86963. function VertexData() {
  86964. }
  86965. /**
  86966. * Uses the passed data array to set the set the values for the specified kind of data
  86967. * @param data a linear array of floating numbers
  86968. * @param kind the type of data that is being set, eg positions, colors etc
  86969. */
  86970. VertexData.prototype.set = function (data, kind) {
  86971. switch (kind) {
  86972. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  86973. this.positions = data;
  86974. break;
  86975. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  86976. this.normals = data;
  86977. break;
  86978. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  86979. this.tangents = data;
  86980. break;
  86981. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  86982. this.uvs = data;
  86983. break;
  86984. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  86985. this.uvs2 = data;
  86986. break;
  86987. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  86988. this.uvs3 = data;
  86989. break;
  86990. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  86991. this.uvs4 = data;
  86992. break;
  86993. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  86994. this.uvs5 = data;
  86995. break;
  86996. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  86997. this.uvs6 = data;
  86998. break;
  86999. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  87000. this.colors = data;
  87001. break;
  87002. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  87003. this.matricesIndices = data;
  87004. break;
  87005. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  87006. this.matricesWeights = data;
  87007. break;
  87008. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  87009. this.matricesIndicesExtra = data;
  87010. break;
  87011. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  87012. this.matricesWeightsExtra = data;
  87013. break;
  87014. }
  87015. };
  87016. /**
  87017. * Associates the vertexData to the passed Mesh.
  87018. * Sets it as updatable or not (default `false`)
  87019. * @param mesh the mesh the vertexData is applied to
  87020. * @param updatable when used and having the value true allows new data to update the vertexData
  87021. * @returns the VertexData
  87022. */
  87023. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  87024. this._applyTo(mesh, updatable);
  87025. return this;
  87026. };
  87027. /**
  87028. * Associates the vertexData to the passed Geometry.
  87029. * Sets it as updatable or not (default `false`)
  87030. * @param geometry the geometry the vertexData is applied to
  87031. * @param updatable when used and having the value true allows new data to update the vertexData
  87032. * @returns VertexData
  87033. */
  87034. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  87035. this._applyTo(geometry, updatable);
  87036. return this;
  87037. };
  87038. /**
  87039. * Updates the associated mesh
  87040. * @param mesh the mesh to be updated
  87041. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87042. * @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
  87043. * @returns VertexData
  87044. */
  87045. VertexData.prototype.updateMesh = function (mesh) {
  87046. this._update(mesh);
  87047. return this;
  87048. };
  87049. /**
  87050. * Updates the associated geometry
  87051. * @param geometry the geometry to be updated
  87052. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87053. * @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
  87054. * @returns VertexData.
  87055. */
  87056. VertexData.prototype.updateGeometry = function (geometry) {
  87057. this._update(geometry);
  87058. return this;
  87059. };
  87060. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  87061. if (updatable === void 0) { updatable = false; }
  87062. if (this.positions) {
  87063. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  87064. }
  87065. if (this.normals) {
  87066. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  87067. }
  87068. if (this.tangents) {
  87069. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  87070. }
  87071. if (this.uvs) {
  87072. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  87073. }
  87074. if (this.uvs2) {
  87075. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  87076. }
  87077. if (this.uvs3) {
  87078. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  87079. }
  87080. if (this.uvs4) {
  87081. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  87082. }
  87083. if (this.uvs5) {
  87084. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  87085. }
  87086. if (this.uvs6) {
  87087. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  87088. }
  87089. if (this.colors) {
  87090. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  87091. }
  87092. if (this.matricesIndices) {
  87093. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  87094. }
  87095. if (this.matricesWeights) {
  87096. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  87097. }
  87098. if (this.matricesIndicesExtra) {
  87099. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  87100. }
  87101. if (this.matricesWeightsExtra) {
  87102. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  87103. }
  87104. if (this.indices) {
  87105. meshOrGeometry.setIndices(this.indices, null, updatable);
  87106. }
  87107. else {
  87108. meshOrGeometry.setIndices([], null);
  87109. }
  87110. return this;
  87111. };
  87112. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  87113. if (this.positions) {
  87114. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  87115. }
  87116. if (this.normals) {
  87117. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  87118. }
  87119. if (this.tangents) {
  87120. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  87121. }
  87122. if (this.uvs) {
  87123. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  87124. }
  87125. if (this.uvs2) {
  87126. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  87127. }
  87128. if (this.uvs3) {
  87129. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  87130. }
  87131. if (this.uvs4) {
  87132. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  87133. }
  87134. if (this.uvs5) {
  87135. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  87136. }
  87137. if (this.uvs6) {
  87138. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  87139. }
  87140. if (this.colors) {
  87141. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  87142. }
  87143. if (this.matricesIndices) {
  87144. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  87145. }
  87146. if (this.matricesWeights) {
  87147. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  87148. }
  87149. if (this.matricesIndicesExtra) {
  87150. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  87151. }
  87152. if (this.matricesWeightsExtra) {
  87153. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  87154. }
  87155. if (this.indices) {
  87156. meshOrGeometry.setIndices(this.indices, null);
  87157. }
  87158. return this;
  87159. };
  87160. /**
  87161. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87162. * @param matrix the transforming matrix
  87163. * @returns the VertexData
  87164. */
  87165. VertexData.prototype.transform = function (matrix) {
  87166. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  87167. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87168. var index;
  87169. if (this.positions) {
  87170. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87171. for (index = 0; index < this.positions.length; index += 3) {
  87172. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  87173. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  87174. this.positions[index] = transformed.x;
  87175. this.positions[index + 1] = transformed.y;
  87176. this.positions[index + 2] = transformed.z;
  87177. }
  87178. }
  87179. if (this.normals) {
  87180. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87181. for (index = 0; index < this.normals.length; index += 3) {
  87182. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  87183. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  87184. this.normals[index] = transformed.x;
  87185. this.normals[index + 1] = transformed.y;
  87186. this.normals[index + 2] = transformed.z;
  87187. }
  87188. }
  87189. if (this.tangents) {
  87190. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87191. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87192. for (index = 0; index < this.tangents.length; index += 4) {
  87193. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  87194. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  87195. this.tangents[index] = tangentTransformed.x;
  87196. this.tangents[index + 1] = tangentTransformed.y;
  87197. this.tangents[index + 2] = tangentTransformed.z;
  87198. this.tangents[index + 3] = tangentTransformed.w;
  87199. }
  87200. }
  87201. if (flip && this.indices) {
  87202. for (index = 0; index < this.indices.length; index += 3) {
  87203. var tmp = this.indices[index + 1];
  87204. this.indices[index + 1] = this.indices[index + 2];
  87205. this.indices[index + 2] = tmp;
  87206. }
  87207. }
  87208. return this;
  87209. };
  87210. /**
  87211. * Merges the passed VertexData into the current one
  87212. * @param other the VertexData to be merged into the current one
  87213. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87214. * @returns the modified VertexData
  87215. */
  87216. VertexData.prototype.merge = function (other, use32BitsIndices) {
  87217. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  87218. this._validate();
  87219. other._validate();
  87220. if (!this.normals !== !other.normals ||
  87221. !this.tangents !== !other.tangents ||
  87222. !this.uvs !== !other.uvs ||
  87223. !this.uvs2 !== !other.uvs2 ||
  87224. !this.uvs3 !== !other.uvs3 ||
  87225. !this.uvs4 !== !other.uvs4 ||
  87226. !this.uvs5 !== !other.uvs5 ||
  87227. !this.uvs6 !== !other.uvs6 ||
  87228. !this.colors !== !other.colors ||
  87229. !this.matricesIndices !== !other.matricesIndices ||
  87230. !this.matricesWeights !== !other.matricesWeights ||
  87231. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  87232. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  87233. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  87234. }
  87235. if (other.indices) {
  87236. if (!this.indices) {
  87237. this.indices = [];
  87238. }
  87239. var offset = this.positions ? this.positions.length / 3 : 0;
  87240. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  87241. if (isSrcTypedArray) {
  87242. var len = this.indices.length + other.indices.length;
  87243. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  87244. temp.set(this.indices);
  87245. var decal = this.indices.length;
  87246. for (var index = 0; index < other.indices.length; index++) {
  87247. temp[decal + index] = other.indices[index] + offset;
  87248. }
  87249. this.indices = temp;
  87250. }
  87251. else {
  87252. for (var index = 0; index < other.indices.length; index++) {
  87253. this.indices.push(other.indices[index] + offset);
  87254. }
  87255. }
  87256. }
  87257. this.positions = this._mergeElement(this.positions, other.positions);
  87258. this.normals = this._mergeElement(this.normals, other.normals);
  87259. this.tangents = this._mergeElement(this.tangents, other.tangents);
  87260. this.uvs = this._mergeElement(this.uvs, other.uvs);
  87261. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  87262. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  87263. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  87264. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  87265. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  87266. this.colors = this._mergeElement(this.colors, other.colors);
  87267. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  87268. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  87269. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  87270. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  87271. return this;
  87272. };
  87273. VertexData.prototype._mergeElement = function (source, other) {
  87274. if (!source) {
  87275. return other;
  87276. }
  87277. if (!other) {
  87278. return source;
  87279. }
  87280. var len = other.length + source.length;
  87281. var isSrcTypedArray = source instanceof Float32Array;
  87282. var isOthTypedArray = other instanceof Float32Array;
  87283. // use non-loop method when the source is Float32Array
  87284. if (isSrcTypedArray) {
  87285. var ret32 = new Float32Array(len);
  87286. ret32.set(source);
  87287. ret32.set(other, source.length);
  87288. return ret32;
  87289. // source is number[], when other is also use concat
  87290. }
  87291. else if (!isOthTypedArray) {
  87292. return source.concat(other);
  87293. // source is a number[], but other is a Float32Array, loop required
  87294. }
  87295. else {
  87296. var ret = source.slice(0); // copy source to a separate array
  87297. for (var i = 0, len = other.length; i < len; i++) {
  87298. ret.push(other[i]);
  87299. }
  87300. return ret;
  87301. }
  87302. };
  87303. VertexData.prototype._validate = function () {
  87304. if (!this.positions) {
  87305. throw new Error("Positions are required");
  87306. }
  87307. var getElementCount = function (kind, values) {
  87308. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  87309. if ((values.length % stride) !== 0) {
  87310. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  87311. }
  87312. return values.length / stride;
  87313. };
  87314. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  87315. var validateElementCount = function (kind, values) {
  87316. var elementCount = getElementCount(kind, values);
  87317. if (elementCount !== positionsElementCount) {
  87318. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  87319. }
  87320. };
  87321. if (this.normals) {
  87322. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  87323. }
  87324. if (this.tangents) {
  87325. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  87326. }
  87327. if (this.uvs) {
  87328. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  87329. }
  87330. if (this.uvs2) {
  87331. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  87332. }
  87333. if (this.uvs3) {
  87334. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  87335. }
  87336. if (this.uvs4) {
  87337. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  87338. }
  87339. if (this.uvs5) {
  87340. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  87341. }
  87342. if (this.uvs6) {
  87343. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  87344. }
  87345. if (this.colors) {
  87346. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  87347. }
  87348. if (this.matricesIndices) {
  87349. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  87350. }
  87351. if (this.matricesWeights) {
  87352. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  87353. }
  87354. if (this.matricesIndicesExtra) {
  87355. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  87356. }
  87357. if (this.matricesWeightsExtra) {
  87358. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  87359. }
  87360. };
  87361. /**
  87362. * Serializes the VertexData
  87363. * @returns a serialized object
  87364. */
  87365. VertexData.prototype.serialize = function () {
  87366. var serializationObject = this.serialize();
  87367. if (this.positions) {
  87368. serializationObject.positions = this.positions;
  87369. }
  87370. if (this.normals) {
  87371. serializationObject.normals = this.normals;
  87372. }
  87373. if (this.tangents) {
  87374. serializationObject.tangents = this.tangents;
  87375. }
  87376. if (this.uvs) {
  87377. serializationObject.uvs = this.uvs;
  87378. }
  87379. if (this.uvs2) {
  87380. serializationObject.uvs2 = this.uvs2;
  87381. }
  87382. if (this.uvs3) {
  87383. serializationObject.uvs3 = this.uvs3;
  87384. }
  87385. if (this.uvs4) {
  87386. serializationObject.uvs4 = this.uvs4;
  87387. }
  87388. if (this.uvs5) {
  87389. serializationObject.uvs5 = this.uvs5;
  87390. }
  87391. if (this.uvs6) {
  87392. serializationObject.uvs6 = this.uvs6;
  87393. }
  87394. if (this.colors) {
  87395. serializationObject.colors = this.colors;
  87396. }
  87397. if (this.matricesIndices) {
  87398. serializationObject.matricesIndices = this.matricesIndices;
  87399. serializationObject.matricesIndices._isExpanded = true;
  87400. }
  87401. if (this.matricesWeights) {
  87402. serializationObject.matricesWeights = this.matricesWeights;
  87403. }
  87404. if (this.matricesIndicesExtra) {
  87405. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  87406. serializationObject.matricesIndicesExtra._isExpanded = true;
  87407. }
  87408. if (this.matricesWeightsExtra) {
  87409. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  87410. }
  87411. serializationObject.indices = this.indices;
  87412. return serializationObject;
  87413. };
  87414. // Statics
  87415. /**
  87416. * Extracts the vertexData from a mesh
  87417. * @param mesh the mesh from which to extract the VertexData
  87418. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87419. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87420. * @returns the object VertexData associated to the passed mesh
  87421. */
  87422. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  87423. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  87424. };
  87425. /**
  87426. * Extracts the vertexData from the geometry
  87427. * @param geometry the geometry from which to extract the VertexData
  87428. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87429. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87430. * @returns the object VertexData associated to the passed mesh
  87431. */
  87432. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  87433. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  87434. };
  87435. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  87436. var result = new VertexData();
  87437. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  87438. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  87439. }
  87440. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  87441. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  87442. }
  87443. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  87444. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  87445. }
  87446. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  87447. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  87448. }
  87449. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  87450. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  87451. }
  87452. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  87453. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  87454. }
  87455. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  87456. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  87457. }
  87458. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  87459. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  87460. }
  87461. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  87462. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  87463. }
  87464. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  87465. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  87466. }
  87467. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  87468. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  87469. }
  87470. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  87471. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  87472. }
  87473. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  87474. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  87475. }
  87476. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87477. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  87478. }
  87479. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  87480. return result;
  87481. };
  87482. /**
  87483. * Creates the VertexData for a Ribbon
  87484. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87485. * * pathArray array of paths, each of which an array of successive Vector3
  87486. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87487. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87488. * * 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
  87489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87490. * * 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)
  87491. * * 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)
  87492. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87493. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87494. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87495. * @returns the VertexData of the ribbon
  87496. */
  87497. VertexData.CreateRibbon = function (options) {
  87498. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  87499. };
  87500. /**
  87501. * Creates the VertexData for a box
  87502. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87503. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87504. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87505. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87506. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87507. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87508. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87509. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87510. * * 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)
  87511. * * 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)
  87512. * @returns the VertexData of the box
  87513. */
  87514. VertexData.CreateBox = function (options) {
  87515. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  87516. };
  87517. /**
  87518. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87519. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87520. * * segments sets the number of horizontal strips optional, default 32
  87521. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87522. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87523. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87524. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87525. * * 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
  87526. * * 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
  87527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87528. * * 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)
  87529. * * 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)
  87530. * @returns the VertexData of the ellipsoid
  87531. */
  87532. VertexData.CreateSphere = function (options) {
  87533. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  87534. };
  87535. /**
  87536. * Creates the VertexData for a cylinder, cone or prism
  87537. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87538. * * height sets the height (y direction) of the cylinder, optional, default 2
  87539. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87540. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87541. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87542. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87543. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87544. * * 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
  87545. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87546. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87547. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87548. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87550. * * 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)
  87551. * * 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)
  87552. * @returns the VertexData of the cylinder, cone or prism
  87553. */
  87554. VertexData.CreateCylinder = function (options) {
  87555. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  87556. };
  87557. /**
  87558. * Creates the VertexData for a torus
  87559. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87560. * * diameter the diameter of the torus, optional default 1
  87561. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87562. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87564. * * 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)
  87565. * * 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)
  87566. * @returns the VertexData of the torus
  87567. */
  87568. VertexData.CreateTorus = function (options) {
  87569. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  87570. };
  87571. /**
  87572. * Creates the VertexData of the LineSystem
  87573. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87574. * - lines an array of lines, each line being an array of successive Vector3
  87575. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87576. * @returns the VertexData of the LineSystem
  87577. */
  87578. VertexData.CreateLineSystem = function (options) {
  87579. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  87580. };
  87581. /**
  87582. * Create the VertexData for a DashedLines
  87583. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87584. * - points an array successive Vector3
  87585. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87586. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87587. * - dashNb the intended total number of dashes, optional, default 200
  87588. * @returns the VertexData for the DashedLines
  87589. */
  87590. VertexData.CreateDashedLines = function (options) {
  87591. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  87592. };
  87593. /**
  87594. * Creates the VertexData for a Ground
  87595. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87596. * - width the width (x direction) of the ground, optional, default 1
  87597. * - height the height (z direction) of the ground, optional, default 1
  87598. * - subdivisions the number of subdivisions per side, optional, default 1
  87599. * @returns the VertexData of the Ground
  87600. */
  87601. VertexData.CreateGround = function (options) {
  87602. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87603. };
  87604. /**
  87605. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87606. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87607. * * xmin the ground minimum X coordinate, optional, default -1
  87608. * * zmin the ground minimum Z coordinate, optional, default -1
  87609. * * xmax the ground maximum X coordinate, optional, default 1
  87610. * * zmax the ground maximum Z coordinate, optional, default 1
  87611. * * 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}
  87612. * * 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}
  87613. * @returns the VertexData of the TiledGround
  87614. */
  87615. VertexData.CreateTiledGround = function (options) {
  87616. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87617. };
  87618. /**
  87619. * Creates the VertexData of the Ground designed from a heightmap
  87620. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87621. * * width the width (x direction) of the ground
  87622. * * height the height (z direction) of the ground
  87623. * * subdivisions the number of subdivisions per side
  87624. * * minHeight the minimum altitude on the ground, optional, default 0
  87625. * * maxHeight the maximum altitude on the ground, optional default 1
  87626. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87627. * * buffer the array holding the image color data
  87628. * * bufferWidth the width of image
  87629. * * bufferHeight the height of image
  87630. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87631. * @returns the VertexData of the Ground designed from a heightmap
  87632. */
  87633. VertexData.CreateGroundFromHeightMap = function (options) {
  87634. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87635. };
  87636. /**
  87637. * Creates the VertexData for a Plane
  87638. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87639. * * size sets the width and height of the plane to the value of size, optional default 1
  87640. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87641. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87643. * * 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)
  87644. * * 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)
  87645. * @returns the VertexData of the box
  87646. */
  87647. VertexData.CreatePlane = function (options) {
  87648. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  87649. };
  87650. /**
  87651. * Creates the VertexData of the Disc or regular Polygon
  87652. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87653. * * radius the radius of the disc, optional default 0.5
  87654. * * tessellation the number of polygon sides, optional, default 64
  87655. * * 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
  87656. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87657. * * 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)
  87658. * * 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)
  87659. * @returns the VertexData of the box
  87660. */
  87661. VertexData.CreateDisc = function (options) {
  87662. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  87663. };
  87664. /**
  87665. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87666. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87667. * @param polygon a mesh built from polygonTriangulation.build()
  87668. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87669. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87670. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87671. * @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)
  87672. * @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)
  87673. * @returns the VertexData of the Polygon
  87674. */
  87675. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  87676. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  87677. };
  87678. /**
  87679. * Creates the VertexData of the IcoSphere
  87680. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87681. * * radius the radius of the IcoSphere, optional default 1
  87682. * * radiusX allows stretching in the x direction, optional, default radius
  87683. * * radiusY allows stretching in the y direction, optional, default radius
  87684. * * radiusZ allows stretching in the z direction, optional, default radius
  87685. * * flat when true creates a flat shaded mesh, optional, default true
  87686. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87687. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87688. * * 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)
  87689. * * 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)
  87690. * @returns the VertexData of the IcoSphere
  87691. */
  87692. VertexData.CreateIcoSphere = function (options) {
  87693. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  87694. };
  87695. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  87696. /**
  87697. * Creates the VertexData for a Polyhedron
  87698. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87699. * * type provided types are:
  87700. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87701. * * 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)
  87702. * * size the size of the IcoSphere, optional default 1
  87703. * * sizeX allows stretching in the x direction, optional, default size
  87704. * * sizeY allows stretching in the y direction, optional, default size
  87705. * * sizeZ allows stretching in the z direction, optional, default size
  87706. * * 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
  87707. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87708. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87709. * * flat when true creates a flat shaded mesh, optional, default true
  87710. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87712. * * 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)
  87713. * * 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)
  87714. * @returns the VertexData of the Polyhedron
  87715. */
  87716. VertexData.CreatePolyhedron = function (options) {
  87717. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  87718. };
  87719. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  87720. /**
  87721. * Creates the VertexData for a TorusKnot
  87722. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87723. * * radius the radius of the torus knot, optional, default 2
  87724. * * tube the thickness of the tube, optional, default 0.5
  87725. * * radialSegments the number of sides on each tube segments, optional, default 32
  87726. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87727. * * p the number of windings around the z axis, optional, default 2
  87728. * * q the number of windings around the x axis, optional, default 3
  87729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87730. * * 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)
  87731. * * 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)
  87732. * @returns the VertexData of the Torus Knot
  87733. */
  87734. VertexData.CreateTorusKnot = function (options) {
  87735. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  87736. };
  87737. // Tools
  87738. /**
  87739. * Compute normals for given positions and indices
  87740. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87741. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87742. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87743. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87744. * * facetNormals : optional array of facet normals (vector3)
  87745. * * facetPositions : optional array of facet positions (vector3)
  87746. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87747. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87748. * * bInfo : optional bounding info, required for facetPartitioning computation
  87749. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87750. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87751. * * useRightHandedSystem: optional boolean to for right handed system computation
  87752. * * depthSort : optional boolean to enable the facet depth sort computation
  87753. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87754. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87755. */
  87756. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  87757. // temporary scalar variables
  87758. var index = 0; // facet index
  87759. var p1p2x = 0.0; // p1p2 vector x coordinate
  87760. var p1p2y = 0.0; // p1p2 vector y coordinate
  87761. var p1p2z = 0.0; // p1p2 vector z coordinate
  87762. var p3p2x = 0.0; // p3p2 vector x coordinate
  87763. var p3p2y = 0.0; // p3p2 vector y coordinate
  87764. var p3p2z = 0.0; // p3p2 vector z coordinate
  87765. var faceNormalx = 0.0; // facet normal x coordinate
  87766. var faceNormaly = 0.0; // facet normal y coordinate
  87767. var faceNormalz = 0.0; // facet normal z coordinate
  87768. var length = 0.0; // facet normal length before normalization
  87769. var v1x = 0; // vector1 x index in the positions array
  87770. var v1y = 0; // vector1 y index in the positions array
  87771. var v1z = 0; // vector1 z index in the positions array
  87772. var v2x = 0; // vector2 x index in the positions array
  87773. var v2y = 0; // vector2 y index in the positions array
  87774. var v2z = 0; // vector2 z index in the positions array
  87775. var v3x = 0; // vector3 x index in the positions array
  87776. var v3y = 0; // vector3 y index in the positions array
  87777. var v3z = 0; // vector3 z index in the positions array
  87778. var computeFacetNormals = false;
  87779. var computeFacetPositions = false;
  87780. var computeFacetPartitioning = false;
  87781. var computeDepthSort = false;
  87782. var faceNormalSign = 1;
  87783. var ratio = 0;
  87784. var distanceTo = null;
  87785. if (options) {
  87786. computeFacetNormals = (options.facetNormals) ? true : false;
  87787. computeFacetPositions = (options.facetPositions) ? true : false;
  87788. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  87789. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  87790. ratio = options.ratio || 0;
  87791. computeDepthSort = (options.depthSort) ? true : false;
  87792. distanceTo = (options.distanceTo);
  87793. if (computeDepthSort) {
  87794. if (distanceTo === undefined) {
  87795. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87796. }
  87797. var depthSortedFacets = options.depthSortedFacets;
  87798. }
  87799. }
  87800. // facetPartitioning reinit if needed
  87801. var xSubRatio = 0;
  87802. var ySubRatio = 0;
  87803. var zSubRatio = 0;
  87804. var subSq = 0;
  87805. if (computeFacetPartitioning && options && options.bbSize) {
  87806. var ox = 0; // X partitioning index for facet position
  87807. var oy = 0; // Y partinioning index for facet position
  87808. var oz = 0; // Z partinioning index for facet position
  87809. var b1x = 0; // X partitioning index for facet v1 vertex
  87810. var b1y = 0; // Y partitioning index for facet v1 vertex
  87811. var b1z = 0; // z partitioning index for facet v1 vertex
  87812. var b2x = 0; // X partitioning index for facet v2 vertex
  87813. var b2y = 0; // Y partitioning index for facet v2 vertex
  87814. var b2z = 0; // Z partitioning index for facet v2 vertex
  87815. var b3x = 0; // X partitioning index for facet v3 vertex
  87816. var b3y = 0; // Y partitioning index for facet v3 vertex
  87817. var b3z = 0; // Z partitioning index for facet v3 vertex
  87818. var block_idx_o = 0; // facet barycenter block index
  87819. var block_idx_v1 = 0; // v1 vertex block index
  87820. var block_idx_v2 = 0; // v2 vertex block index
  87821. var block_idx_v3 = 0; // v3 vertex block index
  87822. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  87823. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  87824. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  87825. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  87826. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  87827. subSq = options.subDiv.max * options.subDiv.max;
  87828. options.facetPartitioning.length = 0;
  87829. }
  87830. // reset the normals
  87831. for (index = 0; index < positions.length; index++) {
  87832. normals[index] = 0.0;
  87833. }
  87834. // Loop : 1 indice triplet = 1 facet
  87835. var nbFaces = (indices.length / 3) | 0;
  87836. for (index = 0; index < nbFaces; index++) {
  87837. // get the indexes of the coordinates of each vertex of the facet
  87838. v1x = indices[index * 3] * 3;
  87839. v1y = v1x + 1;
  87840. v1z = v1x + 2;
  87841. v2x = indices[index * 3 + 1] * 3;
  87842. v2y = v2x + 1;
  87843. v2z = v2x + 2;
  87844. v3x = indices[index * 3 + 2] * 3;
  87845. v3y = v3x + 1;
  87846. v3z = v3x + 2;
  87847. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  87848. p1p2y = positions[v1y] - positions[v2y];
  87849. p1p2z = positions[v1z] - positions[v2z];
  87850. p3p2x = positions[v3x] - positions[v2x];
  87851. p3p2y = positions[v3y] - positions[v2y];
  87852. p3p2z = positions[v3z] - positions[v2z];
  87853. // compute the face normal with the cross product
  87854. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  87855. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  87856. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  87857. // normalize this normal and store it in the array facetData
  87858. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87859. length = (length === 0) ? 1.0 : length;
  87860. faceNormalx /= length;
  87861. faceNormaly /= length;
  87862. faceNormalz /= length;
  87863. if (computeFacetNormals && options) {
  87864. options.facetNormals[index].x = faceNormalx;
  87865. options.facetNormals[index].y = faceNormaly;
  87866. options.facetNormals[index].z = faceNormalz;
  87867. }
  87868. if (computeFacetPositions && options) {
  87869. // compute and the facet barycenter coordinates in the array facetPositions
  87870. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  87871. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  87872. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  87873. }
  87874. if (computeFacetPartitioning && options) {
  87875. // store the facet indexes in arrays in the main facetPartitioning array :
  87876. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  87877. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  87878. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  87879. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  87880. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87881. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87882. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87883. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87884. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87885. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87886. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87887. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87888. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87889. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  87890. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  87891. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  87892. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  87893. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  87894. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  87895. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  87896. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  87897. // push each facet index in each block containing the vertex
  87898. options.facetPartitioning[block_idx_v1].push(index);
  87899. if (block_idx_v2 != block_idx_v1) {
  87900. options.facetPartitioning[block_idx_v2].push(index);
  87901. }
  87902. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  87903. options.facetPartitioning[block_idx_v3].push(index);
  87904. }
  87905. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  87906. options.facetPartitioning[block_idx_o].push(index);
  87907. }
  87908. }
  87909. if (computeDepthSort && options && options.facetPositions) {
  87910. var dsf = depthSortedFacets[index];
  87911. dsf.ind = index * 3;
  87912. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  87913. }
  87914. // compute the normals anyway
  87915. normals[v1x] += faceNormalx; // accumulate all the normals per face
  87916. normals[v1y] += faceNormaly;
  87917. normals[v1z] += faceNormalz;
  87918. normals[v2x] += faceNormalx;
  87919. normals[v2y] += faceNormaly;
  87920. normals[v2z] += faceNormalz;
  87921. normals[v3x] += faceNormalx;
  87922. normals[v3y] += faceNormaly;
  87923. normals[v3z] += faceNormalz;
  87924. }
  87925. // last normalization of each normal
  87926. for (index = 0; index < normals.length / 3; index++) {
  87927. faceNormalx = normals[index * 3];
  87928. faceNormaly = normals[index * 3 + 1];
  87929. faceNormalz = normals[index * 3 + 2];
  87930. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87931. length = (length === 0) ? 1.0 : length;
  87932. faceNormalx /= length;
  87933. faceNormaly /= length;
  87934. faceNormalz /= length;
  87935. normals[index * 3] = faceNormalx;
  87936. normals[index * 3 + 1] = faceNormaly;
  87937. normals[index * 3 + 2] = faceNormalz;
  87938. }
  87939. };
  87940. /** @hidden */
  87941. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  87942. var li = indices.length;
  87943. var ln = normals.length;
  87944. var i;
  87945. var n;
  87946. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  87947. switch (sideOrientation) {
  87948. case VertexData.FRONTSIDE:
  87949. // nothing changed
  87950. break;
  87951. case VertexData.BACKSIDE:
  87952. var tmp;
  87953. // indices
  87954. for (i = 0; i < li; i += 3) {
  87955. tmp = indices[i];
  87956. indices[i] = indices[i + 2];
  87957. indices[i + 2] = tmp;
  87958. }
  87959. // normals
  87960. for (n = 0; n < ln; n++) {
  87961. normals[n] = -normals[n];
  87962. }
  87963. break;
  87964. case VertexData.DOUBLESIDE:
  87965. // positions
  87966. var lp = positions.length;
  87967. var l = lp / 3;
  87968. for (var p = 0; p < lp; p++) {
  87969. positions[lp + p] = positions[p];
  87970. }
  87971. // indices
  87972. for (i = 0; i < li; i += 3) {
  87973. indices[i + li] = indices[i + 2] + l;
  87974. indices[i + 1 + li] = indices[i + 1] + l;
  87975. indices[i + 2 + li] = indices[i] + l;
  87976. }
  87977. // normals
  87978. for (n = 0; n < ln; n++) {
  87979. normals[ln + n] = -normals[n];
  87980. }
  87981. // uvs
  87982. var lu = uvs.length;
  87983. var u = 0;
  87984. for (u = 0; u < lu; u++) {
  87985. uvs[u + lu] = uvs[u];
  87986. }
  87987. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87988. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87989. u = 0;
  87990. for (i = 0; i < lu / 2; i++) {
  87991. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  87992. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  87993. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  87994. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  87995. u += 2;
  87996. }
  87997. break;
  87998. }
  87999. };
  88000. /**
  88001. * Applies VertexData created from the imported parameters to the geometry
  88002. * @param parsedVertexData the parsed data from an imported file
  88003. * @param geometry the geometry to apply the VertexData to
  88004. */
  88005. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  88006. var vertexData = new VertexData();
  88007. // positions
  88008. var positions = parsedVertexData.positions;
  88009. if (positions) {
  88010. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88011. }
  88012. // normals
  88013. var normals = parsedVertexData.normals;
  88014. if (normals) {
  88015. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  88016. }
  88017. // tangents
  88018. var tangents = parsedVertexData.tangents;
  88019. if (tangents) {
  88020. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  88021. }
  88022. // uvs
  88023. var uvs = parsedVertexData.uvs;
  88024. if (uvs) {
  88025. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  88026. }
  88027. // uv2s
  88028. var uv2s = parsedVertexData.uv2s;
  88029. if (uv2s) {
  88030. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  88031. }
  88032. // uv3s
  88033. var uv3s = parsedVertexData.uv3s;
  88034. if (uv3s) {
  88035. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  88036. }
  88037. // uv4s
  88038. var uv4s = parsedVertexData.uv4s;
  88039. if (uv4s) {
  88040. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  88041. }
  88042. // uv5s
  88043. var uv5s = parsedVertexData.uv5s;
  88044. if (uv5s) {
  88045. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  88046. }
  88047. // uv6s
  88048. var uv6s = parsedVertexData.uv6s;
  88049. if (uv6s) {
  88050. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  88051. }
  88052. // colors
  88053. var colors = parsedVertexData.colors;
  88054. if (colors) {
  88055. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  88056. }
  88057. // matricesIndices
  88058. var matricesIndices = parsedVertexData.matricesIndices;
  88059. if (matricesIndices) {
  88060. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  88061. }
  88062. // matricesWeights
  88063. var matricesWeights = parsedVertexData.matricesWeights;
  88064. if (matricesWeights) {
  88065. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  88066. }
  88067. // indices
  88068. var indices = parsedVertexData.indices;
  88069. if (indices) {
  88070. vertexData.indices = indices;
  88071. }
  88072. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  88073. };
  88074. /**
  88075. * Mesh side orientation : usually the external or front surface
  88076. */
  88077. VertexData.FRONTSIDE = 0;
  88078. /**
  88079. * Mesh side orientation : usually the internal or back surface
  88080. */
  88081. VertexData.BACKSIDE = 1;
  88082. /**
  88083. * Mesh side orientation : both internal and external or front and back surfaces
  88084. */
  88085. VertexData.DOUBLESIDE = 2;
  88086. /**
  88087. * Mesh side orientation : by default, `FRONTSIDE`
  88088. */
  88089. VertexData.DEFAULTSIDE = 0;
  88090. return VertexData;
  88091. }());
  88092. /***/ }),
  88093. /***/ "./Meshes/meshBuilder.ts":
  88094. /*!*******************************!*\
  88095. !*** ./Meshes/meshBuilder.ts ***!
  88096. \*******************************/
  88097. /*! exports provided: MeshBuilder */
  88098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88099. "use strict";
  88100. __webpack_require__.r(__webpack_exports__);
  88101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  88102. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  88103. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  88104. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  88105. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  88106. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  88107. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  88108. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  88109. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  88110. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  88111. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  88112. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  88113. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  88114. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  88115. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  88116. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  88117. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  88118. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  88119. /**
  88120. * Class containing static functions to help procedurally build meshes
  88121. */
  88122. var MeshBuilder = /** @class */ (function () {
  88123. function MeshBuilder() {
  88124. }
  88125. /**
  88126. * Creates a box mesh
  88127. * * The parameter `size` sets the size (float) of each box side (default 1)
  88128. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  88129. * * 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)
  88130. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88132. * * 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
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  88135. * @param name defines the name of the mesh
  88136. * @param options defines the options used to create the mesh
  88137. * @param scene defines the hosting scene
  88138. * @returns the box mesh
  88139. */
  88140. MeshBuilder.CreateBox = function (name, options, scene) {
  88141. if (scene === void 0) { scene = null; }
  88142. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  88143. };
  88144. /**
  88145. * Creates a sphere mesh
  88146. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  88147. * * 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`)
  88148. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  88149. * * 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
  88150. * * 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)
  88151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88152. * * 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
  88153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88154. * @param name defines the name of the mesh
  88155. * @param options defines the options used to create the mesh
  88156. * @param scene defines the hosting scene
  88157. * @returns the sphere mesh
  88158. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  88159. */
  88160. MeshBuilder.CreateSphere = function (name, options, scene) {
  88161. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  88162. };
  88163. /**
  88164. * Creates a plane polygonal mesh. By default, this is a disc
  88165. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88166. * * 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
  88167. * * 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
  88168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88169. * * 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
  88170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88171. * @param name defines the name of the mesh
  88172. * @param options defines the options used to create the mesh
  88173. * @param scene defines the hosting scene
  88174. * @returns the plane polygonal mesh
  88175. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88176. */
  88177. MeshBuilder.CreateDisc = function (name, options, scene) {
  88178. if (scene === void 0) { scene = null; }
  88179. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  88180. };
  88181. /**
  88182. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88183. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88184. * * 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`)
  88185. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88186. * * 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
  88187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88188. * * 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
  88189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88190. * @param name defines the name of the mesh
  88191. * @param options defines the options used to create the mesh
  88192. * @param scene defines the hosting scene
  88193. * @returns the icosahedron mesh
  88194. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88195. */
  88196. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  88197. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  88198. };
  88199. /**
  88200. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88201. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  88202. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  88203. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  88204. * * 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
  88205. * * 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
  88206. * * 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
  88207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88208. * * 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
  88209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88210. * * 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
  88211. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  88212. * * 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
  88213. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  88219. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  88220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88221. */
  88222. MeshBuilder.CreateRibbon = function (name, options, scene) {
  88223. if (scene === void 0) { scene = null; }
  88224. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  88225. };
  88226. /**
  88227. * Creates a cylinder or a cone mesh
  88228. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  88229. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  88230. * * 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.
  88231. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  88232. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  88233. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  88234. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  88235. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  88236. * * 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).
  88237. * * 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
  88238. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  88239. * * 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
  88240. * * 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.
  88241. * * If `enclose` is false, a ring surface is one element.
  88242. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  88243. * * 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
  88244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88245. * * 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
  88246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88247. * @param name defines the name of the mesh
  88248. * @param options defines the options used to create the mesh
  88249. * @param scene defines the hosting scene
  88250. * @returns the cylinder mesh
  88251. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  88252. */
  88253. MeshBuilder.CreateCylinder = function (name, options, scene) {
  88254. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  88255. };
  88256. /**
  88257. * Creates a torus mesh
  88258. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  88259. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  88260. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  88261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88262. * * 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
  88263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88264. * @param name defines the name of the mesh
  88265. * @param options defines the options used to create the mesh
  88266. * @param scene defines the hosting scene
  88267. * @returns the torus mesh
  88268. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  88269. */
  88270. MeshBuilder.CreateTorus = function (name, options, scene) {
  88271. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  88272. };
  88273. /**
  88274. * Creates a torus knot mesh
  88275. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  88276. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  88277. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  88278. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  88279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88280. * * 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
  88281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88282. * @param name defines the name of the mesh
  88283. * @param options defines the options used to create the mesh
  88284. * @param scene defines the hosting scene
  88285. * @returns the torus knot mesh
  88286. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  88287. */
  88288. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  88289. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  88290. };
  88291. /**
  88292. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  88293. * * 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
  88294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  88295. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  88296. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  88297. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  88298. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  88299. * * 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
  88300. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  88301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  88303. * @param name defines the name of the new line system
  88304. * @param options defines the options used to create the line system
  88305. * @param scene defines the hosting scene
  88306. * @returns a new line system mesh
  88307. */
  88308. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  88309. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  88310. };
  88311. /**
  88312. * Creates a line mesh
  88313. * 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
  88314. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88315. * * The parameter `points` is an array successive Vector3
  88316. * * 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
  88317. * * The optional parameter `colors` is an array of successive Color4, one per line point
  88318. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  88319. * * When updating an instance, remember that only point positions can change, not the number of points
  88320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  88322. * @param name defines the name of the new line system
  88323. * @param options defines the options used to create the line system
  88324. * @param scene defines the hosting scene
  88325. * @returns a new line mesh
  88326. */
  88327. MeshBuilder.CreateLines = function (name, options, scene) {
  88328. if (scene === void 0) { scene = null; }
  88329. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  88330. };
  88331. /**
  88332. * Creates a dashed line mesh
  88333. * * 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
  88334. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88335. * * The parameter `points` is an array successive Vector3
  88336. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  88337. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  88338. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88339. * * 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
  88340. * * When updating an instance, remember that only point positions can change, not the number of points
  88341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88342. * @param name defines the name of the mesh
  88343. * @param options defines the options used to create the mesh
  88344. * @param scene defines the hosting scene
  88345. * @returns the dashed line mesh
  88346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  88347. */
  88348. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  88349. if (scene === void 0) { scene = null; }
  88350. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  88351. };
  88352. /**
  88353. * 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.
  88354. * * 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.
  88355. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88356. * * 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.
  88357. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  88358. * * 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
  88359. * * 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
  88360. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  88361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88362. * * 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
  88363. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  88364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88365. * @param name defines the name of the mesh
  88366. * @param options defines the options used to create the mesh
  88367. * @param scene defines the hosting scene
  88368. * @returns the extruded shape mesh
  88369. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88371. */
  88372. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  88373. if (scene === void 0) { scene = null; }
  88374. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  88375. };
  88376. /**
  88377. * Creates an custom extruded shape mesh.
  88378. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  88379. * * 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.
  88380. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88381. * * 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
  88382. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  88383. * * 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
  88384. * * It must returns a float value that will be the scale value applied to the shape on each path point
  88385. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88386. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  88387. * * 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
  88388. * * 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
  88389. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  88390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88391. * * 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
  88392. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88394. * @param name defines the name of the mesh
  88395. * @param options defines the options used to create the mesh
  88396. * @param scene defines the hosting scene
  88397. * @returns the custom extruded shape mesh
  88398. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  88399. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88401. */
  88402. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  88403. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  88404. };
  88405. /**
  88406. * Creates lathe mesh.
  88407. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  88408. * * 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
  88409. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  88410. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  88411. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  88412. * * 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
  88413. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  88414. * * 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
  88415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88416. * * 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
  88417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88419. * @param name defines the name of the mesh
  88420. * @param options defines the options used to create the mesh
  88421. * @param scene defines the hosting scene
  88422. * @returns the lathe mesh
  88423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  88424. */
  88425. MeshBuilder.CreateLathe = function (name, options, scene) {
  88426. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  88427. };
  88428. /**
  88429. * Creates a plane mesh
  88430. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  88431. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  88432. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  88433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88434. * * 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
  88435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88436. * @param name defines the name of the mesh
  88437. * @param options defines the options used to create the mesh
  88438. * @param scene defines the hosting scene
  88439. * @returns the plane mesh
  88440. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  88441. */
  88442. MeshBuilder.CreatePlane = function (name, options, scene) {
  88443. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  88444. };
  88445. /**
  88446. * Creates a ground mesh
  88447. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  88448. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  88449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88450. * @param name defines the name of the mesh
  88451. * @param options defines the options used to create the mesh
  88452. * @param scene defines the hosting scene
  88453. * @returns the ground mesh
  88454. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  88455. */
  88456. MeshBuilder.CreateGround = function (name, options, scene) {
  88457. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  88458. };
  88459. /**
  88460. * Creates a tiled ground mesh
  88461. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  88462. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  88463. * * 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
  88464. * * 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
  88465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88466. * @param name defines the name of the mesh
  88467. * @param options defines the options used to create the mesh
  88468. * @param scene defines the hosting scene
  88469. * @returns the tiled ground mesh
  88470. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  88471. */
  88472. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  88473. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  88474. };
  88475. /**
  88476. * Creates a ground mesh from a height map
  88477. * * The parameter `url` sets the URL of the height map image resource.
  88478. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  88479. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  88480. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  88481. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  88482. * * 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.
  88483. * * 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).
  88484. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88486. * @param name defines the name of the mesh
  88487. * @param url defines the url to the height map
  88488. * @param options defines the options used to create the mesh
  88489. * @param scene defines the hosting scene
  88490. * @returns the ground mesh
  88491. * @see https://doc.babylonjs.com/babylon101/height_map
  88492. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  88493. */
  88494. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  88495. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  88496. };
  88497. /**
  88498. * Creates a polygon mesh
  88499. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  88500. * * 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
  88501. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88503. * * 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)
  88504. * * Remember you can only change the shape positions, not their number when updating a polygon
  88505. * @param name defines the name of the mesh
  88506. * @param options defines the options used to create the mesh
  88507. * @param scene defines the hosting scene
  88508. * @param earcutInjection can be used to inject your own earcut reference
  88509. * @returns the polygon mesh
  88510. */
  88511. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  88512. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88513. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  88514. };
  88515. /**
  88516. * Creates an extruded polygon mesh, with depth in the Y direction.
  88517. * * 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)
  88518. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88519. * @param name defines the name of the mesh
  88520. * @param options defines the options used to create the mesh
  88521. * @param scene defines the hosting scene
  88522. * @param earcutInjection can be used to inject your own earcut reference
  88523. * @returns the polygon mesh
  88524. */
  88525. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  88526. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88527. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  88528. };
  88529. /**
  88530. * Creates a tube mesh.
  88531. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88532. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  88533. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  88534. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  88535. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  88536. * * 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)
  88537. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  88538. * * 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
  88539. * * 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
  88540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88541. * * 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
  88542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88544. * @param name defines the name of the mesh
  88545. * @param options defines the options used to create the mesh
  88546. * @param scene defines the hosting scene
  88547. * @returns the tube mesh
  88548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88549. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  88550. */
  88551. MeshBuilder.CreateTube = function (name, options, scene) {
  88552. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  88553. };
  88554. /**
  88555. * Creates a polyhedron mesh
  88556. * * 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
  88557. * * The parameter `size` (positive float, default 1) sets the polygon size
  88558. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88559. * * 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`
  88560. * * 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
  88561. * * 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)`)
  88562. * * 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
  88563. * * 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
  88564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88565. * * 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
  88566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88567. * @param name defines the name of the mesh
  88568. * @param options defines the options used to create the mesh
  88569. * @param scene defines the hosting scene
  88570. * @returns the polyhedron mesh
  88571. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  88572. */
  88573. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  88574. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  88575. };
  88576. /**
  88577. * Creates a decal mesh.
  88578. * 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
  88579. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  88580. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  88581. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  88582. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  88583. * @param name defines the name of the mesh
  88584. * @param sourceMesh defines the mesh where the decal must be applied
  88585. * @param options defines the options used to create the mesh
  88586. * @param scene defines the hosting scene
  88587. * @returns the decal mesh
  88588. * @see https://doc.babylonjs.com/how_to/decals
  88589. */
  88590. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  88591. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  88592. };
  88593. return MeshBuilder;
  88594. }());
  88595. /***/ }),
  88596. /***/ "./Meshes/meshSimplification.ts":
  88597. /*!**************************************!*\
  88598. !*** ./Meshes/meshSimplification.ts ***!
  88599. \**************************************/
  88600. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  88601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88602. "use strict";
  88603. __webpack_require__.r(__webpack_exports__);
  88604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  88605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  88606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  88607. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88608. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88609. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  88610. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88611. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  88612. /**
  88613. * Class used to specify simplification options
  88614. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88615. */
  88616. var SimplificationSettings = /** @class */ (function () {
  88617. /**
  88618. * Creates a SimplificationSettings
  88619. * @param quality expected quality
  88620. * @param distance distance when this optimized version should be used
  88621. * @param optimizeMesh already optimized mesh
  88622. */
  88623. function SimplificationSettings(
  88624. /** expected quality */
  88625. quality,
  88626. /** distance when this optimized version should be used */
  88627. distance,
  88628. /** already optimized mesh */
  88629. optimizeMesh) {
  88630. this.quality = quality;
  88631. this.distance = distance;
  88632. this.optimizeMesh = optimizeMesh;
  88633. }
  88634. return SimplificationSettings;
  88635. }());
  88636. /**
  88637. * Queue used to order the simplification tasks
  88638. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88639. */
  88640. var SimplificationQueue = /** @class */ (function () {
  88641. /**
  88642. * Creates a new queue
  88643. */
  88644. function SimplificationQueue() {
  88645. this.running = false;
  88646. this._simplificationArray = [];
  88647. }
  88648. /**
  88649. * Adds a new simplification task
  88650. * @param task defines a task to add
  88651. */
  88652. SimplificationQueue.prototype.addTask = function (task) {
  88653. this._simplificationArray.push(task);
  88654. };
  88655. /**
  88656. * Execute next task
  88657. */
  88658. SimplificationQueue.prototype.executeNext = function () {
  88659. var task = this._simplificationArray.pop();
  88660. if (task) {
  88661. this.running = true;
  88662. this.runSimplification(task);
  88663. }
  88664. else {
  88665. this.running = false;
  88666. }
  88667. };
  88668. /**
  88669. * Execute a simplification task
  88670. * @param task defines the task to run
  88671. */
  88672. SimplificationQueue.prototype.runSimplification = function (task) {
  88673. var _this = this;
  88674. if (task.parallelProcessing) {
  88675. //parallel simplifier
  88676. task.settings.forEach(function (setting) {
  88677. var simplifier = _this.getSimplifier(task);
  88678. simplifier.simplify(setting, function (newMesh) {
  88679. task.mesh.addLODLevel(setting.distance, newMesh);
  88680. newMesh.isVisible = true;
  88681. //check if it is the last
  88682. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  88683. //all done, run the success callback.
  88684. task.successCallback();
  88685. }
  88686. _this.executeNext();
  88687. });
  88688. });
  88689. }
  88690. else {
  88691. //single simplifier.
  88692. var simplifier = this.getSimplifier(task);
  88693. var runDecimation = function (setting, callback) {
  88694. simplifier.simplify(setting, function (newMesh) {
  88695. task.mesh.addLODLevel(setting.distance, newMesh);
  88696. newMesh.isVisible = true;
  88697. //run the next quality level
  88698. callback();
  88699. });
  88700. };
  88701. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  88702. runDecimation(task.settings[loop.index], function () {
  88703. loop.executeNext();
  88704. });
  88705. }, function () {
  88706. //execution ended, run the success callback.
  88707. if (task.successCallback) {
  88708. task.successCallback();
  88709. }
  88710. _this.executeNext();
  88711. });
  88712. }
  88713. };
  88714. SimplificationQueue.prototype.getSimplifier = function (task) {
  88715. switch (task.simplificationType) {
  88716. case SimplificationType.QUADRATIC:
  88717. default:
  88718. return new QuadraticErrorSimplification(task.mesh);
  88719. }
  88720. };
  88721. return SimplificationQueue;
  88722. }());
  88723. /**
  88724. * The implemented types of simplification
  88725. * At the moment only Quadratic Error Decimation is implemented
  88726. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88727. */
  88728. var SimplificationType;
  88729. (function (SimplificationType) {
  88730. /** Quadratic error decimation */
  88731. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  88732. })(SimplificationType || (SimplificationType = {}));
  88733. var DecimationTriangle = /** @class */ (function () {
  88734. function DecimationTriangle(vertices) {
  88735. this.vertices = vertices;
  88736. this.error = new Array(4);
  88737. this.deleted = false;
  88738. this.isDirty = false;
  88739. this.deletePending = false;
  88740. this.borderFactor = 0;
  88741. }
  88742. return DecimationTriangle;
  88743. }());
  88744. var DecimationVertex = /** @class */ (function () {
  88745. function DecimationVertex(position, id) {
  88746. this.position = position;
  88747. this.id = id;
  88748. this.isBorder = true;
  88749. this.q = new QuadraticMatrix();
  88750. this.triangleCount = 0;
  88751. this.triangleStart = 0;
  88752. this.originalOffsets = [];
  88753. }
  88754. DecimationVertex.prototype.updatePosition = function (newPosition) {
  88755. this.position.copyFrom(newPosition);
  88756. };
  88757. return DecimationVertex;
  88758. }());
  88759. var QuadraticMatrix = /** @class */ (function () {
  88760. function QuadraticMatrix(data) {
  88761. this.data = new Array(10);
  88762. for (var i = 0; i < 10; ++i) {
  88763. if (data && data[i]) {
  88764. this.data[i] = data[i];
  88765. }
  88766. else {
  88767. this.data[i] = 0;
  88768. }
  88769. }
  88770. }
  88771. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  88772. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  88773. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  88774. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  88775. return det;
  88776. };
  88777. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  88778. for (var i = 0; i < 10; ++i) {
  88779. this.data[i] += matrix.data[i];
  88780. }
  88781. };
  88782. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  88783. for (var i = 0; i < 10; ++i) {
  88784. this.data[i] += data[i];
  88785. }
  88786. };
  88787. QuadraticMatrix.prototype.add = function (matrix) {
  88788. var m = new QuadraticMatrix();
  88789. for (var i = 0; i < 10; ++i) {
  88790. m.data[i] = this.data[i] + matrix.data[i];
  88791. }
  88792. return m;
  88793. };
  88794. QuadraticMatrix.FromData = function (a, b, c, d) {
  88795. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  88796. };
  88797. //returning an array to avoid garbage collection
  88798. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  88799. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  88800. };
  88801. return QuadraticMatrix;
  88802. }());
  88803. var Reference = /** @class */ (function () {
  88804. function Reference(vertexId, triangleId) {
  88805. this.vertexId = vertexId;
  88806. this.triangleId = triangleId;
  88807. }
  88808. return Reference;
  88809. }());
  88810. /**
  88811. * An implementation of the Quadratic Error simplification algorithm.
  88812. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  88813. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  88814. * @author RaananW
  88815. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88816. */
  88817. var QuadraticErrorSimplification = /** @class */ (function () {
  88818. function QuadraticErrorSimplification(_mesh) {
  88819. this._mesh = _mesh;
  88820. this.syncIterations = 5000;
  88821. this.aggressiveness = 7;
  88822. this.decimationIterations = 100;
  88823. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  88824. }
  88825. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  88826. var _this = this;
  88827. this.initDecimatedMesh();
  88828. //iterating through the submeshes array, one after the other.
  88829. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  88830. _this.initWithMesh(loop.index, function () {
  88831. _this.runDecimation(settings, loop.index, function () {
  88832. loop.executeNext();
  88833. });
  88834. }, settings.optimizeMesh);
  88835. }, function () {
  88836. setTimeout(function () {
  88837. successCallback(_this._reconstructedMesh);
  88838. }, 0);
  88839. });
  88840. };
  88841. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  88842. var _this = this;
  88843. var targetCount = ~~(this.triangles.length * settings.quality);
  88844. var deletedTriangles = 0;
  88845. var triangleCount = this.triangles.length;
  88846. var iterationFunction = function (iteration, callback) {
  88847. setTimeout(function () {
  88848. if (iteration % 5 === 0) {
  88849. _this.updateMesh(iteration === 0);
  88850. }
  88851. for (var i = 0; i < _this.triangles.length; ++i) {
  88852. _this.triangles[i].isDirty = false;
  88853. }
  88854. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  88855. var trianglesIterator = function (i) {
  88856. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  88857. var t = _this.triangles[tIdx];
  88858. if (!t) {
  88859. return;
  88860. }
  88861. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  88862. return;
  88863. }
  88864. for (var j = 0; j < 3; ++j) {
  88865. if (t.error[j] < threshold) {
  88866. var deleted0 = [];
  88867. var deleted1 = [];
  88868. var v0 = t.vertices[j];
  88869. var v1 = t.vertices[(j + 1) % 3];
  88870. if (v0.isBorder || v1.isBorder) {
  88871. continue;
  88872. }
  88873. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88874. // var n = Vector3.Zero();
  88875. // var uv = Vector2.Zero();
  88876. // var color = new Color4(0, 0, 0, 1);
  88877. _this.calculateError(v0, v1, p);
  88878. var delTr = new Array();
  88879. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  88880. continue;
  88881. }
  88882. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  88883. continue;
  88884. }
  88885. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  88886. continue;
  88887. }
  88888. var uniqueArray = new Array();
  88889. delTr.forEach(function (deletedT) {
  88890. if (uniqueArray.indexOf(deletedT) === -1) {
  88891. deletedT.deletePending = true;
  88892. uniqueArray.push(deletedT);
  88893. }
  88894. });
  88895. if (uniqueArray.length % 2 !== 0) {
  88896. continue;
  88897. }
  88898. v0.q = v1.q.add(v0.q);
  88899. v0.updatePosition(p);
  88900. var tStart = _this.references.length;
  88901. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  88902. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  88903. var tCount = _this.references.length - tStart;
  88904. if (tCount <= v0.triangleCount) {
  88905. if (tCount) {
  88906. for (var c = 0; c < tCount; c++) {
  88907. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  88908. }
  88909. }
  88910. }
  88911. else {
  88912. v0.triangleStart = tStart;
  88913. }
  88914. v0.triangleCount = tCount;
  88915. break;
  88916. }
  88917. }
  88918. };
  88919. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  88920. }, 0);
  88921. };
  88922. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  88923. if (triangleCount - deletedTriangles <= targetCount) {
  88924. loop.breakLoop();
  88925. }
  88926. else {
  88927. iterationFunction(loop.index, function () {
  88928. loop.executeNext();
  88929. });
  88930. }
  88931. }, function () {
  88932. setTimeout(function () {
  88933. //reconstruct this part of the mesh
  88934. _this.reconstructMesh(submeshIndex);
  88935. successCallback();
  88936. }, 0);
  88937. });
  88938. };
  88939. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  88940. var _this = this;
  88941. this.vertices = [];
  88942. this.triangles = [];
  88943. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88944. var indices = this._mesh.getIndices();
  88945. var submesh = this._mesh.subMeshes[submeshIndex];
  88946. var findInVertices = function (positionToSearch) {
  88947. if (optimizeMesh) {
  88948. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  88949. if (_this.vertices[ii].position.equals(positionToSearch)) {
  88950. return _this.vertices[ii];
  88951. }
  88952. }
  88953. }
  88954. return null;
  88955. };
  88956. var vertexReferences = [];
  88957. var vertexInit = function (i) {
  88958. if (!positionData) {
  88959. return;
  88960. }
  88961. var offset = i + submesh.verticesStart;
  88962. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  88963. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  88964. vertex.originalOffsets.push(offset);
  88965. if (vertex.id === _this.vertices.length) {
  88966. _this.vertices.push(vertex);
  88967. }
  88968. vertexReferences.push(vertex.id);
  88969. };
  88970. //var totalVertices = mesh.getTotalVertices();
  88971. var totalVertices = submesh.verticesCount;
  88972. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  88973. var indicesInit = function (i) {
  88974. if (!indices) {
  88975. return;
  88976. }
  88977. var offset = (submesh.indexStart / 3) + i;
  88978. var pos = (offset * 3);
  88979. var i0 = indices[pos + 0];
  88980. var i1 = indices[pos + 1];
  88981. var i2 = indices[pos + 2];
  88982. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  88983. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  88984. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  88985. var triangle = new DecimationTriangle([v0, v1, v2]);
  88986. triangle.originalOffset = pos;
  88987. _this.triangles.push(triangle);
  88988. };
  88989. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  88990. _this.init(callback);
  88991. });
  88992. });
  88993. };
  88994. QuadraticErrorSimplification.prototype.init = function (callback) {
  88995. var _this = this;
  88996. var triangleInit1 = function (i) {
  88997. var t = _this.triangles[i];
  88998. 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();
  88999. for (var j = 0; j < 3; j++) {
  89000. 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))));
  89001. }
  89002. };
  89003. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  89004. var triangleInit2 = function (i) {
  89005. var t = _this.triangles[i];
  89006. for (var j = 0; j < 3; ++j) {
  89007. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  89008. }
  89009. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  89010. };
  89011. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  89012. callback();
  89013. });
  89014. });
  89015. };
  89016. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  89017. var newTriangles = [];
  89018. var i;
  89019. for (i = 0; i < this.vertices.length; ++i) {
  89020. this.vertices[i].triangleCount = 0;
  89021. }
  89022. var t;
  89023. var j;
  89024. for (i = 0; i < this.triangles.length; ++i) {
  89025. if (!this.triangles[i].deleted) {
  89026. t = this.triangles[i];
  89027. for (j = 0; j < 3; ++j) {
  89028. t.vertices[j].triangleCount = 1;
  89029. }
  89030. newTriangles.push(t);
  89031. }
  89032. }
  89033. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  89034. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  89035. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  89036. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  89037. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  89038. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  89039. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  89040. var vertexCount = 0;
  89041. for (i = 0; i < this.vertices.length; ++i) {
  89042. var vertex = this.vertices[i];
  89043. vertex.id = vertexCount;
  89044. if (vertex.triangleCount) {
  89045. vertex.originalOffsets.forEach(function (originalOffset) {
  89046. if (!normalData) {
  89047. return;
  89048. }
  89049. newPositionData.push(vertex.position.x);
  89050. newPositionData.push(vertex.position.y);
  89051. newPositionData.push(vertex.position.z);
  89052. newNormalData.push(normalData[originalOffset * 3]);
  89053. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  89054. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  89055. if (uvs && uvs.length) {
  89056. newUVsData.push(uvs[(originalOffset * 2)]);
  89057. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  89058. }
  89059. else if (colorsData && colorsData.length) {
  89060. newColorsData.push(colorsData[(originalOffset * 4)]);
  89061. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  89062. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  89063. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  89064. }
  89065. ++vertexCount;
  89066. });
  89067. }
  89068. }
  89069. var startingIndex = this._reconstructedMesh.getTotalIndices();
  89070. var startingVertex = this._reconstructedMesh.getTotalVertices();
  89071. var submeshesArray = this._reconstructedMesh.subMeshes;
  89072. this._reconstructedMesh.subMeshes = [];
  89073. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  89074. var originalIndices = this._mesh.getIndices();
  89075. for (i = 0; i < newTriangles.length; ++i) {
  89076. t = newTriangles[i]; //now get the new referencing point for each vertex
  89077. [0, 1, 2].forEach(function (idx) {
  89078. var id = originalIndices[t.originalOffset + idx];
  89079. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  89080. if (offset < 0) {
  89081. offset = 0;
  89082. }
  89083. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  89084. });
  89085. }
  89086. //overwriting the old vertex buffers and indices.
  89087. this._reconstructedMesh.setIndices(newIndicesArray);
  89088. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  89089. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  89090. if (newUVsData.length > 0) {
  89091. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  89092. }
  89093. if (newColorsData.length > 0) {
  89094. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  89095. }
  89096. //create submesh
  89097. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  89098. if (submeshIndex > 0) {
  89099. this._reconstructedMesh.subMeshes = [];
  89100. submeshesArray.forEach(function (submesh) {
  89101. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  89102. });
  89103. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  89104. }
  89105. };
  89106. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  89107. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  89108. this._reconstructedMesh.material = this._mesh.material;
  89109. this._reconstructedMesh.parent = this._mesh.parent;
  89110. this._reconstructedMesh.isVisible = false;
  89111. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  89112. };
  89113. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  89114. for (var i = 0; i < vertex1.triangleCount; ++i) {
  89115. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  89116. if (t.deleted) {
  89117. continue;
  89118. }
  89119. var s = this.references[vertex1.triangleStart + i].vertexId;
  89120. var v1 = t.vertices[(s + 1) % 3];
  89121. var v2 = t.vertices[(s + 2) % 3];
  89122. if ((v1 === vertex2 || v2 === vertex2)) {
  89123. deletedArray[i] = true;
  89124. delTr.push(t);
  89125. continue;
  89126. }
  89127. var d1 = v1.position.subtract(point);
  89128. d1 = d1.normalize();
  89129. var d2 = v2.position.subtract(point);
  89130. d2 = d2.normalize();
  89131. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  89132. return true;
  89133. }
  89134. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  89135. deletedArray[i] = false;
  89136. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  89137. return true;
  89138. }
  89139. }
  89140. return false;
  89141. };
  89142. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  89143. var newDeleted = deletedTriangles;
  89144. for (var i = 0; i < vertex.triangleCount; ++i) {
  89145. var ref = this.references[vertex.triangleStart + i];
  89146. var t = this.triangles[ref.triangleId];
  89147. if (t.deleted) {
  89148. continue;
  89149. }
  89150. if (deletedArray[i] && t.deletePending) {
  89151. t.deleted = true;
  89152. newDeleted++;
  89153. continue;
  89154. }
  89155. t.vertices[ref.vertexId] = origVertex;
  89156. t.isDirty = true;
  89157. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  89158. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  89159. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  89160. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  89161. this.references.push(ref);
  89162. }
  89163. return newDeleted;
  89164. };
  89165. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  89166. for (var i = 0; i < this.vertices.length; ++i) {
  89167. var vCount = [];
  89168. var vId = [];
  89169. var v = this.vertices[i];
  89170. var j;
  89171. for (j = 0; j < v.triangleCount; ++j) {
  89172. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  89173. for (var ii = 0; ii < 3; ii++) {
  89174. var ofs = 0;
  89175. var vv = triangle.vertices[ii];
  89176. while (ofs < vCount.length) {
  89177. if (vId[ofs] === vv.id) {
  89178. break;
  89179. }
  89180. ++ofs;
  89181. }
  89182. if (ofs === vCount.length) {
  89183. vCount.push(1);
  89184. vId.push(vv.id);
  89185. }
  89186. else {
  89187. vCount[ofs]++;
  89188. }
  89189. }
  89190. }
  89191. for (j = 0; j < vCount.length; ++j) {
  89192. if (vCount[j] === 1) {
  89193. this.vertices[vId[j]].isBorder = true;
  89194. }
  89195. else {
  89196. this.vertices[vId[j]].isBorder = false;
  89197. }
  89198. }
  89199. }
  89200. };
  89201. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  89202. if (identifyBorders === void 0) { identifyBorders = false; }
  89203. var i;
  89204. if (!identifyBorders) {
  89205. var newTrianglesVector = [];
  89206. for (i = 0; i < this.triangles.length; ++i) {
  89207. if (!this.triangles[i].deleted) {
  89208. newTrianglesVector.push(this.triangles[i]);
  89209. }
  89210. }
  89211. this.triangles = newTrianglesVector;
  89212. }
  89213. for (i = 0; i < this.vertices.length; ++i) {
  89214. this.vertices[i].triangleCount = 0;
  89215. this.vertices[i].triangleStart = 0;
  89216. }
  89217. var t;
  89218. var j;
  89219. var v;
  89220. for (i = 0; i < this.triangles.length; ++i) {
  89221. t = this.triangles[i];
  89222. for (j = 0; j < 3; ++j) {
  89223. v = t.vertices[j];
  89224. v.triangleCount++;
  89225. }
  89226. }
  89227. var tStart = 0;
  89228. for (i = 0; i < this.vertices.length; ++i) {
  89229. this.vertices[i].triangleStart = tStart;
  89230. tStart += this.vertices[i].triangleCount;
  89231. this.vertices[i].triangleCount = 0;
  89232. }
  89233. var newReferences = new Array(this.triangles.length * 3);
  89234. for (i = 0; i < this.triangles.length; ++i) {
  89235. t = this.triangles[i];
  89236. for (j = 0; j < 3; ++j) {
  89237. v = t.vertices[j];
  89238. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  89239. v.triangleCount++;
  89240. }
  89241. }
  89242. this.references = newReferences;
  89243. if (identifyBorders) {
  89244. this.identifyBorder();
  89245. }
  89246. };
  89247. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  89248. var x = point.x;
  89249. var y = point.y;
  89250. var z = point.z;
  89251. 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
  89252. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  89253. };
  89254. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  89255. var q = vertex1.q.add(vertex2.q);
  89256. var border = vertex1.isBorder && vertex2.isBorder;
  89257. var error = 0;
  89258. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  89259. if (qDet !== 0 && !border) {
  89260. if (!pointResult) {
  89261. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89262. }
  89263. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  89264. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  89265. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  89266. error = this.vertexError(q, pointResult);
  89267. }
  89268. else {
  89269. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  89270. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  89271. var error1 = this.vertexError(q, vertex1.position);
  89272. var error2 = this.vertexError(q, vertex2.position);
  89273. var error3 = this.vertexError(q, p3);
  89274. error = Math.min(error1, error2, error3);
  89275. if (error === error1) {
  89276. if (pointResult) {
  89277. pointResult.copyFrom(vertex1.position);
  89278. }
  89279. }
  89280. else if (error === error2) {
  89281. if (pointResult) {
  89282. pointResult.copyFrom(vertex2.position);
  89283. }
  89284. }
  89285. else {
  89286. if (pointResult) {
  89287. pointResult.copyFrom(p3);
  89288. }
  89289. }
  89290. }
  89291. return error;
  89292. };
  89293. return QuadraticErrorSimplification;
  89294. }());
  89295. /***/ }),
  89296. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  89297. /*!****************************************************!*\
  89298. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  89299. \****************************************************/
  89300. /*! exports provided: SimplicationQueueSceneComponent */
  89301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89302. "use strict";
  89303. __webpack_require__.r(__webpack_exports__);
  89304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  89305. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  89306. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  89307. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  89308. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  89309. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  89310. get: function () {
  89311. if (!this._simplificationQueue) {
  89312. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  89313. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  89314. if (!component) {
  89315. component = new SimplicationQueueSceneComponent(this);
  89316. this._addComponent(component);
  89317. }
  89318. }
  89319. return this._simplificationQueue;
  89320. },
  89321. set: function (value) {
  89322. this._simplificationQueue = value;
  89323. },
  89324. enumerable: true,
  89325. configurable: true
  89326. });
  89327. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  89328. if (parallelProcessing === void 0) { parallelProcessing = true; }
  89329. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  89330. this.getScene().simplificationQueue.addTask({
  89331. settings: settings,
  89332. parallelProcessing: parallelProcessing,
  89333. mesh: this,
  89334. simplificationType: simplificationType,
  89335. successCallback: successCallback
  89336. });
  89337. return this;
  89338. };
  89339. /**
  89340. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  89341. * created in a scene
  89342. */
  89343. var SimplicationQueueSceneComponent = /** @class */ (function () {
  89344. /**
  89345. * Creates a new instance of the component for the given scene
  89346. * @param scene Defines the scene to register the component in
  89347. */
  89348. function SimplicationQueueSceneComponent(scene) {
  89349. /**
  89350. * The component name helpfull to identify the component in the list of scene components.
  89351. */
  89352. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  89353. this.scene = scene;
  89354. }
  89355. /**
  89356. * Registers the component in a given scene
  89357. */
  89358. SimplicationQueueSceneComponent.prototype.register = function () {
  89359. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  89360. };
  89361. /**
  89362. * Rebuilds the elements related to this component in case of
  89363. * context lost for instance.
  89364. */
  89365. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  89366. // Nothing to do for this component
  89367. };
  89368. /**
  89369. * Disposes the component and the associated ressources
  89370. */
  89371. SimplicationQueueSceneComponent.prototype.dispose = function () {
  89372. // Nothing to do for this component
  89373. };
  89374. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  89375. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  89376. this.scene._simplificationQueue.executeNext();
  89377. }
  89378. };
  89379. return SimplicationQueueSceneComponent;
  89380. }());
  89381. /***/ }),
  89382. /***/ "./Meshes/polygonMesh.ts":
  89383. /*!*******************************!*\
  89384. !*** ./Meshes/polygonMesh.ts ***!
  89385. \*******************************/
  89386. /*! exports provided: Polygon, PolygonMeshBuilder */
  89387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89388. "use strict";
  89389. __webpack_require__.r(__webpack_exports__);
  89390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  89391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  89392. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89393. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  89394. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89395. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89396. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89397. /**
  89398. * Vector2 wth index property
  89399. */
  89400. var IndexedVector2 = /** @class */ (function (_super) {
  89401. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  89402. function IndexedVector2(original,
  89403. /** Index of the vector2 */
  89404. index) {
  89405. var _this = _super.call(this, original.x, original.y) || this;
  89406. _this.index = index;
  89407. return _this;
  89408. }
  89409. return IndexedVector2;
  89410. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  89411. /**
  89412. * Defines points to create a polygon
  89413. */
  89414. var PolygonPoints = /** @class */ (function () {
  89415. function PolygonPoints() {
  89416. this.elements = new Array();
  89417. }
  89418. PolygonPoints.prototype.add = function (originalPoints) {
  89419. var _this = this;
  89420. var result = new Array();
  89421. originalPoints.forEach(function (point) {
  89422. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  89423. var newPoint = new IndexedVector2(point, _this.elements.length);
  89424. result.push(newPoint);
  89425. _this.elements.push(newPoint);
  89426. }
  89427. });
  89428. return result;
  89429. };
  89430. PolygonPoints.prototype.computeBounds = function () {
  89431. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89432. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89433. this.elements.forEach(function (point) {
  89434. // x
  89435. if (point.x < lmin.x) {
  89436. lmin.x = point.x;
  89437. }
  89438. else if (point.x > lmax.x) {
  89439. lmax.x = point.x;
  89440. }
  89441. // y
  89442. if (point.y < lmin.y) {
  89443. lmin.y = point.y;
  89444. }
  89445. else if (point.y > lmax.y) {
  89446. lmax.y = point.y;
  89447. }
  89448. });
  89449. return {
  89450. min: lmin,
  89451. max: lmax,
  89452. width: lmax.x - lmin.x,
  89453. height: lmax.y - lmin.y
  89454. };
  89455. };
  89456. return PolygonPoints;
  89457. }());
  89458. /**
  89459. * Polygon
  89460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89461. */
  89462. var Polygon = /** @class */ (function () {
  89463. function Polygon() {
  89464. }
  89465. /**
  89466. * Creates a rectangle
  89467. * @param xmin bottom X coord
  89468. * @param ymin bottom Y coord
  89469. * @param xmax top X coord
  89470. * @param ymax top Y coord
  89471. * @returns points that make the resulting rectation
  89472. */
  89473. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  89474. return [
  89475. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  89476. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  89477. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  89478. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  89479. ];
  89480. };
  89481. /**
  89482. * Creates a circle
  89483. * @param radius radius of circle
  89484. * @param cx scale in x
  89485. * @param cy scale in y
  89486. * @param numberOfSides number of sides that make up the circle
  89487. * @returns points that make the resulting circle
  89488. */
  89489. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  89490. if (cx === void 0) { cx = 0; }
  89491. if (cy === void 0) { cy = 0; }
  89492. if (numberOfSides === void 0) { numberOfSides = 32; }
  89493. var result = new Array();
  89494. var angle = 0;
  89495. var increment = (Math.PI * 2) / numberOfSides;
  89496. for (var i = 0; i < numberOfSides; i++) {
  89497. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  89498. angle -= increment;
  89499. }
  89500. return result;
  89501. };
  89502. /**
  89503. * Creates a polygon from input string
  89504. * @param input Input polygon data
  89505. * @returns the parsed points
  89506. */
  89507. Polygon.Parse = function (input) {
  89508. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  89509. var i, result = [];
  89510. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  89511. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  89512. }
  89513. return result;
  89514. };
  89515. /**
  89516. * Starts building a polygon from x and y coordinates
  89517. * @param x x coordinate
  89518. * @param y y coordinate
  89519. * @returns the started path2
  89520. */
  89521. Polygon.StartingAt = function (x, y) {
  89522. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  89523. };
  89524. return Polygon;
  89525. }());
  89526. /**
  89527. * Builds a polygon
  89528. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  89529. */
  89530. var PolygonMeshBuilder = /** @class */ (function () {
  89531. /**
  89532. * Creates a PolygonMeshBuilder
  89533. * @param name name of the builder
  89534. * @param contours Path of the polygon
  89535. * @param scene scene to add to
  89536. * @param earcutInjection can be used to inject your own earcut reference
  89537. */
  89538. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  89539. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89540. this._points = new PolygonPoints();
  89541. this._outlinepoints = new PolygonPoints();
  89542. this._holes = new Array();
  89543. this._epoints = new Array();
  89544. this._eholes = new Array();
  89545. this.bjsEarcut = earcutInjection;
  89546. this._name = name;
  89547. this._scene = scene;
  89548. var points;
  89549. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  89550. points = contours.getPoints();
  89551. }
  89552. else {
  89553. points = contours;
  89554. }
  89555. this._addToepoint(points);
  89556. this._points.add(points);
  89557. this._outlinepoints.add(points);
  89558. if (typeof this.bjsEarcut === 'undefined') {
  89559. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  89560. }
  89561. }
  89562. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  89563. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  89564. var p = points_1[_i];
  89565. this._epoints.push(p.x, p.y);
  89566. }
  89567. };
  89568. /**
  89569. * Adds a whole within the polygon
  89570. * @param hole Array of points defining the hole
  89571. * @returns this
  89572. */
  89573. PolygonMeshBuilder.prototype.addHole = function (hole) {
  89574. this._points.add(hole);
  89575. var holepoints = new PolygonPoints();
  89576. holepoints.add(hole);
  89577. this._holes.push(holepoints);
  89578. this._eholes.push(this._epoints.length / 2);
  89579. this._addToepoint(hole);
  89580. return this;
  89581. };
  89582. /**
  89583. * Creates the polygon
  89584. * @param updatable If the mesh should be updatable
  89585. * @param depth The depth of the mesh created
  89586. * @returns the created mesh
  89587. */
  89588. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  89589. var _this = this;
  89590. if (updatable === void 0) { updatable = false; }
  89591. if (depth === void 0) { depth = 0; }
  89592. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  89593. var normals = new Array();
  89594. var positions = new Array();
  89595. var uvs = new Array();
  89596. var bounds = this._points.computeBounds();
  89597. this._points.elements.forEach(function (p) {
  89598. normals.push(0, 1.0, 0);
  89599. positions.push(p.x, 0, p.y);
  89600. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  89601. });
  89602. var indices = new Array();
  89603. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  89604. for (var i = 0; i < res.length; i++) {
  89605. indices.push(res[i]);
  89606. }
  89607. if (depth > 0) {
  89608. var positionscount = (positions.length / 3); //get the current pointcount
  89609. this._points.elements.forEach(function (p) {
  89610. normals.push(0, -1.0, 0);
  89611. positions.push(p.x, -depth, p.y);
  89612. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  89613. });
  89614. var totalCount = indices.length;
  89615. for (var i = 0; i < totalCount; i += 3) {
  89616. var i0 = indices[i + 0];
  89617. var i1 = indices[i + 1];
  89618. var i2 = indices[i + 2];
  89619. indices.push(i2 + positionscount);
  89620. indices.push(i1 + positionscount);
  89621. indices.push(i0 + positionscount);
  89622. }
  89623. //Add the sides
  89624. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  89625. this._holes.forEach(function (hole) {
  89626. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  89627. });
  89628. }
  89629. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  89630. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  89631. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  89632. result.setIndices(indices);
  89633. return result;
  89634. };
  89635. /**
  89636. * Adds a side to the polygon
  89637. * @param positions points that make the polygon
  89638. * @param normals normals of the polygon
  89639. * @param uvs uvs of the polygon
  89640. * @param indices indices of the polygon
  89641. * @param bounds bounds of the polygon
  89642. * @param points points of the polygon
  89643. * @param depth depth of the polygon
  89644. * @param flip flip of the polygon
  89645. */
  89646. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  89647. var StartIndex = positions.length / 3;
  89648. var ulength = 0;
  89649. for (var i = 0; i < points.elements.length; i++) {
  89650. var p = points.elements[i];
  89651. var p1;
  89652. if ((i + 1) > points.elements.length - 1) {
  89653. p1 = points.elements[0];
  89654. }
  89655. else {
  89656. p1 = points.elements[i + 1];
  89657. }
  89658. positions.push(p.x, 0, p.y);
  89659. positions.push(p.x, -depth, p.y);
  89660. positions.push(p1.x, 0, p1.y);
  89661. positions.push(p1.x, -depth, p1.y);
  89662. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  89663. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  89664. var v3 = v2.subtract(v1);
  89665. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  89666. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  89667. vn = vn.normalize();
  89668. uvs.push(ulength / bounds.width, 0);
  89669. uvs.push(ulength / bounds.width, 1);
  89670. ulength += v3.length();
  89671. uvs.push((ulength / bounds.width), 0);
  89672. uvs.push((ulength / bounds.width), 1);
  89673. if (!flip) {
  89674. normals.push(-vn.x, -vn.y, -vn.z);
  89675. normals.push(-vn.x, -vn.y, -vn.z);
  89676. normals.push(-vn.x, -vn.y, -vn.z);
  89677. normals.push(-vn.x, -vn.y, -vn.z);
  89678. indices.push(StartIndex);
  89679. indices.push(StartIndex + 1);
  89680. indices.push(StartIndex + 2);
  89681. indices.push(StartIndex + 1);
  89682. indices.push(StartIndex + 3);
  89683. indices.push(StartIndex + 2);
  89684. }
  89685. else {
  89686. normals.push(vn.x, vn.y, vn.z);
  89687. normals.push(vn.x, vn.y, vn.z);
  89688. normals.push(vn.x, vn.y, vn.z);
  89689. normals.push(vn.x, vn.y, vn.z);
  89690. indices.push(StartIndex);
  89691. indices.push(StartIndex + 2);
  89692. indices.push(StartIndex + 1);
  89693. indices.push(StartIndex + 1);
  89694. indices.push(StartIndex + 2);
  89695. indices.push(StartIndex + 3);
  89696. }
  89697. StartIndex += 4;
  89698. }
  89699. };
  89700. return PolygonMeshBuilder;
  89701. }());
  89702. /***/ }),
  89703. /***/ "./Meshes/subMesh.ts":
  89704. /*!***************************!*\
  89705. !*** ./Meshes/subMesh.ts ***!
  89706. \***************************/
  89707. /*! exports provided: BaseSubMesh, SubMesh */
  89708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89709. "use strict";
  89710. __webpack_require__.r(__webpack_exports__);
  89711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  89712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  89713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89714. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  89715. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  89716. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  89717. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  89718. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  89719. /**
  89720. * Base class for submeshes
  89721. */
  89722. var BaseSubMesh = /** @class */ (function () {
  89723. function BaseSubMesh() {
  89724. }
  89725. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  89726. /**
  89727. * Gets associated effect
  89728. */
  89729. get: function () {
  89730. return this._materialEffect;
  89731. },
  89732. enumerable: true,
  89733. configurable: true
  89734. });
  89735. /**
  89736. * Sets associated effect (effect used to render this submesh)
  89737. * @param effect defines the effect to associate with
  89738. * @param defines defines the set of defines used to compile this effect
  89739. */
  89740. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  89741. if (defines === void 0) { defines = null; }
  89742. if (this._materialEffect === effect) {
  89743. if (!effect) {
  89744. this._materialDefines = null;
  89745. }
  89746. return;
  89747. }
  89748. this._materialDefines = defines;
  89749. this._materialEffect = effect;
  89750. };
  89751. return BaseSubMesh;
  89752. }());
  89753. /**
  89754. * Defines a subdivision inside a mesh
  89755. */
  89756. var SubMesh = /** @class */ (function (_super) {
  89757. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  89758. /**
  89759. * Creates a new submesh
  89760. * @param materialIndex defines the material index to use
  89761. * @param verticesStart defines vertex index start
  89762. * @param verticesCount defines vertices count
  89763. * @param indexStart defines index start
  89764. * @param indexCount defines indices count
  89765. * @param mesh defines the parent mesh
  89766. * @param renderingMesh defines an optional rendering mesh
  89767. * @param createBoundingBox defines if bounding box should be created for this submesh
  89768. */
  89769. function SubMesh(
  89770. /** the material index to use */
  89771. materialIndex,
  89772. /** vertex index start */
  89773. verticesStart,
  89774. /** vertices count */
  89775. verticesCount,
  89776. /** index start */
  89777. indexStart,
  89778. /** indices count */
  89779. indexCount, mesh, renderingMesh, createBoundingBox) {
  89780. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89781. var _this = _super.call(this) || this;
  89782. _this.materialIndex = materialIndex;
  89783. _this.verticesStart = verticesStart;
  89784. _this.verticesCount = verticesCount;
  89785. _this.indexStart = indexStart;
  89786. _this.indexCount = indexCount;
  89787. /** @hidden */
  89788. _this._renderId = 0;
  89789. _this._mesh = mesh;
  89790. _this._renderingMesh = renderingMesh || mesh;
  89791. mesh.subMeshes.push(_this);
  89792. _this._trianglePlanes = [];
  89793. _this._id = mesh.subMeshes.length - 1;
  89794. if (createBoundingBox) {
  89795. _this.refreshBoundingInfo();
  89796. mesh.computeWorldMatrix(true);
  89797. }
  89798. return _this;
  89799. }
  89800. /**
  89801. * Add a new submesh to a mesh
  89802. * @param materialIndex defines the material index to use
  89803. * @param verticesStart defines vertex index start
  89804. * @param verticesCount defines vertices count
  89805. * @param indexStart defines index start
  89806. * @param indexCount defines indices count
  89807. * @param mesh defines the parent mesh
  89808. * @param renderingMesh defines an optional rendering mesh
  89809. * @param createBoundingBox defines if bounding box should be created for this submesh
  89810. * @returns the new submesh
  89811. */
  89812. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  89813. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89814. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  89815. };
  89816. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  89817. /**
  89818. * Returns true if this submesh covers the entire parent mesh
  89819. * @ignorenaming
  89820. */
  89821. get: function () {
  89822. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  89823. },
  89824. enumerable: true,
  89825. configurable: true
  89826. });
  89827. /**
  89828. * Returns the submesh BoudingInfo object
  89829. * @returns current bounding info (or mesh's one if the submesh is global)
  89830. */
  89831. SubMesh.prototype.getBoundingInfo = function () {
  89832. if (this.IsGlobal) {
  89833. return this._mesh.getBoundingInfo();
  89834. }
  89835. return this._boundingInfo;
  89836. };
  89837. /**
  89838. * Sets the submesh BoundingInfo
  89839. * @param boundingInfo defines the new bounding info to use
  89840. * @returns the SubMesh
  89841. */
  89842. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  89843. this._boundingInfo = boundingInfo;
  89844. return this;
  89845. };
  89846. /**
  89847. * Returns the mesh of the current submesh
  89848. * @return the parent mesh
  89849. */
  89850. SubMesh.prototype.getMesh = function () {
  89851. return this._mesh;
  89852. };
  89853. /**
  89854. * Returns the rendering mesh of the submesh
  89855. * @returns the rendering mesh (could be different from parent mesh)
  89856. */
  89857. SubMesh.prototype.getRenderingMesh = function () {
  89858. return this._renderingMesh;
  89859. };
  89860. /**
  89861. * Returns the submesh material
  89862. * @returns null or the current material
  89863. */
  89864. SubMesh.prototype.getMaterial = function () {
  89865. var rootMaterial = this._renderingMesh.material;
  89866. if (rootMaterial === null || rootMaterial === undefined) {
  89867. return this._mesh.getScene().defaultMaterial;
  89868. }
  89869. else if (rootMaterial.getSubMaterial) {
  89870. var multiMaterial = rootMaterial;
  89871. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  89872. if (this._currentMaterial !== effectiveMaterial) {
  89873. this._currentMaterial = effectiveMaterial;
  89874. this._materialDefines = null;
  89875. }
  89876. return effectiveMaterial;
  89877. }
  89878. return rootMaterial;
  89879. };
  89880. // Methods
  89881. /**
  89882. * Sets a new updated BoundingInfo object to the submesh
  89883. * @returns the SubMesh
  89884. */
  89885. SubMesh.prototype.refreshBoundingInfo = function () {
  89886. this._lastColliderWorldVertices = null;
  89887. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  89888. return this;
  89889. }
  89890. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  89891. if (!data) {
  89892. this._boundingInfo = this._mesh.getBoundingInfo();
  89893. return this;
  89894. }
  89895. var indices = this._renderingMesh.getIndices();
  89896. var extend;
  89897. //is this the only submesh?
  89898. if (this.indexStart === 0 && this.indexCount === indices.length) {
  89899. var boundingInfo = this._renderingMesh.getBoundingInfo();
  89900. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  89901. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  89902. }
  89903. else {
  89904. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  89905. }
  89906. if (this._boundingInfo) {
  89907. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  89908. }
  89909. else {
  89910. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  89911. }
  89912. return this;
  89913. };
  89914. /** @hidden */
  89915. SubMesh.prototype._checkCollision = function (collider) {
  89916. var boundingInfo = this.getBoundingInfo();
  89917. return boundingInfo._checkCollision(collider);
  89918. };
  89919. /**
  89920. * Updates the submesh BoundingInfo
  89921. * @param world defines the world matrix to use to update the bounding info
  89922. * @returns the submesh
  89923. */
  89924. SubMesh.prototype.updateBoundingInfo = function (world) {
  89925. var boundingInfo = this.getBoundingInfo();
  89926. if (!boundingInfo) {
  89927. this.refreshBoundingInfo();
  89928. boundingInfo = this.getBoundingInfo();
  89929. }
  89930. boundingInfo.update(world);
  89931. return this;
  89932. };
  89933. /**
  89934. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89935. * @param frustumPlanes defines the frustum planes
  89936. * @returns true if the submesh is intersecting with the frustum
  89937. */
  89938. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  89939. var boundingInfo = this.getBoundingInfo();
  89940. if (!boundingInfo) {
  89941. return false;
  89942. }
  89943. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  89944. };
  89945. /**
  89946. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89947. * @param frustumPlanes defines the frustum planes
  89948. * @returns true if the submesh is inside the frustum
  89949. */
  89950. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  89951. var boundingInfo = this.getBoundingInfo();
  89952. if (!boundingInfo) {
  89953. return false;
  89954. }
  89955. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  89956. };
  89957. /**
  89958. * Renders the submesh
  89959. * @param enableAlphaMode defines if alpha needs to be used
  89960. * @returns the submesh
  89961. */
  89962. SubMesh.prototype.render = function (enableAlphaMode) {
  89963. this._renderingMesh.render(this, enableAlphaMode);
  89964. return this;
  89965. };
  89966. /**
  89967. * @hidden
  89968. */
  89969. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  89970. if (!this._linesIndexBuffer) {
  89971. var linesIndices = [];
  89972. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  89973. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  89974. }
  89975. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  89976. this._linesIndexCount = linesIndices.length;
  89977. }
  89978. return this._linesIndexBuffer;
  89979. };
  89980. /**
  89981. * Checks if the submesh intersects with a ray
  89982. * @param ray defines the ray to test
  89983. * @returns true is the passed ray intersects the submesh bounding box
  89984. */
  89985. SubMesh.prototype.canIntersects = function (ray) {
  89986. var boundingInfo = this.getBoundingInfo();
  89987. if (!boundingInfo) {
  89988. return false;
  89989. }
  89990. return ray.intersectsBox(boundingInfo.boundingBox);
  89991. };
  89992. /**
  89993. * Intersects current submesh with a ray
  89994. * @param ray defines the ray to test
  89995. * @param positions defines mesh's positions array
  89996. * @param indices defines mesh's indices array
  89997. * @param fastCheck defines if only bounding info should be used
  89998. * @returns intersection info or null if no intersection
  89999. */
  90000. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  90001. var material = this.getMaterial();
  90002. if (!material) {
  90003. return null;
  90004. }
  90005. switch (material.fillMode) {
  90006. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  90007. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  90008. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  90009. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  90010. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  90011. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  90012. return null;
  90013. }
  90014. // LineMesh first as it's also a Mesh...
  90015. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  90016. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  90017. }
  90018. return this._intersectTriangles(ray, positions, indices, fastCheck);
  90019. };
  90020. /** @hidden */
  90021. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  90022. var intersectInfo = null;
  90023. // Line test
  90024. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  90025. var p0 = positions[indices[index]];
  90026. var p1 = positions[indices[index + 1]];
  90027. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  90028. if (length < 0) {
  90029. continue;
  90030. }
  90031. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  90032. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  90033. intersectInfo.faceId = index / 2;
  90034. if (fastCheck) {
  90035. break;
  90036. }
  90037. }
  90038. }
  90039. return intersectInfo;
  90040. };
  90041. /** @hidden */
  90042. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  90043. var intersectInfo = null;
  90044. // Triangles test
  90045. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  90046. var p0 = positions[indices[index]];
  90047. var p1 = positions[indices[index + 1]];
  90048. var p2 = positions[indices[index + 2]];
  90049. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  90050. if (currentIntersectInfo) {
  90051. if (currentIntersectInfo.distance < 0) {
  90052. continue;
  90053. }
  90054. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  90055. intersectInfo = currentIntersectInfo;
  90056. intersectInfo.faceId = index / 3;
  90057. if (fastCheck) {
  90058. break;
  90059. }
  90060. }
  90061. }
  90062. }
  90063. return intersectInfo;
  90064. };
  90065. /** @hidden */
  90066. SubMesh.prototype._rebuild = function () {
  90067. if (this._linesIndexBuffer) {
  90068. this._linesIndexBuffer = null;
  90069. }
  90070. };
  90071. // Clone
  90072. /**
  90073. * Creates a new submesh from the passed mesh
  90074. * @param newMesh defines the new hosting mesh
  90075. * @param newRenderingMesh defines an optional rendering mesh
  90076. * @returns the new submesh
  90077. */
  90078. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  90079. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  90080. if (!this.IsGlobal) {
  90081. var boundingInfo = this.getBoundingInfo();
  90082. if (!boundingInfo) {
  90083. return result;
  90084. }
  90085. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  90086. }
  90087. return result;
  90088. };
  90089. // Dispose
  90090. /**
  90091. * Release associated resources
  90092. */
  90093. SubMesh.prototype.dispose = function () {
  90094. if (this._linesIndexBuffer) {
  90095. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  90096. this._linesIndexBuffer = null;
  90097. }
  90098. // Remove from mesh
  90099. var index = this._mesh.subMeshes.indexOf(this);
  90100. this._mesh.subMeshes.splice(index, 1);
  90101. };
  90102. /**
  90103. * Gets the class name
  90104. * @returns the string "SubMesh".
  90105. */
  90106. SubMesh.prototype.getClassName = function () {
  90107. return "SubMesh";
  90108. };
  90109. // Statics
  90110. /**
  90111. * Creates a new submesh from indices data
  90112. * @param materialIndex the index of the main mesh material
  90113. * @param startIndex the index where to start the copy in the mesh indices array
  90114. * @param indexCount the number of indices to copy then from the startIndex
  90115. * @param mesh the main mesh to create the submesh from
  90116. * @param renderingMesh the optional rendering mesh
  90117. * @returns a new submesh
  90118. */
  90119. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  90120. var minVertexIndex = Number.MAX_VALUE;
  90121. var maxVertexIndex = -Number.MAX_VALUE;
  90122. var whatWillRender = (renderingMesh || mesh);
  90123. var indices = whatWillRender.getIndices();
  90124. for (var index = startIndex; index < startIndex + indexCount; index++) {
  90125. var vertexIndex = indices[index];
  90126. if (vertexIndex < minVertexIndex) {
  90127. minVertexIndex = vertexIndex;
  90128. }
  90129. if (vertexIndex > maxVertexIndex) {
  90130. maxVertexIndex = vertexIndex;
  90131. }
  90132. }
  90133. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  90134. };
  90135. return SubMesh;
  90136. }(BaseSubMesh));
  90137. /***/ }),
  90138. /***/ "./Meshes/transformNode.ts":
  90139. /*!*********************************!*\
  90140. !*** ./Meshes/transformNode.ts ***!
  90141. \*********************************/
  90142. /*! exports provided: TransformNode */
  90143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90144. "use strict";
  90145. __webpack_require__.r(__webpack_exports__);
  90146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  90147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90148. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  90149. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  90150. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90151. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  90152. /**
  90153. * 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.
  90154. * @see https://doc.babylonjs.com/how_to/transformnode
  90155. */
  90156. var TransformNode = /** @class */ (function (_super) {
  90157. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  90158. function TransformNode(name, scene, isPure) {
  90159. if (scene === void 0) { scene = null; }
  90160. if (isPure === void 0) { isPure = true; }
  90161. var _this = _super.call(this, name, scene) || this;
  90162. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  90163. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  90164. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  90165. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  90166. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  90167. // Properties
  90168. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90169. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90170. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  90171. _this._isDirty = false;
  90172. /**
  90173. * Set the billboard mode. Default is 0.
  90174. *
  90175. * | Value | Type | Description |
  90176. * | --- | --- | --- |
  90177. * | 0 | BILLBOARDMODE_NONE | |
  90178. * | 1 | BILLBOARDMODE_X | |
  90179. * | 2 | BILLBOARDMODE_Y | |
  90180. * | 4 | BILLBOARDMODE_Z | |
  90181. * | 7 | BILLBOARDMODE_ALL | |
  90182. *
  90183. */
  90184. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  90185. /**
  90186. * 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
  90187. */
  90188. _this.scalingDeterminant = 1;
  90189. /**
  90190. * Sets the distance of the object to max, often used by skybox
  90191. */
  90192. _this.infiniteDistance = false;
  90193. /**
  90194. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  90195. * By default the system will update normals to compensate
  90196. */
  90197. _this.ignoreNonUniformScaling = false;
  90198. /** @hidden */
  90199. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  90200. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90201. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  90202. _this._postMultiplyPivotMatrix = false;
  90203. _this._isWorldMatrixFrozen = false;
  90204. /** @hidden */
  90205. _this._indexInSceneTransformNodesArray = -1;
  90206. /**
  90207. * An event triggered after the world matrix is updated
  90208. */
  90209. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  90210. _this._nonUniformScaling = false;
  90211. if (isPure) {
  90212. _this.getScene().addTransformNode(_this);
  90213. }
  90214. return _this;
  90215. }
  90216. /**
  90217. * Gets a string identifying the name of the class
  90218. * @returns "TransformNode" string
  90219. */
  90220. TransformNode.prototype.getClassName = function () {
  90221. return "TransformNode";
  90222. };
  90223. Object.defineProperty(TransformNode.prototype, "position", {
  90224. /**
  90225. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  90226. */
  90227. get: function () {
  90228. return this._position;
  90229. },
  90230. set: function (newPosition) {
  90231. this._position = newPosition;
  90232. this._isDirty = true;
  90233. },
  90234. enumerable: true,
  90235. configurable: true
  90236. });
  90237. Object.defineProperty(TransformNode.prototype, "rotation", {
  90238. /**
  90239. * 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)).
  90240. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  90241. */
  90242. get: function () {
  90243. return this._rotation;
  90244. },
  90245. set: function (newRotation) {
  90246. this._rotation = newRotation;
  90247. this._isDirty = true;
  90248. },
  90249. enumerable: true,
  90250. configurable: true
  90251. });
  90252. Object.defineProperty(TransformNode.prototype, "scaling", {
  90253. /**
  90254. * 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)).
  90255. */
  90256. get: function () {
  90257. return this._scaling;
  90258. },
  90259. set: function (newScaling) {
  90260. this._scaling = newScaling;
  90261. this._isDirty = true;
  90262. },
  90263. enumerable: true,
  90264. configurable: true
  90265. });
  90266. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  90267. /**
  90268. * 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).
  90269. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  90270. */
  90271. get: function () {
  90272. return this._rotationQuaternion;
  90273. },
  90274. set: function (quaternion) {
  90275. this._rotationQuaternion = quaternion;
  90276. //reset the rotation vector.
  90277. if (quaternion) {
  90278. this.rotation.setAll(0.0);
  90279. }
  90280. },
  90281. enumerable: true,
  90282. configurable: true
  90283. });
  90284. Object.defineProperty(TransformNode.prototype, "forward", {
  90285. /**
  90286. * The forward direction of that transform in world space.
  90287. */
  90288. get: function () {
  90289. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
  90290. },
  90291. enumerable: true,
  90292. configurable: true
  90293. });
  90294. Object.defineProperty(TransformNode.prototype, "up", {
  90295. /**
  90296. * The up direction of that transform in world space.
  90297. */
  90298. get: function () {
  90299. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  90300. },
  90301. enumerable: true,
  90302. configurable: true
  90303. });
  90304. Object.defineProperty(TransformNode.prototype, "right", {
  90305. /**
  90306. * The right direction of that transform in world space.
  90307. */
  90308. get: function () {
  90309. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
  90310. },
  90311. enumerable: true,
  90312. configurable: true
  90313. });
  90314. /**
  90315. * Copies the parameter passed Matrix into the mesh Pose matrix.
  90316. * @param matrix the matrix to copy the pose from
  90317. * @returns this TransformNode.
  90318. */
  90319. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  90320. this._poseMatrix.copyFrom(matrix);
  90321. return this;
  90322. };
  90323. /**
  90324. * Returns the mesh Pose matrix.
  90325. * @returns the pose matrix
  90326. */
  90327. TransformNode.prototype.getPoseMatrix = function () {
  90328. return this._poseMatrix;
  90329. };
  90330. /** @hidden */
  90331. TransformNode.prototype._isSynchronized = function () {
  90332. if (this._isDirty) {
  90333. return false;
  90334. }
  90335. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90336. return false;
  90337. }
  90338. if (this._cache.pivotMatrixUpdated) {
  90339. return false;
  90340. }
  90341. if (this.infiniteDistance) {
  90342. return false;
  90343. }
  90344. if (!this._cache.position.equals(this._position)) {
  90345. return false;
  90346. }
  90347. if (this._rotationQuaternion) {
  90348. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  90349. return false;
  90350. }
  90351. }
  90352. if (!this._cache.rotation.equals(this._rotation)) {
  90353. return false;
  90354. }
  90355. if (!this._cache.scaling.equals(this._scaling)) {
  90356. return false;
  90357. }
  90358. return true;
  90359. };
  90360. /** @hidden */
  90361. TransformNode.prototype._initCache = function () {
  90362. _super.prototype._initCache.call(this);
  90363. this._cache.localMatrixUpdated = false;
  90364. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90365. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90366. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90367. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  90368. this._cache.billboardMode = -1;
  90369. this._cache.infiniteDistance = false;
  90370. };
  90371. /**
  90372. * Flag the transform node as dirty (Forcing it to update everything)
  90373. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  90374. * @returns this transform node
  90375. */
  90376. TransformNode.prototype.markAsDirty = function (property) {
  90377. if (property === "rotation") {
  90378. this.rotationQuaternion = null;
  90379. }
  90380. this._currentRenderId = Number.MAX_VALUE;
  90381. this._isDirty = true;
  90382. return this;
  90383. };
  90384. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  90385. /**
  90386. * Returns the current mesh absolute position.
  90387. * Returns a Vector3.
  90388. */
  90389. get: function () {
  90390. return this._absolutePosition;
  90391. },
  90392. enumerable: true,
  90393. configurable: true
  90394. });
  90395. /**
  90396. * Sets a new matrix to apply before all other transformation
  90397. * @param matrix defines the transform matrix
  90398. * @returns the current TransformNode
  90399. */
  90400. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  90401. return this.setPivotMatrix(matrix, false);
  90402. };
  90403. /**
  90404. * Sets a new pivot matrix to the current node
  90405. * @param matrix defines the new pivot matrix to use
  90406. * @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
  90407. * @returns the current TransformNode
  90408. */
  90409. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  90410. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  90411. this._pivotMatrix.copyFrom(matrix);
  90412. this._cache.pivotMatrixUpdated = true;
  90413. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  90414. if (this._postMultiplyPivotMatrix) {
  90415. if (!this._pivotMatrixInverse) {
  90416. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  90417. }
  90418. else {
  90419. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  90420. }
  90421. }
  90422. return this;
  90423. };
  90424. /**
  90425. * Returns the mesh pivot matrix.
  90426. * Default : Identity.
  90427. * @returns the matrix
  90428. */
  90429. TransformNode.prototype.getPivotMatrix = function () {
  90430. return this._pivotMatrix;
  90431. };
  90432. /**
  90433. * Prevents the World matrix to be computed any longer.
  90434. * @returns the TransformNode.
  90435. */
  90436. TransformNode.prototype.freezeWorldMatrix = function () {
  90437. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  90438. this.computeWorldMatrix(true);
  90439. this._isWorldMatrixFrozen = true;
  90440. return this;
  90441. };
  90442. /**
  90443. * Allows back the World matrix computation.
  90444. * @returns the TransformNode.
  90445. */
  90446. TransformNode.prototype.unfreezeWorldMatrix = function () {
  90447. this._isWorldMatrixFrozen = false;
  90448. this.computeWorldMatrix(true);
  90449. return this;
  90450. };
  90451. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  90452. /**
  90453. * True if the World matrix has been frozen.
  90454. */
  90455. get: function () {
  90456. return this._isWorldMatrixFrozen;
  90457. },
  90458. enumerable: true,
  90459. configurable: true
  90460. });
  90461. /**
  90462. * Retuns the mesh absolute position in the World.
  90463. * @returns a Vector3.
  90464. */
  90465. TransformNode.prototype.getAbsolutePosition = function () {
  90466. this.computeWorldMatrix();
  90467. return this._absolutePosition;
  90468. };
  90469. /**
  90470. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  90471. * @param absolutePosition the absolute position to set
  90472. * @returns the TransformNode.
  90473. */
  90474. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  90475. if (!absolutePosition) {
  90476. return this;
  90477. }
  90478. var absolutePositionX;
  90479. var absolutePositionY;
  90480. var absolutePositionZ;
  90481. if (absolutePosition.x === undefined) {
  90482. if (arguments.length < 3) {
  90483. return this;
  90484. }
  90485. absolutePositionX = arguments[0];
  90486. absolutePositionY = arguments[1];
  90487. absolutePositionZ = arguments[2];
  90488. }
  90489. else {
  90490. absolutePositionX = absolutePosition.x;
  90491. absolutePositionY = absolutePosition.y;
  90492. absolutePositionZ = absolutePosition.z;
  90493. }
  90494. if (this.parent) {
  90495. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90496. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90497. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  90498. }
  90499. else {
  90500. this.position.x = absolutePositionX;
  90501. this.position.y = absolutePositionY;
  90502. this.position.z = absolutePositionZ;
  90503. }
  90504. return this;
  90505. };
  90506. /**
  90507. * Sets the mesh position in its local space.
  90508. * @param vector3 the position to set in localspace
  90509. * @returns the TransformNode.
  90510. */
  90511. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  90512. this.computeWorldMatrix();
  90513. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  90514. return this;
  90515. };
  90516. /**
  90517. * Returns the mesh position in the local space from the current World matrix values.
  90518. * @returns a new Vector3.
  90519. */
  90520. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  90521. this.computeWorldMatrix();
  90522. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90523. this._localMatrix.invertToRef(invLocalWorldMatrix);
  90524. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  90525. };
  90526. /**
  90527. * Translates the mesh along the passed Vector3 in its local space.
  90528. * @param vector3 the distance to translate in localspace
  90529. * @returns the TransformNode.
  90530. */
  90531. TransformNode.prototype.locallyTranslate = function (vector3) {
  90532. this.computeWorldMatrix(true);
  90533. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  90534. return this;
  90535. };
  90536. /**
  90537. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  90538. * @param targetPoint the position (must be in same space as current mesh) to look at
  90539. * @param yawCor optional yaw (y-axis) correction in radians
  90540. * @param pitchCor optional pitch (x-axis) correction in radians
  90541. * @param rollCor optional roll (z-axis) correction in radians
  90542. * @param space the choosen space of the target
  90543. * @returns the TransformNode.
  90544. */
  90545. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  90546. if (yawCor === void 0) { yawCor = 0; }
  90547. if (pitchCor === void 0) { pitchCor = 0; }
  90548. if (rollCor === void 0) { rollCor = 0; }
  90549. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  90550. var dv = TransformNode._lookAtVectorCache;
  90551. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  90552. targetPoint.subtractToRef(pos, dv);
  90553. this.setDirection(dv, yawCor, pitchCor, rollCor);
  90554. // Correct for parent's rotation offset
  90555. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  90556. if (this.rotationQuaternion) {
  90557. // Get local rotation matrix of the looking object
  90558. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90559. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  90560. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90561. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90562. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90563. parentRotationMatrix.invert();
  90564. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90565. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  90566. }
  90567. else {
  90568. // Get local rotation matrix of the looking object
  90569. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90570. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  90571. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90572. quaternionRotation.toRotationMatrix(rotationMatrix);
  90573. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90574. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90575. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90576. parentRotationMatrix.invert();
  90577. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90578. quaternionRotation.fromRotationMatrix(rotationMatrix);
  90579. quaternionRotation.toEulerAnglesToRef(this.rotation);
  90580. }
  90581. }
  90582. return this;
  90583. };
  90584. /**
  90585. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90586. * This Vector3 is expressed in the World space.
  90587. * @param localAxis axis to rotate
  90588. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90589. */
  90590. TransformNode.prototype.getDirection = function (localAxis) {
  90591. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90592. this.getDirectionToRef(localAxis, result);
  90593. return result;
  90594. };
  90595. /**
  90596. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  90597. * localAxis is expressed in the mesh local space.
  90598. * result is computed in the Wordl space from the mesh World matrix.
  90599. * @param localAxis axis to rotate
  90600. * @param result the resulting transformnode
  90601. * @returns this TransformNode.
  90602. */
  90603. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  90604. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  90605. return this;
  90606. };
  90607. /**
  90608. * Sets this transform node rotation to the given local axis.
  90609. * @param localAxis the axis in local space
  90610. * @param yawCor optional yaw (y-axis) correction in radians
  90611. * @param pitchCor optional pitch (x-axis) correction in radians
  90612. * @param rollCor optional roll (z-axis) correction in radians
  90613. * @returns this TransformNode
  90614. */
  90615. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  90616. if (yawCor === void 0) { yawCor = 0; }
  90617. if (pitchCor === void 0) { pitchCor = 0; }
  90618. if (rollCor === void 0) { rollCor = 0; }
  90619. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  90620. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  90621. var pitch = -Math.atan2(localAxis.y, len);
  90622. if (this.rotationQuaternion) {
  90623. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  90624. }
  90625. else {
  90626. this.rotation.x = pitch + pitchCor;
  90627. this.rotation.y = yaw + yawCor;
  90628. this.rotation.z = rollCor;
  90629. }
  90630. return this;
  90631. };
  90632. /**
  90633. * Sets a new pivot point to the current node
  90634. * @param point defines the new pivot point to use
  90635. * @param space defines if the point is in world or local space (local by default)
  90636. * @returns the current TransformNode
  90637. */
  90638. TransformNode.prototype.setPivotPoint = function (point, space) {
  90639. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  90640. if (this.getScene().getRenderId() == 0) {
  90641. this.computeWorldMatrix(true);
  90642. }
  90643. var wm = this.getWorldMatrix();
  90644. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  90645. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90646. wm.invertToRef(tmat);
  90647. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  90648. }
  90649. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  90650. };
  90651. /**
  90652. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  90653. * @returns the pivot point
  90654. */
  90655. TransformNode.prototype.getPivotPoint = function () {
  90656. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90657. this.getPivotPointToRef(point);
  90658. return point;
  90659. };
  90660. /**
  90661. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  90662. * @param result the vector3 to store the result
  90663. * @returns this TransformNode.
  90664. */
  90665. TransformNode.prototype.getPivotPointToRef = function (result) {
  90666. result.x = -this._pivotMatrix.m[12];
  90667. result.y = -this._pivotMatrix.m[13];
  90668. result.z = -this._pivotMatrix.m[14];
  90669. return this;
  90670. };
  90671. /**
  90672. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  90673. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  90674. */
  90675. TransformNode.prototype.getAbsolutePivotPoint = function () {
  90676. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90677. this.getAbsolutePivotPointToRef(point);
  90678. return point;
  90679. };
  90680. /**
  90681. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  90682. * @param result vector3 to store the result
  90683. * @returns this TransformNode.
  90684. */
  90685. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  90686. result.x = this._pivotMatrix.m[12];
  90687. result.y = this._pivotMatrix.m[13];
  90688. result.z = this._pivotMatrix.m[14];
  90689. this.getPivotPointToRef(result);
  90690. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  90691. return this;
  90692. };
  90693. /**
  90694. * Defines the passed node as the parent of the current node.
  90695. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  90696. * @param node the node ot set as the parent
  90697. * @returns this TransformNode.
  90698. */
  90699. TransformNode.prototype.setParent = function (node) {
  90700. if (!node && !this.parent) {
  90701. return this;
  90702. }
  90703. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90704. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  90705. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  90706. if (!node) {
  90707. if (this.parent && this.parent.computeWorldMatrix) {
  90708. this.parent.computeWorldMatrix(true);
  90709. }
  90710. this.computeWorldMatrix(true);
  90711. this.getWorldMatrix().decompose(scale, quatRotation, position);
  90712. }
  90713. else {
  90714. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90715. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90716. this.computeWorldMatrix(true);
  90717. node.computeWorldMatrix(true);
  90718. node.getWorldMatrix().invertToRef(invParentMatrix);
  90719. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  90720. diffMatrix.decompose(scale, quatRotation, position);
  90721. }
  90722. if (this.rotationQuaternion) {
  90723. this.rotationQuaternion.copyFrom(quatRotation);
  90724. }
  90725. else {
  90726. quatRotation.toEulerAnglesToRef(this.rotation);
  90727. }
  90728. this.scaling.copyFrom(scale);
  90729. this.position.copyFrom(position);
  90730. this.parent = node;
  90731. return this;
  90732. };
  90733. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  90734. /**
  90735. * True if the scaling property of this object is non uniform eg. (1,2,1)
  90736. */
  90737. get: function () {
  90738. return this._nonUniformScaling;
  90739. },
  90740. enumerable: true,
  90741. configurable: true
  90742. });
  90743. /** @hidden */
  90744. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  90745. if (this._nonUniformScaling === value) {
  90746. return false;
  90747. }
  90748. this._nonUniformScaling = value;
  90749. return true;
  90750. };
  90751. /**
  90752. * Attach the current TransformNode to another TransformNode associated with a bone
  90753. * @param bone Bone affecting the TransformNode
  90754. * @param affectedTransformNode TransformNode associated with the bone
  90755. * @returns this object
  90756. */
  90757. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  90758. this._transformToBoneReferal = affectedTransformNode;
  90759. this.parent = bone;
  90760. if (bone.getWorldMatrix().determinant() < 0) {
  90761. this.scalingDeterminant *= -1;
  90762. }
  90763. return this;
  90764. };
  90765. /**
  90766. * Detach the transform node if its associated with a bone
  90767. * @returns this object
  90768. */
  90769. TransformNode.prototype.detachFromBone = function () {
  90770. if (!this.parent) {
  90771. return this;
  90772. }
  90773. if (this.parent.getWorldMatrix().determinant() < 0) {
  90774. this.scalingDeterminant *= -1;
  90775. }
  90776. this._transformToBoneReferal = null;
  90777. this.parent = null;
  90778. return this;
  90779. };
  90780. /**
  90781. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  90782. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90783. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90784. * The passed axis is also normalized.
  90785. * @param axis the axis to rotate around
  90786. * @param amount the amount to rotate in radians
  90787. * @param space Space to rotate in (Default: local)
  90788. * @returns the TransformNode.
  90789. */
  90790. TransformNode.prototype.rotate = function (axis, amount, space) {
  90791. axis.normalize();
  90792. if (!this.rotationQuaternion) {
  90793. this.rotationQuaternion = this.rotation.toQuaternion();
  90794. this.rotation.setAll(0);
  90795. }
  90796. var rotationQuaternion;
  90797. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  90798. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90799. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  90800. }
  90801. else {
  90802. if (this.parent) {
  90803. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90804. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90805. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  90806. }
  90807. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90808. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90809. }
  90810. return this;
  90811. };
  90812. /**
  90813. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  90814. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90815. * The passed axis is also normalized. .
  90816. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90817. * @param point the point to rotate around
  90818. * @param axis the axis to rotate around
  90819. * @param amount the amount to rotate in radians
  90820. * @returns the TransformNode
  90821. */
  90822. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  90823. axis.normalize();
  90824. if (!this.rotationQuaternion) {
  90825. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  90826. this.rotation.setAll(0);
  90827. }
  90828. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  90829. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  90830. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  90831. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90832. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  90833. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  90834. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  90835. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  90836. point.subtractToRef(this.position, tmpVector);
  90837. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  90838. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  90839. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  90840. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  90841. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  90842. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  90843. this.position.addInPlace(finalTranslation);
  90844. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90845. return this;
  90846. };
  90847. /**
  90848. * Translates the mesh along the axis vector for the passed distance in the given space.
  90849. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90850. * @param axis the axis to translate in
  90851. * @param distance the distance to translate
  90852. * @param space Space to rotate in (Default: local)
  90853. * @returns the TransformNode.
  90854. */
  90855. TransformNode.prototype.translate = function (axis, distance, space) {
  90856. var displacementVector = axis.scale(distance);
  90857. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  90858. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  90859. this.setPositionWithLocalVector(tempV3);
  90860. }
  90861. else {
  90862. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  90863. }
  90864. return this;
  90865. };
  90866. /**
  90867. * Adds a rotation step to the mesh current rotation.
  90868. * x, y, z are Euler angles expressed in radians.
  90869. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90870. * This means this rotation is made in the mesh local space only.
  90871. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90872. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90873. * ```javascript
  90874. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90875. * ```
  90876. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90877. * 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.
  90878. * @param x Rotation to add
  90879. * @param y Rotation to add
  90880. * @param z Rotation to add
  90881. * @returns the TransformNode.
  90882. */
  90883. TransformNode.prototype.addRotation = function (x, y, z) {
  90884. var rotationQuaternion;
  90885. if (this.rotationQuaternion) {
  90886. rotationQuaternion = this.rotationQuaternion;
  90887. }
  90888. else {
  90889. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  90890. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  90891. }
  90892. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90893. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  90894. rotationQuaternion.multiplyInPlace(accumulation);
  90895. if (!this.rotationQuaternion) {
  90896. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  90897. }
  90898. return this;
  90899. };
  90900. /**
  90901. * Computes the world matrix of the node
  90902. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90903. * @returns the world matrix
  90904. */
  90905. TransformNode.prototype.computeWorldMatrix = function (force) {
  90906. if (this._isWorldMatrixFrozen) {
  90907. return this._worldMatrix;
  90908. }
  90909. if (!force && this.isSynchronized()) {
  90910. this._currentRenderId = this.getScene().getRenderId();
  90911. return this._worldMatrix;
  90912. }
  90913. this._updateCache();
  90914. this._cache.position.copyFrom(this.position);
  90915. this._cache.scaling.copyFrom(this.scaling);
  90916. this._cache.pivotMatrixUpdated = false;
  90917. this._cache.billboardMode = this.billboardMode;
  90918. this._cache.infiniteDistance = this.infiniteDistance;
  90919. this._currentRenderId = this.getScene().getRenderId();
  90920. this._childRenderId = this.getScene().getRenderId();
  90921. this._isDirty = false;
  90922. // Scaling
  90923. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]);
  90924. // Rotation
  90925. //rotate, if quaternion is set and rotation was used
  90926. if (this.rotationQuaternion) {
  90927. var len = this.rotation.length();
  90928. if (len) {
  90929. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  90930. this.rotation.copyFromFloats(0, 0, 0);
  90931. }
  90932. }
  90933. if (this.rotationQuaternion) {
  90934. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90935. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  90936. }
  90937. else {
  90938. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90939. this._cache.rotation.copyFrom(this.rotation);
  90940. }
  90941. // Translation
  90942. var camera = this.getScene().activeCamera;
  90943. if (this.infiniteDistance && !this.parent && camera) {
  90944. var cameraWorldMatrix = camera.getWorldMatrix();
  90945. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  90946. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]);
  90947. }
  90948. else {
  90949. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]);
  90950. }
  90951. // Composing transformations
  90952. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  90953. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90954. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  90955. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  90956. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  90957. // Need to decompose each rotation here
  90958. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  90959. if (this.parent && this.parent.getWorldMatrix) {
  90960. if (this._transformToBoneReferal) {
  90961. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  90962. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  90963. }
  90964. else {
  90965. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  90966. }
  90967. }
  90968. else {
  90969. currentPosition.copyFrom(this.position);
  90970. }
  90971. currentPosition.subtractInPlace(camera.globalPosition);
  90972. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  90973. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  90974. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  90975. }
  90976. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  90977. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  90978. }
  90979. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  90980. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  90981. }
  90982. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90983. }
  90984. else {
  90985. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  90986. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  90987. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90988. }
  90989. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90990. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90991. }
  90992. // Post multiply inverse of pivotMatrix
  90993. if (this._postMultiplyPivotMatrix) {
  90994. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90995. }
  90996. // Local world
  90997. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2], this._localMatrix);
  90998. // Parent
  90999. if (this.parent && this.parent.getWorldMatrix) {
  91000. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  91001. if (this._transformToBoneReferal) {
  91002. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91003. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91004. }
  91005. else {
  91006. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  91007. }
  91008. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91009. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91010. this._worldMatrix.copyFrom(this._localMatrix);
  91011. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91012. }
  91013. else {
  91014. if (this._transformToBoneReferal) {
  91015. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91016. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  91017. }
  91018. else {
  91019. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  91020. }
  91021. }
  91022. this._markSyncedWithParent();
  91023. }
  91024. else {
  91025. this._worldMatrix.copyFrom(this._localMatrix);
  91026. }
  91027. // Normal matrix
  91028. if (!this.ignoreNonUniformScaling) {
  91029. if (this.scaling.isNonUniform) {
  91030. this._updateNonUniformScalingState(true);
  91031. }
  91032. else if (this.parent && this.parent._nonUniformScaling) {
  91033. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  91034. }
  91035. else {
  91036. this._updateNonUniformScalingState(false);
  91037. }
  91038. }
  91039. else {
  91040. this._updateNonUniformScalingState(false);
  91041. }
  91042. this._afterComputeWorldMatrix();
  91043. // Absolute position
  91044. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  91045. // Callbacks
  91046. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  91047. if (!this._poseMatrix) {
  91048. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  91049. }
  91050. // Cache the determinant
  91051. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  91052. return this._worldMatrix;
  91053. };
  91054. TransformNode.prototype._afterComputeWorldMatrix = function () {
  91055. };
  91056. /**
  91057. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  91058. * @param func callback function to add
  91059. *
  91060. * @returns the TransformNode.
  91061. */
  91062. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  91063. this.onAfterWorldMatrixUpdateObservable.add(func);
  91064. return this;
  91065. };
  91066. /**
  91067. * Removes a registered callback function.
  91068. * @param func callback function to remove
  91069. * @returns the TransformNode.
  91070. */
  91071. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  91072. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  91073. return this;
  91074. };
  91075. /**
  91076. * Gets the position of the current mesh in camera space
  91077. * @param camera defines the camera to use
  91078. * @returns a position
  91079. */
  91080. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  91081. if (camera === void 0) { camera = null; }
  91082. if (!camera) {
  91083. camera = this.getScene().activeCamera;
  91084. }
  91085. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  91086. };
  91087. /**
  91088. * Returns the distance from the mesh to the active camera
  91089. * @param camera defines the camera to use
  91090. * @returns the distance
  91091. */
  91092. TransformNode.prototype.getDistanceToCamera = function (camera) {
  91093. if (camera === void 0) { camera = null; }
  91094. if (!camera) {
  91095. camera = this.getScene().activeCamera;
  91096. }
  91097. return this.absolutePosition.subtract(camera.position).length();
  91098. };
  91099. /**
  91100. * Clone the current transform node
  91101. * @param name Name of the new clone
  91102. * @param newParent New parent for the clone
  91103. * @param doNotCloneChildren Do not clone children hierarchy
  91104. * @returns the new transform node
  91105. */
  91106. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  91107. var _this = this;
  91108. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  91109. result.name = name;
  91110. result.id = name;
  91111. if (newParent) {
  91112. result.parent = newParent;
  91113. }
  91114. if (!doNotCloneChildren) {
  91115. // Children
  91116. var directDescendants = this.getDescendants(true);
  91117. for (var index = 0; index < directDescendants.length; index++) {
  91118. var child = directDescendants[index];
  91119. if (child.clone) {
  91120. child.clone(name + "." + child.name, result);
  91121. }
  91122. }
  91123. }
  91124. return result;
  91125. };
  91126. /**
  91127. * Serializes the objects information.
  91128. * @param currentSerializationObject defines the object to serialize in
  91129. * @returns the serialized object
  91130. */
  91131. TransformNode.prototype.serialize = function (currentSerializationObject) {
  91132. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  91133. serializationObject.type = this.getClassName();
  91134. // Parent
  91135. if (this.parent) {
  91136. serializationObject.parentId = this.parent.id;
  91137. }
  91138. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  91139. serializationObject.isEnabled = this.isEnabled();
  91140. // Parent
  91141. if (this.parent) {
  91142. serializationObject.parentId = this.parent.id;
  91143. }
  91144. return serializationObject;
  91145. };
  91146. // Statics
  91147. /**
  91148. * Returns a new TransformNode object parsed from the source provided.
  91149. * @param parsedTransformNode is the source.
  91150. * @param scene the scne the object belongs to
  91151. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  91152. * @returns a new TransformNode object parsed from the source provided.
  91153. */
  91154. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  91155. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  91156. if (parsedTransformNode.localMatrix) {
  91157. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  91158. }
  91159. else if (parsedTransformNode.pivotMatrix) {
  91160. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  91161. }
  91162. transformNode.setEnabled(parsedTransformNode.isEnabled);
  91163. // Parent
  91164. if (parsedTransformNode.parentId) {
  91165. transformNode._waitingParentId = parsedTransformNode.parentId;
  91166. }
  91167. return transformNode;
  91168. };
  91169. /**
  91170. * Get all child-transformNodes of this node
  91171. * @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
  91172. * @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
  91173. * @returns an array of TransformNode
  91174. */
  91175. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  91176. var results = [];
  91177. this._getDescendants(results, directDescendantsOnly, function (node) {
  91178. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  91179. });
  91180. return results;
  91181. };
  91182. /**
  91183. * Releases resources associated with this transform node.
  91184. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91185. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91186. */
  91187. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  91188. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  91189. // Animations
  91190. this.getScene().stopAnimation(this);
  91191. // Remove from scene
  91192. this.getScene().removeTransformNode(this);
  91193. this.onAfterWorldMatrixUpdateObservable.clear();
  91194. if (doNotRecurse) {
  91195. var transformNodes = this.getChildTransformNodes(true);
  91196. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  91197. var transformNode = transformNodes_1[_i];
  91198. transformNode.parent = null;
  91199. transformNode.computeWorldMatrix(true);
  91200. }
  91201. }
  91202. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  91203. };
  91204. // Statics
  91205. /**
  91206. * Object will not rotate to face the camera
  91207. */
  91208. TransformNode.BILLBOARDMODE_NONE = 0;
  91209. /**
  91210. * Object will rotate to face the camera but only on the x axis
  91211. */
  91212. TransformNode.BILLBOARDMODE_X = 1;
  91213. /**
  91214. * Object will rotate to face the camera but only on the y axis
  91215. */
  91216. TransformNode.BILLBOARDMODE_Y = 2;
  91217. /**
  91218. * Object will rotate to face the camera but only on the z axis
  91219. */
  91220. TransformNode.BILLBOARDMODE_Z = 4;
  91221. /**
  91222. * Object will rotate to face the camera
  91223. */
  91224. TransformNode.BILLBOARDMODE_ALL = 7;
  91225. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  91226. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  91227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  91229. ], TransformNode.prototype, "_position", void 0);
  91230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  91232. ], TransformNode.prototype, "_rotation", void 0);
  91233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  91235. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  91236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  91238. ], TransformNode.prototype, "_scaling", void 0);
  91239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91241. ], TransformNode.prototype, "billboardMode", void 0);
  91242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91244. ], TransformNode.prototype, "scalingDeterminant", void 0);
  91245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91247. ], TransformNode.prototype, "infiniteDistance", void 0);
  91248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91250. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  91251. return TransformNode;
  91252. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  91253. /***/ }),
  91254. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  91255. /*!***************************************************************!*\
  91256. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  91257. \***************************************************************/
  91258. /*! exports provided: CubeMapToSphericalPolynomialTools */
  91259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91260. "use strict";
  91261. __webpack_require__.r(__webpack_exports__);
  91262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  91263. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91264. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  91265. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  91266. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91267. var FileFaceOrientation = /** @class */ (function () {
  91268. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  91269. this.name = name;
  91270. this.worldAxisForNormal = worldAxisForNormal;
  91271. this.worldAxisForFileX = worldAxisForFileX;
  91272. this.worldAxisForFileY = worldAxisForFileY;
  91273. }
  91274. return FileFaceOrientation;
  91275. }());
  91276. /**
  91277. * Helper class dealing with the extraction of spherical polynomial dataArray
  91278. * from a cube map.
  91279. */
  91280. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  91281. function CubeMapToSphericalPolynomialTools() {
  91282. }
  91283. /**
  91284. * Converts a texture to the according Spherical Polynomial data.
  91285. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91286. *
  91287. * @param texture The texture to extract the information from.
  91288. * @return The Spherical Polynomial data.
  91289. */
  91290. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  91291. if (!texture.isCube) {
  91292. // Only supports cube Textures currently.
  91293. return null;
  91294. }
  91295. var size = texture.getSize().width;
  91296. var right = texture.readPixels(0);
  91297. var left = texture.readPixels(1);
  91298. var up;
  91299. var down;
  91300. if (texture.isRenderTarget) {
  91301. up = texture.readPixels(3);
  91302. down = texture.readPixels(2);
  91303. }
  91304. else {
  91305. up = texture.readPixels(2);
  91306. down = texture.readPixels(3);
  91307. }
  91308. var front = texture.readPixels(4);
  91309. var back = texture.readPixels(5);
  91310. var gammaSpace = texture.gammaSpace;
  91311. // Always read as RGBA.
  91312. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  91313. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91314. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91315. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  91316. }
  91317. var cubeInfo = {
  91318. size: size,
  91319. right: right,
  91320. left: left,
  91321. up: up,
  91322. down: down,
  91323. front: front,
  91324. back: back,
  91325. format: format,
  91326. type: type,
  91327. gammaSpace: gammaSpace,
  91328. };
  91329. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  91330. };
  91331. /**
  91332. * Converts a cubemap to the according Spherical Polynomial data.
  91333. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91334. *
  91335. * @param cubeInfo The Cube map to extract the information from.
  91336. * @return The Spherical Polynomial data.
  91337. */
  91338. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  91339. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  91340. var totalSolidAngle = 0.0;
  91341. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  91342. var du = 2.0 / cubeInfo.size;
  91343. var dv = du;
  91344. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  91345. var minUV = du * 0.5 - 1.0;
  91346. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  91347. var fileFace = this.FileFaces[faceIndex];
  91348. var dataArray = cubeInfo[fileFace.name];
  91349. var v = minUV;
  91350. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  91351. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  91352. // Because SP is still linear, so summation is fine in that basis.
  91353. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  91354. for (var y = 0; y < cubeInfo.size; y++) {
  91355. var u = minUV;
  91356. for (var x = 0; x < cubeInfo.size; x++) {
  91357. // World direction (not normalised)
  91358. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  91359. worldDirection.normalize();
  91360. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  91361. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  91362. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  91363. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  91364. // Handle Integer types.
  91365. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91366. r /= 255;
  91367. g /= 255;
  91368. b /= 255;
  91369. }
  91370. // Handle Gamma space textures.
  91371. if (cubeInfo.gammaSpace) {
  91372. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91373. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91374. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91375. }
  91376. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  91377. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  91378. totalSolidAngle += deltaSolidAngle;
  91379. u += du;
  91380. }
  91381. v += dv;
  91382. }
  91383. }
  91384. // Solid angle for entire sphere is 4*pi
  91385. var sphereSolidAngle = 4.0 * Math.PI;
  91386. // Adjust the solid angle to allow for how many faces we processed.
  91387. var facesProcessed = 6.0;
  91388. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  91389. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  91390. // This is needed because the numerical integration over the cube uses a
  91391. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  91392. // and also to compensate for accumulative error due to float precision in the summation.
  91393. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  91394. sphericalHarmonics.scale(correctionFactor);
  91395. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  91396. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  91397. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  91398. };
  91399. CubeMapToSphericalPolynomialTools.FileFaces = [
  91400. 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)),
  91401. 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)),
  91402. 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)),
  91403. 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)),
  91404. 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)),
  91405. 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
  91406. ];
  91407. return CubeMapToSphericalPolynomialTools;
  91408. }());
  91409. /***/ }),
  91410. /***/ "./Misc/HighDynamicRange/hdr.ts":
  91411. /*!**************************************!*\
  91412. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  91413. \**************************************/
  91414. /*! exports provided: HDRTools */
  91415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91416. "use strict";
  91417. __webpack_require__.r(__webpack_exports__);
  91418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  91419. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91420. /**
  91421. * This groups tools to convert HDR texture to native colors array.
  91422. */
  91423. var HDRTools = /** @class */ (function () {
  91424. function HDRTools() {
  91425. }
  91426. HDRTools.Ldexp = function (mantissa, exponent) {
  91427. if (exponent > 1023) {
  91428. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  91429. }
  91430. if (exponent < -1074) {
  91431. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  91432. }
  91433. return mantissa * Math.pow(2, exponent);
  91434. };
  91435. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  91436. if (exponent > 0) { /*nonzero pixel*/
  91437. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  91438. float32array[index + 0] = red * exponent;
  91439. float32array[index + 1] = green * exponent;
  91440. float32array[index + 2] = blue * exponent;
  91441. }
  91442. else {
  91443. float32array[index + 0] = 0;
  91444. float32array[index + 1] = 0;
  91445. float32array[index + 2] = 0;
  91446. }
  91447. };
  91448. HDRTools.readStringLine = function (uint8array, startIndex) {
  91449. var line = "";
  91450. var character = "";
  91451. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  91452. character = String.fromCharCode(uint8array[i]);
  91453. if (character == "\n") {
  91454. break;
  91455. }
  91456. line += character;
  91457. }
  91458. return line;
  91459. };
  91460. /**
  91461. * Reads header information from an RGBE texture stored in a native array.
  91462. * More information on this format are available here:
  91463. * https://en.wikipedia.org/wiki/RGBE_image_format
  91464. *
  91465. * @param uint8array The binary file stored in native array.
  91466. * @return The header information.
  91467. */
  91468. HDRTools.RGBE_ReadHeader = function (uint8array) {
  91469. var height = 0;
  91470. var width = 0;
  91471. var line = this.readStringLine(uint8array, 0);
  91472. if (line[0] != '#' || line[1] != '?') {
  91473. throw "Bad HDR Format.";
  91474. }
  91475. var endOfHeader = false;
  91476. var findFormat = false;
  91477. var lineIndex = 0;
  91478. do {
  91479. lineIndex += (line.length + 1);
  91480. line = this.readStringLine(uint8array, lineIndex);
  91481. if (line == "FORMAT=32-bit_rle_rgbe") {
  91482. findFormat = true;
  91483. }
  91484. else if (line.length == 0) {
  91485. endOfHeader = true;
  91486. }
  91487. } while (!endOfHeader);
  91488. if (!findFormat) {
  91489. throw "HDR Bad header format, unsupported FORMAT";
  91490. }
  91491. lineIndex += (line.length + 1);
  91492. line = this.readStringLine(uint8array, lineIndex);
  91493. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  91494. var match = sizeRegexp.exec(line);
  91495. // TODO. Support +Y and -X if needed.
  91496. if (!match || match.length < 3) {
  91497. throw "HDR Bad header format, no size";
  91498. }
  91499. width = parseInt(match[2]);
  91500. height = parseInt(match[1]);
  91501. if (width < 8 || width > 0x7fff) {
  91502. throw "HDR Bad header format, unsupported size";
  91503. }
  91504. lineIndex += (line.length + 1);
  91505. return {
  91506. height: height,
  91507. width: width,
  91508. dataPosition: lineIndex
  91509. };
  91510. };
  91511. /**
  91512. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  91513. * This RGBE texture needs to store the information as a panorama.
  91514. *
  91515. * More information on this format are available here:
  91516. * https://en.wikipedia.org/wiki/RGBE_image_format
  91517. *
  91518. * @param buffer The binary file stored in an array buffer.
  91519. * @param size The expected size of the extracted cubemap.
  91520. * @return The Cube Map information.
  91521. */
  91522. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  91523. var uint8array = new Uint8Array(buffer);
  91524. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  91525. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91526. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  91527. return cubeMapData;
  91528. };
  91529. /**
  91530. * Returns the pixels data extracted from an RGBE texture.
  91531. * This pixels will be stored left to right up to down in the R G B order in one array.
  91532. *
  91533. * More information on this format are available here:
  91534. * https://en.wikipedia.org/wiki/RGBE_image_format
  91535. *
  91536. * @param uint8array The binary file stored in an array buffer.
  91537. * @param hdrInfo The header information of the file.
  91538. * @return The pixels data in RGB right to left up to down order.
  91539. */
  91540. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  91541. // Keep for multi format supports.
  91542. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91543. };
  91544. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  91545. var num_scanlines = hdrInfo.height;
  91546. var scanline_width = hdrInfo.width;
  91547. var a, b, c, d, count;
  91548. var dataIndex = hdrInfo.dataPosition;
  91549. var index = 0, endIndex = 0, i = 0;
  91550. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  91551. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  91552. // 3 channels of 4 bytes per pixel in float.
  91553. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  91554. var resultArray = new Float32Array(resultBuffer);
  91555. // read in each successive scanline
  91556. while (num_scanlines > 0) {
  91557. a = uint8array[dataIndex++];
  91558. b = uint8array[dataIndex++];
  91559. c = uint8array[dataIndex++];
  91560. d = uint8array[dataIndex++];
  91561. if (a != 2 || b != 2 || (c & 0x80)) {
  91562. // this file is not run length encoded
  91563. throw "HDR Bad header format, not RLE";
  91564. }
  91565. if (((c << 8) | d) != scanline_width) {
  91566. throw "HDR Bad header format, wrong scan line width";
  91567. }
  91568. index = 0;
  91569. // read each of the four channels for the scanline into the buffer
  91570. for (i = 0; i < 4; i++) {
  91571. endIndex = (i + 1) * scanline_width;
  91572. while (index < endIndex) {
  91573. a = uint8array[dataIndex++];
  91574. b = uint8array[dataIndex++];
  91575. if (a > 128) {
  91576. // a run of the same value
  91577. count = a - 128;
  91578. if ((count == 0) || (count > endIndex - index)) {
  91579. throw "HDR Bad Format, bad scanline data (run)";
  91580. }
  91581. while (count-- > 0) {
  91582. scanLineArray[index++] = b;
  91583. }
  91584. }
  91585. else {
  91586. // a non-run
  91587. count = a;
  91588. if ((count == 0) || (count > endIndex - index)) {
  91589. throw "HDR Bad Format, bad scanline data (non-run)";
  91590. }
  91591. scanLineArray[index++] = b;
  91592. if (--count > 0) {
  91593. for (var j = 0; j < count; j++) {
  91594. scanLineArray[index++] = uint8array[dataIndex++];
  91595. }
  91596. }
  91597. }
  91598. }
  91599. }
  91600. // now convert data from buffer into floats
  91601. for (i = 0; i < scanline_width; i++) {
  91602. a = scanLineArray[i];
  91603. b = scanLineArray[i + scanline_width];
  91604. c = scanLineArray[i + 2 * scanline_width];
  91605. d = scanLineArray[i + 3 * scanline_width];
  91606. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  91607. }
  91608. num_scanlines--;
  91609. }
  91610. return resultArray;
  91611. };
  91612. return HDRTools;
  91613. }());
  91614. /***/ }),
  91615. /***/ "./Misc/HighDynamicRange/index.ts":
  91616. /*!****************************************!*\
  91617. !*** ./Misc/HighDynamicRange/index.ts ***!
  91618. \****************************************/
  91619. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  91620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91621. "use strict";
  91622. __webpack_require__.r(__webpack_exports__);
  91623. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  91624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  91625. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  91626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  91627. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  91629. /***/ }),
  91630. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  91631. /*!****************************************************!*\
  91632. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  91633. \****************************************************/
  91634. /*! exports provided: PanoramaToCubeMapTools */
  91635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91636. "use strict";
  91637. __webpack_require__.r(__webpack_exports__);
  91638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  91639. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91640. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91641. /**
  91642. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91643. */
  91644. var PanoramaToCubeMapTools = /** @class */ (function () {
  91645. function PanoramaToCubeMapTools() {
  91646. }
  91647. /**
  91648. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91649. *
  91650. * @param float32Array The source data.
  91651. * @param inputWidth The width of the input panorama.
  91652. * @param inputHeight The height of the input panorama.
  91653. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91654. * @return The cubemap data
  91655. */
  91656. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  91657. if (!float32Array) {
  91658. throw "ConvertPanoramaToCubemap: input cannot be null";
  91659. }
  91660. if (float32Array.length != inputWidth * inputHeight * 3) {
  91661. throw "ConvertPanoramaToCubemap: input size is wrong";
  91662. }
  91663. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  91664. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  91665. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  91666. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  91667. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  91668. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  91669. return {
  91670. front: textureFront,
  91671. back: textureBack,
  91672. left: textureLeft,
  91673. right: textureRight,
  91674. up: textureUp,
  91675. down: textureDown,
  91676. size: size,
  91677. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  91678. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  91679. gammaSpace: false,
  91680. };
  91681. };
  91682. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  91683. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  91684. var textureArray = new Float32Array(buffer);
  91685. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  91686. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  91687. var dy = 1 / texSize;
  91688. var fy = 0;
  91689. for (var y = 0; y < texSize; y++) {
  91690. var xv1 = faceData[0];
  91691. var xv2 = faceData[2];
  91692. for (var x = 0; x < texSize; x++) {
  91693. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  91694. v.normalize();
  91695. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  91696. // 3 channels per pixels
  91697. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  91698. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  91699. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  91700. xv1 = xv1.add(rotDX1);
  91701. xv2 = xv2.add(rotDX2);
  91702. }
  91703. fy += dy;
  91704. }
  91705. return textureArray;
  91706. };
  91707. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  91708. var theta = Math.atan2(vDir.z, vDir.x);
  91709. var phi = Math.acos(vDir.y);
  91710. while (theta < -Math.PI) {
  91711. theta += 2 * Math.PI;
  91712. }
  91713. while (theta > Math.PI) {
  91714. theta -= 2 * Math.PI;
  91715. }
  91716. var dx = theta / Math.PI;
  91717. var dy = phi / Math.PI;
  91718. // recenter.
  91719. dx = dx * 0.5 + 0.5;
  91720. var px = Math.round(dx * inputWidth);
  91721. if (px < 0) {
  91722. px = 0;
  91723. }
  91724. else if (px >= inputWidth) {
  91725. px = inputWidth - 1;
  91726. }
  91727. var py = Math.round(dy * inputHeight);
  91728. if (py < 0) {
  91729. py = 0;
  91730. }
  91731. else if (py >= inputHeight) {
  91732. py = inputHeight - 1;
  91733. }
  91734. var inputY = (inputHeight - py - 1);
  91735. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  91736. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  91737. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  91738. return {
  91739. r: r,
  91740. g: g,
  91741. b: b
  91742. };
  91743. };
  91744. PanoramaToCubeMapTools.FACE_FRONT = [
  91745. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91746. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91747. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91748. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  91749. ];
  91750. PanoramaToCubeMapTools.FACE_BACK = [
  91751. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91752. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91753. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  91754. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  91755. ];
  91756. PanoramaToCubeMapTools.FACE_RIGHT = [
  91757. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91758. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91759. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91760. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91761. ];
  91762. PanoramaToCubeMapTools.FACE_LEFT = [
  91763. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91764. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91765. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91766. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  91767. ];
  91768. PanoramaToCubeMapTools.FACE_DOWN = [
  91769. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91770. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91771. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91772. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91773. ];
  91774. PanoramaToCubeMapTools.FACE_UP = [
  91775. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91776. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91777. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91778. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  91779. ];
  91780. return PanoramaToCubeMapTools;
  91781. }());
  91782. /***/ }),
  91783. /***/ "./Misc/andOrNotEvaluator.ts":
  91784. /*!***********************************!*\
  91785. !*** ./Misc/andOrNotEvaluator.ts ***!
  91786. \***********************************/
  91787. /*! exports provided: AndOrNotEvaluator */
  91788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91789. "use strict";
  91790. __webpack_require__.r(__webpack_exports__);
  91791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  91792. /**
  91793. * Class used to evalaute queries containing `and` and `or` operators
  91794. */
  91795. var AndOrNotEvaluator = /** @class */ (function () {
  91796. function AndOrNotEvaluator() {
  91797. }
  91798. /**
  91799. * Evaluate a query
  91800. * @param query defines the query to evaluate
  91801. * @param evaluateCallback defines the callback used to filter result
  91802. * @returns true if the query matches
  91803. */
  91804. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  91805. if (!query.match(/\([^\(\)]*\)/g)) {
  91806. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  91807. }
  91808. else {
  91809. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  91810. // remove parenthesis
  91811. r = r.slice(1, r.length - 1);
  91812. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  91813. });
  91814. }
  91815. if (query === "true") {
  91816. return true;
  91817. }
  91818. if (query === "false") {
  91819. return false;
  91820. }
  91821. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  91822. };
  91823. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  91824. evaluateCallback = evaluateCallback || (function (r) {
  91825. return r === "true" ? true : false;
  91826. });
  91827. var result;
  91828. var or = parenthesisContent.split("||");
  91829. for (var i in or) {
  91830. if (or.hasOwnProperty(i)) {
  91831. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  91832. var and = ori.split("&&");
  91833. if (and.length > 1) {
  91834. for (var j = 0; j < and.length; ++j) {
  91835. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  91836. if (andj !== "true" && andj !== "false") {
  91837. if (andj[0] === "!") {
  91838. result = !evaluateCallback(andj.substring(1));
  91839. }
  91840. else {
  91841. result = evaluateCallback(andj);
  91842. }
  91843. }
  91844. else {
  91845. result = andj === "true" ? true : false;
  91846. }
  91847. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  91848. ori = "false";
  91849. break;
  91850. }
  91851. }
  91852. }
  91853. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  91854. result = true;
  91855. break;
  91856. }
  91857. // result equals false (or undefined)
  91858. if (ori !== "true" && ori !== "false") {
  91859. if (ori[0] === "!") {
  91860. result = !evaluateCallback(ori.substring(1));
  91861. }
  91862. else {
  91863. result = evaluateCallback(ori);
  91864. }
  91865. }
  91866. else {
  91867. result = ori === "true" ? true : false;
  91868. }
  91869. }
  91870. }
  91871. // the whole parenthesis scope is replaced by 'true' or 'false'
  91872. return result ? "true" : "false";
  91873. };
  91874. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  91875. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  91876. // remove whitespaces
  91877. r = r.replace(/[\s]/g, function () { return ""; });
  91878. return r.length % 2 ? "!" : "";
  91879. });
  91880. booleanString = booleanString.trim();
  91881. if (booleanString === "!true") {
  91882. booleanString = "false";
  91883. }
  91884. else if (booleanString === "!false") {
  91885. booleanString = "true";
  91886. }
  91887. return booleanString;
  91888. };
  91889. return AndOrNotEvaluator;
  91890. }());
  91891. /***/ }),
  91892. /***/ "./Misc/arrayTools.ts":
  91893. /*!****************************!*\
  91894. !*** ./Misc/arrayTools.ts ***!
  91895. \****************************/
  91896. /*! exports provided: ArrayTools */
  91897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91898. "use strict";
  91899. __webpack_require__.r(__webpack_exports__);
  91900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  91901. /**
  91902. * Class containing a set of static utilities functions for arrays.
  91903. */
  91904. var ArrayTools = /** @class */ (function () {
  91905. function ArrayTools() {
  91906. }
  91907. /**
  91908. * Returns an array of the given size filled with element built from the given constructor and the paramters
  91909. * @param size the number of element to construct and put in the array
  91910. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  91911. * @returns a new array filled with new objects
  91912. */
  91913. ArrayTools.BuildArray = function (size, itemBuilder) {
  91914. var a = [];
  91915. for (var i = 0; i < size; ++i) {
  91916. a.push(itemBuilder());
  91917. }
  91918. return a;
  91919. };
  91920. return ArrayTools;
  91921. }());
  91922. /***/ }),
  91923. /***/ "./Misc/assetsManager.ts":
  91924. /*!*******************************!*\
  91925. !*** ./Misc/assetsManager.ts ***!
  91926. \*******************************/
  91927. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  91928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91929. "use strict";
  91930. __webpack_require__.r(__webpack_exports__);
  91931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  91932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  91933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  91934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  91935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  91936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  91937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  91938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  91939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  91940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  91941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  91942. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91943. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  91944. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  91945. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  91946. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  91947. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  91948. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  91949. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91950. /**
  91951. * Defines the list of states available for a task inside a AssetsManager
  91952. */
  91953. var AssetTaskState;
  91954. (function (AssetTaskState) {
  91955. /**
  91956. * Initialization
  91957. */
  91958. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  91959. /**
  91960. * Running
  91961. */
  91962. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  91963. /**
  91964. * Done
  91965. */
  91966. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  91967. /**
  91968. * Error
  91969. */
  91970. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  91971. })(AssetTaskState || (AssetTaskState = {}));
  91972. /**
  91973. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  91974. */
  91975. var AbstractAssetTask = /** @class */ (function () {
  91976. /**
  91977. * Creates a new AssetsManager
  91978. * @param name defines the name of the task
  91979. */
  91980. function AbstractAssetTask(
  91981. /**
  91982. * Task name
  91983. */ name) {
  91984. this.name = name;
  91985. this._isCompleted = false;
  91986. this._taskState = AssetTaskState.INIT;
  91987. }
  91988. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  91989. /**
  91990. * Get if the task is completed
  91991. */
  91992. get: function () {
  91993. return this._isCompleted;
  91994. },
  91995. enumerable: true,
  91996. configurable: true
  91997. });
  91998. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  91999. /**
  92000. * Gets the current state of the task
  92001. */
  92002. get: function () {
  92003. return this._taskState;
  92004. },
  92005. enumerable: true,
  92006. configurable: true
  92007. });
  92008. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  92009. /**
  92010. * Gets the current error object (if task is in error)
  92011. */
  92012. get: function () {
  92013. return this._errorObject;
  92014. },
  92015. enumerable: true,
  92016. configurable: true
  92017. });
  92018. /**
  92019. * Internal only
  92020. * @hidden
  92021. */
  92022. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  92023. if (this._errorObject) {
  92024. return;
  92025. }
  92026. this._errorObject = {
  92027. message: message,
  92028. exception: exception
  92029. };
  92030. };
  92031. /**
  92032. * Execute the current task
  92033. * @param scene defines the scene where you want your assets to be loaded
  92034. * @param onSuccess is a callback called when the task is successfully executed
  92035. * @param onError is a callback called if an error occurs
  92036. */
  92037. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92038. var _this = this;
  92039. this._taskState = AssetTaskState.RUNNING;
  92040. this.runTask(scene, function () {
  92041. _this.onDoneCallback(onSuccess, onError);
  92042. }, function (msg, exception) {
  92043. _this.onErrorCallback(onError, msg, exception);
  92044. });
  92045. };
  92046. /**
  92047. * Execute the current task
  92048. * @param scene defines the scene where you want your assets to be loaded
  92049. * @param onSuccess is a callback called when the task is successfully executed
  92050. * @param onError is a callback called if an error occurs
  92051. */
  92052. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92053. throw new Error("runTask is not implemented");
  92054. };
  92055. /**
  92056. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  92057. * This can be used with failed tasks that have the reason for failure fixed.
  92058. */
  92059. AbstractAssetTask.prototype.reset = function () {
  92060. this._taskState = AssetTaskState.INIT;
  92061. };
  92062. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  92063. this._taskState = AssetTaskState.ERROR;
  92064. this._errorObject = {
  92065. message: message,
  92066. exception: exception
  92067. };
  92068. if (this.onError) {
  92069. this.onError(this, message, exception);
  92070. }
  92071. onError();
  92072. };
  92073. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  92074. try {
  92075. this._taskState = AssetTaskState.DONE;
  92076. this._isCompleted = true;
  92077. if (this.onSuccess) {
  92078. this.onSuccess(this);
  92079. }
  92080. onSuccess();
  92081. }
  92082. catch (e) {
  92083. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  92084. }
  92085. };
  92086. return AbstractAssetTask;
  92087. }());
  92088. /**
  92089. * Class used to share progress information about assets loading
  92090. */
  92091. var AssetsProgressEvent = /** @class */ (function () {
  92092. /**
  92093. * Creates a AssetsProgressEvent
  92094. * @param remainingCount defines the number of remaining tasks to process
  92095. * @param totalCount defines the total number of tasks
  92096. * @param task defines the task that was just processed
  92097. */
  92098. function AssetsProgressEvent(remainingCount, totalCount, task) {
  92099. this.remainingCount = remainingCount;
  92100. this.totalCount = totalCount;
  92101. this.task = task;
  92102. }
  92103. return AssetsProgressEvent;
  92104. }());
  92105. /**
  92106. * Define a task used by AssetsManager to load meshes
  92107. */
  92108. var MeshAssetTask = /** @class */ (function (_super) {
  92109. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  92110. /**
  92111. * Creates a new MeshAssetTask
  92112. * @param name defines the name of the task
  92113. * @param meshesNames defines the list of mesh's names you want to load
  92114. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  92115. * @param sceneFilename defines the filename of the scene to load from
  92116. */
  92117. function MeshAssetTask(
  92118. /**
  92119. * Defines the name of the task
  92120. */
  92121. name,
  92122. /**
  92123. * Defines the list of mesh's names you want to load
  92124. */
  92125. meshesNames,
  92126. /**
  92127. * Defines the root url to use as a base to load your meshes and associated resources
  92128. */
  92129. rootUrl,
  92130. /**
  92131. * Defines the filename of the scene to load from
  92132. */
  92133. sceneFilename) {
  92134. var _this = _super.call(this, name) || this;
  92135. _this.name = name;
  92136. _this.meshesNames = meshesNames;
  92137. _this.rootUrl = rootUrl;
  92138. _this.sceneFilename = sceneFilename;
  92139. return _this;
  92140. }
  92141. /**
  92142. * Execute the current task
  92143. * @param scene defines the scene where you want your assets to be loaded
  92144. * @param onSuccess is a callback called when the task is successfully executed
  92145. * @param onError is a callback called if an error occurs
  92146. */
  92147. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92148. var _this = this;
  92149. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  92150. _this.loadedMeshes = meshes;
  92151. _this.loadedParticleSystems = particleSystems;
  92152. _this.loadedSkeletons = skeletons;
  92153. _this.loadedAnimationGroups = animationGroups;
  92154. onSuccess();
  92155. }, null, function (scene, message, exception) {
  92156. onError(message, exception);
  92157. });
  92158. };
  92159. return MeshAssetTask;
  92160. }(AbstractAssetTask));
  92161. /**
  92162. * Define a task used by AssetsManager to load text content
  92163. */
  92164. var TextFileAssetTask = /** @class */ (function (_super) {
  92165. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  92166. /**
  92167. * Creates a new TextFileAssetTask object
  92168. * @param name defines the name of the task
  92169. * @param url defines the location of the file to load
  92170. */
  92171. function TextFileAssetTask(
  92172. /**
  92173. * Defines the name of the task
  92174. */
  92175. name,
  92176. /**
  92177. * Defines the location of the file to load
  92178. */
  92179. url) {
  92180. var _this = _super.call(this, name) || this;
  92181. _this.name = name;
  92182. _this.url = url;
  92183. return _this;
  92184. }
  92185. /**
  92186. * Execute the current task
  92187. * @param scene defines the scene where you want your assets to be loaded
  92188. * @param onSuccess is a callback called when the task is successfully executed
  92189. * @param onError is a callback called if an error occurs
  92190. */
  92191. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92192. var _this = this;
  92193. scene._loadFile(this.url, function (data) {
  92194. _this.text = data;
  92195. onSuccess();
  92196. }, undefined, false, false, function (request, exception) {
  92197. if (request) {
  92198. onError(request.status + " " + request.statusText, exception);
  92199. }
  92200. });
  92201. };
  92202. return TextFileAssetTask;
  92203. }(AbstractAssetTask));
  92204. /**
  92205. * Define a task used by AssetsManager to load binary data
  92206. */
  92207. var BinaryFileAssetTask = /** @class */ (function (_super) {
  92208. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  92209. /**
  92210. * Creates a new BinaryFileAssetTask object
  92211. * @param name defines the name of the new task
  92212. * @param url defines the location of the file to load
  92213. */
  92214. function BinaryFileAssetTask(
  92215. /**
  92216. * Defines the name of the task
  92217. */
  92218. name,
  92219. /**
  92220. * Defines the location of the file to load
  92221. */
  92222. url) {
  92223. var _this = _super.call(this, name) || this;
  92224. _this.name = name;
  92225. _this.url = url;
  92226. return _this;
  92227. }
  92228. /**
  92229. * Execute the current task
  92230. * @param scene defines the scene where you want your assets to be loaded
  92231. * @param onSuccess is a callback called when the task is successfully executed
  92232. * @param onError is a callback called if an error occurs
  92233. */
  92234. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92235. var _this = this;
  92236. scene._loadFile(this.url, function (data) {
  92237. _this.data = data;
  92238. onSuccess();
  92239. }, undefined, true, true, function (request, exception) {
  92240. if (request) {
  92241. onError(request.status + " " + request.statusText, exception);
  92242. }
  92243. });
  92244. };
  92245. return BinaryFileAssetTask;
  92246. }(AbstractAssetTask));
  92247. /**
  92248. * Define a task used by AssetsManager to load images
  92249. */
  92250. var ImageAssetTask = /** @class */ (function (_super) {
  92251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  92252. /**
  92253. * Creates a new ImageAssetTask
  92254. * @param name defines the name of the task
  92255. * @param url defines the location of the image to load
  92256. */
  92257. function ImageAssetTask(
  92258. /**
  92259. * Defines the name of the task
  92260. */
  92261. name,
  92262. /**
  92263. * Defines the location of the image to load
  92264. */
  92265. url) {
  92266. var _this = _super.call(this, name) || this;
  92267. _this.name = name;
  92268. _this.url = url;
  92269. return _this;
  92270. }
  92271. /**
  92272. * Execute the current task
  92273. * @param scene defines the scene where you want your assets to be loaded
  92274. * @param onSuccess is a callback called when the task is successfully executed
  92275. * @param onError is a callback called if an error occurs
  92276. */
  92277. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92278. var _this = this;
  92279. var img = new Image();
  92280. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  92281. img.onload = function () {
  92282. _this.image = img;
  92283. onSuccess();
  92284. };
  92285. img.onerror = function (err) {
  92286. onError("Error loading image", err);
  92287. };
  92288. img.src = this.url;
  92289. };
  92290. return ImageAssetTask;
  92291. }(AbstractAssetTask));
  92292. /**
  92293. * Define a task used by AssetsManager to load 2D textures
  92294. */
  92295. var TextureAssetTask = /** @class */ (function (_super) {
  92296. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  92297. /**
  92298. * Creates a new TextureAssetTask object
  92299. * @param name defines the name of the task
  92300. * @param url defines the location of the file to load
  92301. * @param noMipmap defines if mipmap should not be generated (default is false)
  92302. * @param invertY defines if texture must be inverted on Y axis (default is false)
  92303. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92304. */
  92305. function TextureAssetTask(
  92306. /**
  92307. * Defines the name of the task
  92308. */
  92309. name,
  92310. /**
  92311. * Defines the location of the file to load
  92312. */
  92313. url,
  92314. /**
  92315. * Defines if mipmap should not be generated (default is false)
  92316. */
  92317. noMipmap,
  92318. /**
  92319. * Defines if texture must be inverted on Y axis (default is false)
  92320. */
  92321. invertY,
  92322. /**
  92323. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92324. */
  92325. samplingMode) {
  92326. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92327. var _this = _super.call(this, name) || this;
  92328. _this.name = name;
  92329. _this.url = url;
  92330. _this.noMipmap = noMipmap;
  92331. _this.invertY = invertY;
  92332. _this.samplingMode = samplingMode;
  92333. return _this;
  92334. }
  92335. /**
  92336. * Execute the current task
  92337. * @param scene defines the scene where you want your assets to be loaded
  92338. * @param onSuccess is a callback called when the task is successfully executed
  92339. * @param onError is a callback called if an error occurs
  92340. */
  92341. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92342. var onload = function () {
  92343. onSuccess();
  92344. };
  92345. var onerror = function (message, exception) {
  92346. onError(message, exception);
  92347. };
  92348. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  92349. };
  92350. return TextureAssetTask;
  92351. }(AbstractAssetTask));
  92352. /**
  92353. * Define a task used by AssetsManager to load cube textures
  92354. */
  92355. var CubeTextureAssetTask = /** @class */ (function (_super) {
  92356. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  92357. /**
  92358. * Creates a new CubeTextureAssetTask
  92359. * @param name defines the name of the task
  92360. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92361. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92362. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92363. * @param files defines the explicit list of files (undefined by default)
  92364. */
  92365. function CubeTextureAssetTask(
  92366. /**
  92367. * Defines the name of the task
  92368. */
  92369. name,
  92370. /**
  92371. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92372. */
  92373. url,
  92374. /**
  92375. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92376. */
  92377. extensions,
  92378. /**
  92379. * Defines if mipmaps should not be generated (default is false)
  92380. */
  92381. noMipmap,
  92382. /**
  92383. * Defines the explicit list of files (undefined by default)
  92384. */
  92385. files) {
  92386. var _this = _super.call(this, name) || this;
  92387. _this.name = name;
  92388. _this.url = url;
  92389. _this.extensions = extensions;
  92390. _this.noMipmap = noMipmap;
  92391. _this.files = files;
  92392. return _this;
  92393. }
  92394. /**
  92395. * Execute the current task
  92396. * @param scene defines the scene where you want your assets to be loaded
  92397. * @param onSuccess is a callback called when the task is successfully executed
  92398. * @param onError is a callback called if an error occurs
  92399. */
  92400. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92401. var onload = function () {
  92402. onSuccess();
  92403. };
  92404. var onerror = function (message, exception) {
  92405. onError(message, exception);
  92406. };
  92407. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  92408. };
  92409. return CubeTextureAssetTask;
  92410. }(AbstractAssetTask));
  92411. /**
  92412. * Define a task used by AssetsManager to load HDR cube textures
  92413. */
  92414. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  92415. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  92416. /**
  92417. * Creates a new HDRCubeTextureAssetTask object
  92418. * @param name defines the name of the task
  92419. * @param url defines the location of the file to load
  92420. * @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.
  92421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92422. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92423. * @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)
  92424. * @param reserved Internal use only
  92425. */
  92426. function HDRCubeTextureAssetTask(
  92427. /**
  92428. * Defines the name of the task
  92429. */
  92430. name,
  92431. /**
  92432. * Defines the location of the file to load
  92433. */
  92434. url,
  92435. /**
  92436. * Defines the desired size (the more it increases the longer the generation will be)
  92437. */
  92438. size,
  92439. /**
  92440. * Defines if mipmaps should not be generated (default is false)
  92441. */
  92442. noMipmap,
  92443. /**
  92444. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92445. */
  92446. generateHarmonics,
  92447. /**
  92448. * 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)
  92449. */
  92450. gammaSpace,
  92451. /**
  92452. * Internal Use Only
  92453. */
  92454. reserved) {
  92455. if (noMipmap === void 0) { noMipmap = false; }
  92456. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92457. if (gammaSpace === void 0) { gammaSpace = false; }
  92458. if (reserved === void 0) { reserved = false; }
  92459. var _this = _super.call(this, name) || this;
  92460. _this.name = name;
  92461. _this.url = url;
  92462. _this.size = size;
  92463. _this.noMipmap = noMipmap;
  92464. _this.generateHarmonics = generateHarmonics;
  92465. _this.gammaSpace = gammaSpace;
  92466. _this.reserved = reserved;
  92467. return _this;
  92468. }
  92469. /**
  92470. * Execute the current task
  92471. * @param scene defines the scene where you want your assets to be loaded
  92472. * @param onSuccess is a callback called when the task is successfully executed
  92473. * @param onError is a callback called if an error occurs
  92474. */
  92475. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92476. var onload = function () {
  92477. onSuccess();
  92478. };
  92479. var onerror = function (message, exception) {
  92480. onError(message, exception);
  92481. };
  92482. 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);
  92483. };
  92484. return HDRCubeTextureAssetTask;
  92485. }(AbstractAssetTask));
  92486. /**
  92487. * This class can be used to easily import assets into a scene
  92488. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  92489. */
  92490. var AssetsManager = /** @class */ (function () {
  92491. /**
  92492. * Creates a new AssetsManager
  92493. * @param scene defines the scene to work on
  92494. */
  92495. function AssetsManager(scene) {
  92496. this._isLoading = false;
  92497. this._tasks = new Array();
  92498. this._waitingTasksCount = 0;
  92499. this._totalTasksCount = 0;
  92500. /**
  92501. * Observable called when all tasks are processed
  92502. */
  92503. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92504. /**
  92505. * Observable called when a task had an error
  92506. */
  92507. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92508. /**
  92509. * Observable called when a task is successful
  92510. */
  92511. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92512. /**
  92513. * Observable called when a task is done (whatever the result is)
  92514. */
  92515. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92516. /**
  92517. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  92518. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92519. */
  92520. this.useDefaultLoadingScreen = true;
  92521. this._scene = scene;
  92522. }
  92523. /**
  92524. * Add a MeshAssetTask to the list of active tasks
  92525. * @param taskName defines the name of the new task
  92526. * @param meshesNames defines the name of meshes to load
  92527. * @param rootUrl defines the root url to use to locate files
  92528. * @param sceneFilename defines the filename of the scene file
  92529. * @returns a new MeshAssetTask object
  92530. */
  92531. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  92532. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  92533. this._tasks.push(task);
  92534. return task;
  92535. };
  92536. /**
  92537. * Add a TextFileAssetTask to the list of active tasks
  92538. * @param taskName defines the name of the new task
  92539. * @param url defines the url of the file to load
  92540. * @returns a new TextFileAssetTask object
  92541. */
  92542. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  92543. var task = new TextFileAssetTask(taskName, url);
  92544. this._tasks.push(task);
  92545. return task;
  92546. };
  92547. /**
  92548. * Add a BinaryFileAssetTask to the list of active tasks
  92549. * @param taskName defines the name of the new task
  92550. * @param url defines the url of the file to load
  92551. * @returns a new BinaryFileAssetTask object
  92552. */
  92553. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  92554. var task = new BinaryFileAssetTask(taskName, url);
  92555. this._tasks.push(task);
  92556. return task;
  92557. };
  92558. /**
  92559. * Add a ImageAssetTask to the list of active tasks
  92560. * @param taskName defines the name of the new task
  92561. * @param url defines the url of the file to load
  92562. * @returns a new ImageAssetTask object
  92563. */
  92564. AssetsManager.prototype.addImageTask = function (taskName, url) {
  92565. var task = new ImageAssetTask(taskName, url);
  92566. this._tasks.push(task);
  92567. return task;
  92568. };
  92569. /**
  92570. * Add a TextureAssetTask to the list of active tasks
  92571. * @param taskName defines the name of the new task
  92572. * @param url defines the url of the file to load
  92573. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92574. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  92575. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  92576. * @returns a new TextureAssetTask object
  92577. */
  92578. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  92579. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92580. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  92581. this._tasks.push(task);
  92582. return task;
  92583. };
  92584. /**
  92585. * Add a CubeTextureAssetTask to the list of active tasks
  92586. * @param taskName defines the name of the new task
  92587. * @param url defines the url of the file to load
  92588. * @param extensions defines the extension to use to load the cube map (can be null)
  92589. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92590. * @param files defines the list of files to load (can be null)
  92591. * @returns a new CubeTextureAssetTask object
  92592. */
  92593. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  92594. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  92595. this._tasks.push(task);
  92596. return task;
  92597. };
  92598. /**
  92599. *
  92600. * Add a HDRCubeTextureAssetTask to the list of active tasks
  92601. * @param taskName defines the name of the new task
  92602. * @param url defines the url of the file to load
  92603. * @param size defines the size you want for the cubemap (can be null)
  92604. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92605. * @param generateHarmonics defines if you want to automatically generate (true by default)
  92606. * @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)
  92607. * @param reserved Internal use only
  92608. * @returns a new HDRCubeTextureAssetTask object
  92609. */
  92610. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  92611. if (noMipmap === void 0) { noMipmap = false; }
  92612. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92613. if (gammaSpace === void 0) { gammaSpace = false; }
  92614. if (reserved === void 0) { reserved = false; }
  92615. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  92616. this._tasks.push(task);
  92617. return task;
  92618. };
  92619. /**
  92620. * Remove a task from the assets manager.
  92621. * @param task the task to remove
  92622. */
  92623. AssetsManager.prototype.removeTask = function (task) {
  92624. var index = this._tasks.indexOf(task);
  92625. if (index > -1) {
  92626. this._tasks.splice(index, 1);
  92627. }
  92628. };
  92629. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  92630. this._waitingTasksCount--;
  92631. try {
  92632. if (this.onProgress) {
  92633. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  92634. }
  92635. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  92636. }
  92637. catch (e) {
  92638. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  92639. console.log(e);
  92640. }
  92641. if (this._waitingTasksCount === 0) {
  92642. try {
  92643. if (this.onFinish) {
  92644. this.onFinish(this._tasks);
  92645. }
  92646. // Let's remove successfull tasks
  92647. var currentTasks = this._tasks.slice();
  92648. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  92649. var task = currentTasks_1[_i];
  92650. if (task.taskState === AssetTaskState.DONE) {
  92651. var index = this._tasks.indexOf(task);
  92652. if (index > -1) {
  92653. this._tasks.splice(index, 1);
  92654. }
  92655. }
  92656. }
  92657. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92658. }
  92659. catch (e) {
  92660. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  92661. console.log(e);
  92662. }
  92663. this._isLoading = false;
  92664. this._scene.getEngine().hideLoadingUI();
  92665. }
  92666. };
  92667. AssetsManager.prototype._runTask = function (task) {
  92668. var _this = this;
  92669. var done = function () {
  92670. try {
  92671. if (_this.onTaskSuccess) {
  92672. _this.onTaskSuccess(task);
  92673. }
  92674. _this.onTaskSuccessObservable.notifyObservers(task);
  92675. _this._decreaseWaitingTasksCount(task);
  92676. }
  92677. catch (e) {
  92678. error("Error executing task success callbacks", e);
  92679. }
  92680. };
  92681. var error = function (message, exception) {
  92682. task._setErrorObject(message, exception);
  92683. if (_this.onTaskError) {
  92684. _this.onTaskError(task);
  92685. }
  92686. _this.onTaskErrorObservable.notifyObservers(task);
  92687. _this._decreaseWaitingTasksCount(task);
  92688. };
  92689. task.run(this._scene, done, error);
  92690. };
  92691. /**
  92692. * Reset the AssetsManager and remove all tasks
  92693. * @return the current instance of the AssetsManager
  92694. */
  92695. AssetsManager.prototype.reset = function () {
  92696. this._isLoading = false;
  92697. this._tasks = new Array();
  92698. return this;
  92699. };
  92700. /**
  92701. * Start the loading process
  92702. * @return the current instance of the AssetsManager
  92703. */
  92704. AssetsManager.prototype.load = function () {
  92705. if (this._isLoading) {
  92706. return this;
  92707. }
  92708. this._isLoading = true;
  92709. this._waitingTasksCount = this._tasks.length;
  92710. this._totalTasksCount = this._tasks.length;
  92711. if (this._waitingTasksCount === 0) {
  92712. this._isLoading = false;
  92713. if (this.onFinish) {
  92714. this.onFinish(this._tasks);
  92715. }
  92716. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92717. return this;
  92718. }
  92719. if (this.useDefaultLoadingScreen) {
  92720. this._scene.getEngine().displayLoadingUI();
  92721. }
  92722. for (var index = 0; index < this._tasks.length; index++) {
  92723. var task = this._tasks[index];
  92724. if (task.taskState === AssetTaskState.INIT) {
  92725. this._runTask(task);
  92726. }
  92727. }
  92728. return this;
  92729. };
  92730. return AssetsManager;
  92731. }());
  92732. /***/ }),
  92733. /***/ "./Misc/dds.ts":
  92734. /*!*********************!*\
  92735. !*** ./Misc/dds.ts ***!
  92736. \*********************/
  92737. /*! exports provided: DDSTools */
  92738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92739. "use strict";
  92740. __webpack_require__.r(__webpack_exports__);
  92741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  92742. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92743. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92744. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92745. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  92746. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  92747. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92748. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  92749. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  92750. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  92751. // All values and structures referenced from:
  92752. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  92753. var DDS_MAGIC = 0x20534444;
  92754. var
  92755. //DDSD_CAPS = 0x1,
  92756. //DDSD_HEIGHT = 0x2,
  92757. //DDSD_WIDTH = 0x4,
  92758. //DDSD_PITCH = 0x8,
  92759. //DDSD_PIXELFORMAT = 0x1000,
  92760. DDSD_MIPMAPCOUNT = 0x20000;
  92761. //DDSD_LINEARSIZE = 0x80000,
  92762. //DDSD_DEPTH = 0x800000;
  92763. // var DDSCAPS_COMPLEX = 0x8,
  92764. // DDSCAPS_MIPMAP = 0x400000,
  92765. // DDSCAPS_TEXTURE = 0x1000;
  92766. var DDSCAPS2_CUBEMAP = 0x200;
  92767. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  92768. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  92769. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  92770. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  92771. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  92772. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  92773. // DDSCAPS2_VOLUME = 0x200000;
  92774. var
  92775. //DDPF_ALPHAPIXELS = 0x1,
  92776. //DDPF_ALPHA = 0x2,
  92777. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  92778. //DDPF_YUV = 0x200,
  92779. DDPF_LUMINANCE = 0x20000;
  92780. function FourCCToInt32(value) {
  92781. return value.charCodeAt(0) +
  92782. (value.charCodeAt(1) << 8) +
  92783. (value.charCodeAt(2) << 16) +
  92784. (value.charCodeAt(3) << 24);
  92785. }
  92786. function Int32ToFourCC(value) {
  92787. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  92788. }
  92789. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  92790. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  92791. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  92792. var FOURCC_DX10 = FourCCToInt32("DX10");
  92793. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  92794. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  92795. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  92796. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  92797. var headerLengthInt = 31; // The header length in 32 bit ints
  92798. // Offsets into the header array
  92799. var off_magic = 0;
  92800. var off_size = 1;
  92801. var off_flags = 2;
  92802. var off_height = 3;
  92803. var off_width = 4;
  92804. var off_mipmapCount = 7;
  92805. var off_pfFlags = 20;
  92806. var off_pfFourCC = 21;
  92807. var off_RGBbpp = 22;
  92808. var off_RMask = 23;
  92809. var off_GMask = 24;
  92810. var off_BMask = 25;
  92811. var off_AMask = 26;
  92812. // var off_caps1 = 27;
  92813. var off_caps2 = 28;
  92814. // var off_caps3 = 29;
  92815. // var off_caps4 = 30;
  92816. var off_dxgiFormat = 32;
  92817. /**
  92818. * Class used to provide DDS decompression tools
  92819. */
  92820. var DDSTools = /** @class */ (function () {
  92821. function DDSTools() {
  92822. }
  92823. /**
  92824. * Gets DDS information from an array buffer
  92825. * @param arrayBuffer defines the array buffer to read data from
  92826. * @returns the DDS information
  92827. */
  92828. DDSTools.GetDDSInfo = function (arrayBuffer) {
  92829. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  92830. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  92831. var mipmapCount = 1;
  92832. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  92833. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92834. }
  92835. var fourCC = header[off_pfFourCC];
  92836. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  92837. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92838. switch (fourCC) {
  92839. case FOURCC_D3DFMT_R16G16B16A16F:
  92840. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92841. break;
  92842. case FOURCC_D3DFMT_R32G32B32A32F:
  92843. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92844. break;
  92845. case FOURCC_DX10:
  92846. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  92847. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92848. break;
  92849. }
  92850. }
  92851. return {
  92852. width: header[off_width],
  92853. height: header[off_height],
  92854. mipmapCount: mipmapCount,
  92855. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  92856. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  92857. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  92858. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  92859. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  92860. dxgiFormat: dxgiFormat,
  92861. textureType: textureType
  92862. };
  92863. };
  92864. DDSTools._ToHalfFloat = function (value) {
  92865. if (!DDSTools._FloatView) {
  92866. DDSTools._FloatView = new Float32Array(1);
  92867. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  92868. }
  92869. DDSTools._FloatView[0] = value;
  92870. var x = DDSTools._Int32View[0];
  92871. var bits = (x >> 16) & 0x8000; /* Get the sign */
  92872. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  92873. var e = (x >> 23) & 0xff; /* Using int is faster here */
  92874. /* If zero, or denormal, or exponent underflows too much for a denormal
  92875. * half, return signed zero. */
  92876. if (e < 103) {
  92877. return bits;
  92878. }
  92879. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  92880. if (e > 142) {
  92881. bits |= 0x7c00;
  92882. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  92883. * not Inf, so make sure we set one mantissa bit too. */
  92884. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  92885. return bits;
  92886. }
  92887. /* If exponent underflows but not too much, return a denormal */
  92888. if (e < 113) {
  92889. m |= 0x0800;
  92890. /* Extra rounding may overflow and set mantissa to 0 and exponent
  92891. * to 1, which is OK. */
  92892. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  92893. return bits;
  92894. }
  92895. bits |= ((e - 112) << 10) | (m >> 1);
  92896. bits += m & 1;
  92897. return bits;
  92898. };
  92899. DDSTools._FromHalfFloat = function (value) {
  92900. var s = (value & 0x8000) >> 15;
  92901. var e = (value & 0x7C00) >> 10;
  92902. var f = value & 0x03FF;
  92903. if (e === 0) {
  92904. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  92905. }
  92906. else if (e == 0x1F) {
  92907. return f ? NaN : ((s ? -1 : 1) * Infinity);
  92908. }
  92909. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  92910. };
  92911. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92912. var destArray = new Float32Array(dataLength);
  92913. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92914. var index = 0;
  92915. for (var y = 0; y < height; y++) {
  92916. for (var x = 0; x < width; x++) {
  92917. var srcPos = (x + y * width) * 4;
  92918. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  92919. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  92920. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  92921. if (DDSTools.StoreLODInAlphaChannel) {
  92922. destArray[index + 3] = lod;
  92923. }
  92924. else {
  92925. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  92926. }
  92927. index += 4;
  92928. }
  92929. }
  92930. return destArray;
  92931. };
  92932. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92933. if (DDSTools.StoreLODInAlphaChannel) {
  92934. var destArray = new Uint16Array(dataLength);
  92935. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92936. var index = 0;
  92937. for (var y = 0; y < height; y++) {
  92938. for (var x = 0; x < width; x++) {
  92939. var srcPos = (x + y * width) * 4;
  92940. destArray[index] = srcData[srcPos];
  92941. destArray[index + 1] = srcData[srcPos + 1];
  92942. destArray[index + 2] = srcData[srcPos + 2];
  92943. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  92944. index += 4;
  92945. }
  92946. }
  92947. return destArray;
  92948. }
  92949. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  92950. };
  92951. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92952. if (DDSTools.StoreLODInAlphaChannel) {
  92953. var destArray = new Float32Array(dataLength);
  92954. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92955. var index = 0;
  92956. for (var y = 0; y < height; y++) {
  92957. for (var x = 0; x < width; x++) {
  92958. var srcPos = (x + y * width) * 4;
  92959. destArray[index] = srcData[srcPos];
  92960. destArray[index + 1] = srcData[srcPos + 1];
  92961. destArray[index + 2] = srcData[srcPos + 2];
  92962. destArray[index + 3] = lod;
  92963. index += 4;
  92964. }
  92965. }
  92966. return destArray;
  92967. }
  92968. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  92969. };
  92970. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92971. var destArray = new Uint8Array(dataLength);
  92972. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92973. var index = 0;
  92974. for (var y = 0; y < height; y++) {
  92975. for (var x = 0; x < width; x++) {
  92976. var srcPos = (x + y * width) * 4;
  92977. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  92978. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  92979. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  92980. if (DDSTools.StoreLODInAlphaChannel) {
  92981. destArray[index + 3] = lod;
  92982. }
  92983. else {
  92984. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  92985. }
  92986. index += 4;
  92987. }
  92988. }
  92989. return destArray;
  92990. };
  92991. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92992. var destArray = new Uint8Array(dataLength);
  92993. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92994. var index = 0;
  92995. for (var y = 0; y < height; y++) {
  92996. for (var x = 0; x < width; x++) {
  92997. var srcPos = (x + y * width) * 4;
  92998. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  92999. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  93000. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  93001. if (DDSTools.StoreLODInAlphaChannel) {
  93002. destArray[index + 3] = lod;
  93003. }
  93004. else {
  93005. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  93006. }
  93007. index += 4;
  93008. }
  93009. }
  93010. return destArray;
  93011. };
  93012. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  93013. var byteArray = new Uint8Array(dataLength);
  93014. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93015. var index = 0;
  93016. for (var y = 0; y < height; y++) {
  93017. for (var x = 0; x < width; x++) {
  93018. var srcPos = (x + y * width) * 4;
  93019. byteArray[index] = srcData[srcPos + rOffset];
  93020. byteArray[index + 1] = srcData[srcPos + gOffset];
  93021. byteArray[index + 2] = srcData[srcPos + bOffset];
  93022. byteArray[index + 3] = srcData[srcPos + aOffset];
  93023. index += 4;
  93024. }
  93025. }
  93026. return byteArray;
  93027. };
  93028. DDSTools._ExtractLongWordOrder = function (value) {
  93029. if (value === 0 || value === 255 || value === -16777216) {
  93030. return 0;
  93031. }
  93032. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  93033. };
  93034. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  93035. var byteArray = new Uint8Array(dataLength);
  93036. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93037. var index = 0;
  93038. for (var y = 0; y < height; y++) {
  93039. for (var x = 0; x < width; x++) {
  93040. var srcPos = (x + y * width) * 3;
  93041. byteArray[index] = srcData[srcPos + rOffset];
  93042. byteArray[index + 1] = srcData[srcPos + gOffset];
  93043. byteArray[index + 2] = srcData[srcPos + bOffset];
  93044. index += 3;
  93045. }
  93046. }
  93047. return byteArray;
  93048. };
  93049. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  93050. var byteArray = new Uint8Array(dataLength);
  93051. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93052. var index = 0;
  93053. for (var y = 0; y < height; y++) {
  93054. for (var x = 0; x < width; x++) {
  93055. var srcPos = (x + y * width);
  93056. byteArray[index] = srcData[srcPos];
  93057. index++;
  93058. }
  93059. }
  93060. return byteArray;
  93061. };
  93062. /**
  93063. * Uploads DDS Levels to a Babylon Texture
  93064. * @hidden
  93065. */
  93066. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  93067. if (lodIndex === void 0) { lodIndex = -1; }
  93068. var sphericalPolynomialFaces = null;
  93069. if (info.sphericalPolynomial) {
  93070. sphericalPolynomialFaces = new Array();
  93071. }
  93072. var ext = engine.getCaps().s3tc;
  93073. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  93074. var fourCC, width, height, dataLength = 0, dataOffset;
  93075. var byteArray, mipmapCount, mip;
  93076. var internalCompressedFormat = 0;
  93077. var blockBytes = 1;
  93078. if (header[off_magic] !== DDS_MAGIC) {
  93079. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  93080. return;
  93081. }
  93082. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  93083. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  93084. return;
  93085. }
  93086. if (info.isCompressed && !ext) {
  93087. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  93088. return;
  93089. }
  93090. var bpp = header[off_RGBbpp];
  93091. dataOffset = header[off_size] + 4;
  93092. var computeFormats = false;
  93093. if (info.isFourCC) {
  93094. fourCC = header[off_pfFourCC];
  93095. switch (fourCC) {
  93096. case FOURCC_DXT1:
  93097. blockBytes = 8;
  93098. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  93099. break;
  93100. case FOURCC_DXT3:
  93101. blockBytes = 16;
  93102. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  93103. break;
  93104. case FOURCC_DXT5:
  93105. blockBytes = 16;
  93106. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  93107. break;
  93108. case FOURCC_D3DFMT_R16G16B16A16F:
  93109. computeFormats = true;
  93110. break;
  93111. case FOURCC_D3DFMT_R32G32B32A32F:
  93112. computeFormats = true;
  93113. break;
  93114. case FOURCC_DX10:
  93115. // There is an additionnal header so dataOffset need to be changed
  93116. dataOffset += 5 * 4; // 5 uints
  93117. var supported = false;
  93118. switch (info.dxgiFormat) {
  93119. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  93120. computeFormats = true;
  93121. supported = true;
  93122. break;
  93123. case DXGI_FORMAT_B8G8R8X8_UNORM:
  93124. info.isRGB = true;
  93125. info.isFourCC = false;
  93126. bpp = 32;
  93127. supported = true;
  93128. break;
  93129. }
  93130. if (supported) {
  93131. break;
  93132. }
  93133. default:
  93134. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  93135. return;
  93136. }
  93137. }
  93138. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  93139. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  93140. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  93141. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  93142. if (computeFormats) {
  93143. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  93144. }
  93145. mipmapCount = 1;
  93146. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  93147. mipmapCount = Math.max(1, header[off_mipmapCount]);
  93148. }
  93149. for (var face = 0; face < faces; face++) {
  93150. width = header[off_width];
  93151. height = header[off_height];
  93152. for (mip = 0; mip < mipmapCount; ++mip) {
  93153. if (lodIndex === -1 || lodIndex === mip) {
  93154. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  93155. var i = (lodIndex === -1) ? mip : 0;
  93156. if (!info.isCompressed && info.isFourCC) {
  93157. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93158. dataLength = width * height * 4;
  93159. var floatArray = null;
  93160. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  93161. if (bpp === 128) {
  93162. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93163. if (sphericalPolynomialFaces && i == 0) {
  93164. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93165. }
  93166. }
  93167. else if (bpp === 64) {
  93168. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93169. if (sphericalPolynomialFaces && i == 0) {
  93170. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93171. }
  93172. }
  93173. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93174. }
  93175. else {
  93176. if (bpp === 128) {
  93177. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93178. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93179. if (sphericalPolynomialFaces && i == 0) {
  93180. sphericalPolynomialFaces.push(floatArray);
  93181. }
  93182. }
  93183. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  93184. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93185. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93186. if (sphericalPolynomialFaces && i == 0) {
  93187. sphericalPolynomialFaces.push(floatArray);
  93188. }
  93189. }
  93190. else { // 64
  93191. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93192. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93193. if (sphericalPolynomialFaces && i == 0) {
  93194. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93195. }
  93196. }
  93197. }
  93198. if (floatArray) {
  93199. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  93200. }
  93201. }
  93202. else if (info.isRGB) {
  93203. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93204. if (bpp === 24) {
  93205. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  93206. dataLength = width * height * 3;
  93207. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  93208. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93209. }
  93210. else { // 32
  93211. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93212. dataLength = width * height * 4;
  93213. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  93214. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93215. }
  93216. }
  93217. else if (info.isLuminance) {
  93218. var unpackAlignment = engine._getUnpackAlignement();
  93219. var unpaddedRowSize = width;
  93220. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  93221. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  93222. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  93223. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  93224. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93225. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93226. }
  93227. else {
  93228. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  93229. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  93230. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93231. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  93232. }
  93233. }
  93234. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  93235. width *= 0.5;
  93236. height *= 0.5;
  93237. width = Math.max(1.0, width);
  93238. height = Math.max(1.0, height);
  93239. }
  93240. if (currentFace !== undefined) {
  93241. // Loading a single face
  93242. break;
  93243. }
  93244. }
  93245. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  93246. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  93247. size: header[off_width],
  93248. right: sphericalPolynomialFaces[0],
  93249. left: sphericalPolynomialFaces[1],
  93250. up: sphericalPolynomialFaces[2],
  93251. down: sphericalPolynomialFaces[3],
  93252. front: sphericalPolynomialFaces[4],
  93253. back: sphericalPolynomialFaces[5],
  93254. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  93255. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  93256. gammaSpace: false,
  93257. });
  93258. }
  93259. else {
  93260. info.sphericalPolynomial = undefined;
  93261. }
  93262. };
  93263. /**
  93264. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  93265. */
  93266. DDSTools.StoreLODInAlphaChannel = false;
  93267. return DDSTools;
  93268. }());
  93269. /**
  93270. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  93271. * @param rootUrl defines the url where the file to load is located
  93272. * @param scene defines the current scene
  93273. * @param lodScale defines scale to apply to the mip map selection
  93274. * @param lodOffset defines offset to apply to the mip map selection
  93275. * @param onLoad defines an optional callback raised when the texture is loaded
  93276. * @param onError defines an optional callback raised if there is an issue to load the texture
  93277. * @param format defines the format of the data
  93278. * @param forcedExtension defines the extension to use to pick the right loader
  93279. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  93280. * @returns the cube texture as an InternalTexture
  93281. */
  93282. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  93283. var _this = this;
  93284. if (onLoad === void 0) { onLoad = null; }
  93285. if (onError === void 0) { onError = null; }
  93286. if (forcedExtension === void 0) { forcedExtension = null; }
  93287. if (createPolynomials === void 0) { createPolynomials = true; }
  93288. var callback = function (loadData) {
  93289. if (!loadData) {
  93290. if (onLoad) {
  93291. onLoad(null);
  93292. }
  93293. return;
  93294. }
  93295. var texture = loadData.texture;
  93296. if (!createPolynomials) {
  93297. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  93298. }
  93299. else if (loadData.info.sphericalPolynomial) {
  93300. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  93301. }
  93302. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  93303. if (_this.getCaps().textureLOD) {
  93304. // Do not add extra process if texture lod is supported.
  93305. if (onLoad) {
  93306. onLoad(texture);
  93307. }
  93308. return;
  93309. }
  93310. var mipSlices = 3;
  93311. var gl = _this._gl;
  93312. var width = loadData.width;
  93313. if (!width) {
  93314. return;
  93315. }
  93316. var textures = [];
  93317. for (var i = 0; i < mipSlices; i++) {
  93318. //compute LOD from even spacing in smoothness (matching shader calculation)
  93319. var smoothness = i / (mipSlices - 1);
  93320. var roughness = 1 - smoothness;
  93321. var minLODIndex = lodOffset; // roughness = 0
  93322. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  93323. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  93324. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  93325. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  93326. glTextureFromLod.type = texture.type;
  93327. glTextureFromLod.format = texture.format;
  93328. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  93329. glTextureFromLod.height = glTextureFromLod.width;
  93330. glTextureFromLod.isCube = true;
  93331. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  93332. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  93333. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  93334. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  93335. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  93336. if (loadData.isDDS) {
  93337. var info = loadData.info;
  93338. var data = loadData.data;
  93339. _this._unpackFlipY(info.isCompressed);
  93340. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  93341. }
  93342. else {
  93343. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  93344. }
  93345. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  93346. // Wrap in a base texture for easy binding.
  93347. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  93348. lodTexture.isCube = true;
  93349. lodTexture._texture = glTextureFromLod;
  93350. glTextureFromLod.isReady = true;
  93351. textures.push(lodTexture);
  93352. }
  93353. texture._lodTextureHigh = textures[2];
  93354. texture._lodTextureMid = textures[1];
  93355. texture._lodTextureLow = textures[0];
  93356. if (onLoad) {
  93357. onLoad(texture);
  93358. }
  93359. };
  93360. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  93361. };
  93362. /***/ }),
  93363. /***/ "./Misc/decorators.ts":
  93364. /*!****************************!*\
  93365. !*** ./Misc/decorators.ts ***!
  93366. \****************************/
  93367. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  93368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93369. "use strict";
  93370. __webpack_require__.r(__webpack_exports__);
  93371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  93372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  93373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  93374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  93375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  93376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  93377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  93378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  93379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  93380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  93381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  93382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  93383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  93384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  93385. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  93386. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93387. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  93388. var __decoratorInitialStore = {};
  93389. var __mergedStore = {};
  93390. var _copySource = function (creationFunction, source, instanciate) {
  93391. var destination = creationFunction();
  93392. // Tags
  93393. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93394. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93395. }
  93396. var classStore = getMergedStore(destination);
  93397. // Properties
  93398. for (var property in classStore) {
  93399. var propertyDescriptor = classStore[property];
  93400. var sourceProperty = source[property];
  93401. var propertyType = propertyDescriptor.type;
  93402. if (sourceProperty !== undefined && sourceProperty !== null) {
  93403. switch (propertyType) {
  93404. case 0: // Value
  93405. case 6: // Mesh reference
  93406. case 11: // Camera reference
  93407. destination[property] = sourceProperty;
  93408. break;
  93409. case 1: // Texture
  93410. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  93411. break;
  93412. case 2: // Color3
  93413. case 3: // FresnelParameters
  93414. case 4: // Vector2
  93415. case 5: // Vector3
  93416. case 7: // Color Curves
  93417. case 10: // Quaternion
  93418. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  93419. break;
  93420. }
  93421. }
  93422. }
  93423. return destination;
  93424. };
  93425. function getDirectStore(target) {
  93426. var classKey = target.getClassName();
  93427. if (!__decoratorInitialStore[classKey]) {
  93428. __decoratorInitialStore[classKey] = {};
  93429. }
  93430. return __decoratorInitialStore[classKey];
  93431. }
  93432. /**
  93433. * Return the list of properties flagged as serializable
  93434. * @param target: host object
  93435. */
  93436. function getMergedStore(target) {
  93437. var classKey = target.getClassName();
  93438. if (__mergedStore[classKey]) {
  93439. return __mergedStore[classKey];
  93440. }
  93441. __mergedStore[classKey] = {};
  93442. var store = __mergedStore[classKey];
  93443. var currentTarget = target;
  93444. var currentKey = classKey;
  93445. while (currentKey) {
  93446. var initialStore = __decoratorInitialStore[currentKey];
  93447. for (var property in initialStore) {
  93448. store[property] = initialStore[property];
  93449. }
  93450. var parent_1 = void 0;
  93451. var done = false;
  93452. do {
  93453. parent_1 = Object.getPrototypeOf(currentTarget);
  93454. if (!parent_1.getClassName) {
  93455. done = true;
  93456. break;
  93457. }
  93458. if (parent_1.getClassName() !== currentKey) {
  93459. break;
  93460. }
  93461. currentTarget = parent_1;
  93462. } while (parent_1);
  93463. if (done) {
  93464. break;
  93465. }
  93466. currentKey = parent_1.getClassName();
  93467. currentTarget = parent_1;
  93468. }
  93469. return store;
  93470. }
  93471. function generateSerializableMember(type, sourceName) {
  93472. return function (target, propertyKey) {
  93473. var classStore = getDirectStore(target);
  93474. if (!classStore[propertyKey]) {
  93475. classStore[propertyKey] = { type: type, sourceName: sourceName };
  93476. }
  93477. };
  93478. }
  93479. function generateExpandMember(setCallback, targetKey) {
  93480. if (targetKey === void 0) { targetKey = null; }
  93481. return function (target, propertyKey) {
  93482. var key = targetKey || ("_" + propertyKey);
  93483. Object.defineProperty(target, propertyKey, {
  93484. get: function () {
  93485. return this[key];
  93486. },
  93487. set: function (value) {
  93488. if (this[key] === value) {
  93489. return;
  93490. }
  93491. this[key] = value;
  93492. target[setCallback].apply(this);
  93493. },
  93494. enumerable: true,
  93495. configurable: true
  93496. });
  93497. };
  93498. }
  93499. function expandToProperty(callback, targetKey) {
  93500. if (targetKey === void 0) { targetKey = null; }
  93501. return generateExpandMember(callback, targetKey);
  93502. }
  93503. function serialize(sourceName) {
  93504. return generateSerializableMember(0, sourceName); // value member
  93505. }
  93506. function serializeAsTexture(sourceName) {
  93507. return generateSerializableMember(1, sourceName); // texture member
  93508. }
  93509. function serializeAsColor3(sourceName) {
  93510. return generateSerializableMember(2, sourceName); // color3 member
  93511. }
  93512. function serializeAsFresnelParameters(sourceName) {
  93513. return generateSerializableMember(3, sourceName); // fresnel parameters member
  93514. }
  93515. function serializeAsVector2(sourceName) {
  93516. return generateSerializableMember(4, sourceName); // vector2 member
  93517. }
  93518. function serializeAsVector3(sourceName) {
  93519. return generateSerializableMember(5, sourceName); // vector3 member
  93520. }
  93521. function serializeAsMeshReference(sourceName) {
  93522. return generateSerializableMember(6, sourceName); // mesh reference member
  93523. }
  93524. function serializeAsColorCurves(sourceName) {
  93525. return generateSerializableMember(7, sourceName); // color curves
  93526. }
  93527. function serializeAsColor4(sourceName) {
  93528. return generateSerializableMember(8, sourceName); // color 4
  93529. }
  93530. function serializeAsImageProcessingConfiguration(sourceName) {
  93531. return generateSerializableMember(9, sourceName); // image processing
  93532. }
  93533. function serializeAsQuaternion(sourceName) {
  93534. return generateSerializableMember(10, sourceName); // quaternion member
  93535. }
  93536. /**
  93537. * Decorator used to define property that can be serialized as reference to a camera
  93538. * @param sourceName defines the name of the property to decorate
  93539. */
  93540. function serializeAsCameraReference(sourceName) {
  93541. return generateSerializableMember(11, sourceName); // camera reference member
  93542. }
  93543. /**
  93544. * Class used to help serialization objects
  93545. */
  93546. var SerializationHelper = /** @class */ (function () {
  93547. function SerializationHelper() {
  93548. }
  93549. /**
  93550. * Appends the serialized animations from the source animations
  93551. * @param source Source containing the animations
  93552. * @param destination Target to store the animations
  93553. */
  93554. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  93555. if (source.animations) {
  93556. destination.animations = [];
  93557. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  93558. var animation = source.animations[animationIndex];
  93559. destination.animations.push(animation.serialize());
  93560. }
  93561. }
  93562. };
  93563. /**
  93564. * Static function used to serialized a specific entity
  93565. * @param entity defines the entity to serialize
  93566. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93567. * @returns a JSON compatible object representing the serialization of the entity
  93568. */
  93569. SerializationHelper.Serialize = function (entity, serializationObject) {
  93570. if (!serializationObject) {
  93571. serializationObject = {};
  93572. }
  93573. // Tags
  93574. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93575. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  93576. }
  93577. var serializedProperties = getMergedStore(entity);
  93578. // Properties
  93579. for (var property in serializedProperties) {
  93580. var propertyDescriptor = serializedProperties[property];
  93581. var targetPropertyName = propertyDescriptor.sourceName || property;
  93582. var propertyType = propertyDescriptor.type;
  93583. var sourceProperty = entity[property];
  93584. if (sourceProperty !== undefined && sourceProperty !== null) {
  93585. switch (propertyType) {
  93586. case 0: // Value
  93587. serializationObject[targetPropertyName] = sourceProperty;
  93588. break;
  93589. case 1: // Texture
  93590. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93591. break;
  93592. case 2: // Color3
  93593. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93594. break;
  93595. case 3: // FresnelParameters
  93596. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93597. break;
  93598. case 4: // Vector2
  93599. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93600. break;
  93601. case 5: // Vector3
  93602. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93603. break;
  93604. case 6: // Mesh reference
  93605. serializationObject[targetPropertyName] = sourceProperty.id;
  93606. break;
  93607. case 7: // Color Curves
  93608. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93609. break;
  93610. case 8: // Color 4
  93611. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93612. break;
  93613. case 9: // Image Processing
  93614. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93615. break;
  93616. case 10: // Quaternion
  93617. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93618. break;
  93619. case 11: // Camera reference
  93620. serializationObject[targetPropertyName] = sourceProperty.id;
  93621. break;
  93622. }
  93623. }
  93624. }
  93625. return serializationObject;
  93626. };
  93627. /**
  93628. * Creates a new entity from a serialization data object
  93629. * @param creationFunction defines a function used to instanciated the new entity
  93630. * @param source defines the source serialization data
  93631. * @param scene defines the hosting scene
  93632. * @param rootUrl defines the root url for resources
  93633. * @returns a new entity
  93634. */
  93635. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  93636. if (rootUrl === void 0) { rootUrl = null; }
  93637. var destination = creationFunction();
  93638. if (!rootUrl) {
  93639. rootUrl = "";
  93640. }
  93641. // Tags
  93642. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93643. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93644. }
  93645. var classStore = getMergedStore(destination);
  93646. // Properties
  93647. for (var property in classStore) {
  93648. var propertyDescriptor = classStore[property];
  93649. var sourceProperty = source[propertyDescriptor.sourceName || property];
  93650. var propertyType = propertyDescriptor.type;
  93651. if (sourceProperty !== undefined && sourceProperty !== null) {
  93652. var dest = destination;
  93653. switch (propertyType) {
  93654. case 0: // Value
  93655. dest[property] = sourceProperty;
  93656. break;
  93657. case 1: // Texture
  93658. if (scene) {
  93659. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  93660. }
  93661. break;
  93662. case 2: // Color3
  93663. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  93664. break;
  93665. case 3: // FresnelParameters
  93666. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  93667. break;
  93668. case 4: // Vector2
  93669. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  93670. break;
  93671. case 5: // Vector3
  93672. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  93673. break;
  93674. case 6: // Mesh reference
  93675. if (scene) {
  93676. dest[property] = scene.getLastMeshByID(sourceProperty);
  93677. }
  93678. break;
  93679. case 7: // Color Curves
  93680. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  93681. break;
  93682. case 8: // Color 4
  93683. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  93684. break;
  93685. case 9: // Image Processing
  93686. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  93687. break;
  93688. case 10: // Quaternion
  93689. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  93690. break;
  93691. case 11: // Camera reference
  93692. if (scene) {
  93693. dest[property] = scene.getCameraByID(sourceProperty);
  93694. }
  93695. break;
  93696. }
  93697. }
  93698. }
  93699. return destination;
  93700. };
  93701. /**
  93702. * Clones an object
  93703. * @param creationFunction defines the function used to instanciate the new object
  93704. * @param source defines the source object
  93705. * @returns the cloned object
  93706. */
  93707. SerializationHelper.Clone = function (creationFunction, source) {
  93708. return _copySource(creationFunction, source, false);
  93709. };
  93710. /**
  93711. * Instanciates a new object based on a source one (some data will be shared between both object)
  93712. * @param creationFunction defines the function used to instanciate the new object
  93713. * @param source defines the source object
  93714. * @returns the new object
  93715. */
  93716. SerializationHelper.Instanciate = function (creationFunction, source) {
  93717. return _copySource(creationFunction, source, true);
  93718. };
  93719. /** hidden */
  93720. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  93721. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  93722. };
  93723. /** hidden */
  93724. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  93725. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  93726. };
  93727. /** hidden */
  93728. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  93729. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  93730. };
  93731. /** hidden */
  93732. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  93733. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  93734. };
  93735. return SerializationHelper;
  93736. }());
  93737. /***/ }),
  93738. /***/ "./Misc/deepCopier.ts":
  93739. /*!****************************!*\
  93740. !*** ./Misc/deepCopier.ts ***!
  93741. \****************************/
  93742. /*! exports provided: DeepCopier */
  93743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93744. "use strict";
  93745. __webpack_require__.r(__webpack_exports__);
  93746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  93747. var cloneValue = function (source, destinationObject) {
  93748. if (!source) {
  93749. return null;
  93750. }
  93751. if (source.getClassName && source.getClassName() === "Mesh") {
  93752. return null;
  93753. }
  93754. if (source.getClassName && source.getClassName() === "SubMesh") {
  93755. return source.clone(destinationObject);
  93756. }
  93757. else if (source.clone) {
  93758. return source.clone();
  93759. }
  93760. return null;
  93761. };
  93762. /**
  93763. * Class containing a set of static utilities functions for deep copy.
  93764. */
  93765. var DeepCopier = /** @class */ (function () {
  93766. function DeepCopier() {
  93767. }
  93768. /**
  93769. * Tries to copy an object by duplicating every property
  93770. * @param source defines the source object
  93771. * @param destination defines the target object
  93772. * @param doNotCopyList defines a list of properties to avoid
  93773. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93774. */
  93775. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  93776. for (var prop in source) {
  93777. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  93778. continue;
  93779. }
  93780. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  93781. continue;
  93782. }
  93783. var sourceValue = source[prop];
  93784. var typeOfSourceValue = typeof sourceValue;
  93785. if (typeOfSourceValue === "function") {
  93786. continue;
  93787. }
  93788. try {
  93789. if (typeOfSourceValue === "object") {
  93790. if (sourceValue instanceof Array) {
  93791. destination[prop] = [];
  93792. if (sourceValue.length > 0) {
  93793. if (typeof sourceValue[0] == "object") {
  93794. for (var index = 0; index < sourceValue.length; index++) {
  93795. var clonedValue = cloneValue(sourceValue[index], destination);
  93796. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  93797. destination[prop].push(clonedValue);
  93798. }
  93799. }
  93800. }
  93801. else {
  93802. destination[prop] = sourceValue.slice(0);
  93803. }
  93804. }
  93805. }
  93806. else {
  93807. destination[prop] = cloneValue(sourceValue, destination);
  93808. }
  93809. }
  93810. else {
  93811. destination[prop] = sourceValue;
  93812. }
  93813. }
  93814. catch (e) {
  93815. // Just ignore error (it could be because of a read-only property)
  93816. }
  93817. }
  93818. };
  93819. return DeepCopier;
  93820. }());
  93821. /***/ }),
  93822. /***/ "./Misc/deferred.ts":
  93823. /*!**************************!*\
  93824. !*** ./Misc/deferred.ts ***!
  93825. \**************************/
  93826. /*! exports provided: Deferred */
  93827. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93828. "use strict";
  93829. __webpack_require__.r(__webpack_exports__);
  93830. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  93831. /**
  93832. * Wrapper class for promise with external resolve and reject.
  93833. */
  93834. var Deferred = /** @class */ (function () {
  93835. /**
  93836. * Constructor for this deferred object.
  93837. */
  93838. function Deferred() {
  93839. var _this = this;
  93840. this.promise = new Promise(function (resolve, reject) {
  93841. _this._resolve = resolve;
  93842. _this._reject = reject;
  93843. });
  93844. }
  93845. Object.defineProperty(Deferred.prototype, "resolve", {
  93846. /**
  93847. * The resolve method of the promise associated with this deferred object.
  93848. */
  93849. get: function () {
  93850. return this._resolve;
  93851. },
  93852. enumerable: true,
  93853. configurable: true
  93854. });
  93855. Object.defineProperty(Deferred.prototype, "reject", {
  93856. /**
  93857. * The reject method of the promise associated with this deferred object.
  93858. */
  93859. get: function () {
  93860. return this._reject;
  93861. },
  93862. enumerable: true,
  93863. configurable: true
  93864. });
  93865. return Deferred;
  93866. }());
  93867. /***/ }),
  93868. /***/ "./Misc/devTools.ts":
  93869. /*!**************************!*\
  93870. !*** ./Misc/devTools.ts ***!
  93871. \**************************/
  93872. /*! exports provided: _DevTools */
  93873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93874. "use strict";
  93875. __webpack_require__.r(__webpack_exports__);
  93876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  93877. /** @hidden */
  93878. var _DevTools = /** @class */ (function () {
  93879. function _DevTools() {
  93880. }
  93881. _DevTools.WarnImport = function (name) {
  93882. return name + " needs to be imported before as it contains a side-effect required by your code.";
  93883. };
  93884. return _DevTools;
  93885. }());
  93886. /***/ }),
  93887. /***/ "./Misc/domManagement.ts":
  93888. /*!*******************************!*\
  93889. !*** ./Misc/domManagement.ts ***!
  93890. \*******************************/
  93891. /*! exports provided: DomManagement */
  93892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93893. "use strict";
  93894. __webpack_require__.r(__webpack_exports__);
  93895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  93896. /**
  93897. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  93898. * Babylon.js
  93899. */
  93900. var DomManagement = /** @class */ (function () {
  93901. function DomManagement() {
  93902. }
  93903. /**
  93904. * Checks if the window object exists
  93905. * @returns true if the window object exists
  93906. */
  93907. DomManagement.IsWindowObjectExist = function () {
  93908. return (typeof window) !== "undefined";
  93909. };
  93910. /**
  93911. * Extracts text content from a DOM element hierarchy
  93912. * @param element defines the root element
  93913. * @returns a string
  93914. */
  93915. DomManagement.GetDOMTextContent = function (element) {
  93916. var result = "";
  93917. var child = element.firstChild;
  93918. while (child) {
  93919. if (child.nodeType === 3) {
  93920. result += child.textContent;
  93921. }
  93922. child = (child.nextSibling);
  93923. }
  93924. return result;
  93925. };
  93926. return DomManagement;
  93927. }());
  93928. /***/ }),
  93929. /***/ "./Misc/environmentTextureTools.ts":
  93930. /*!*****************************************!*\
  93931. !*** ./Misc/environmentTextureTools.ts ***!
  93932. \*****************************************/
  93933. /*! exports provided: EnvironmentTextureTools */
  93934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93935. "use strict";
  93936. __webpack_require__.r(__webpack_exports__);
  93937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  93938. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93939. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93940. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  93941. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  93942. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  93943. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  93944. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93945. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  93946. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  93947. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93948. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  93949. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  93950. /**
  93951. * Sets of helpers addressing the serialization and deserialization of environment texture
  93952. * stored in a BabylonJS env file.
  93953. * Those files are usually stored as .env files.
  93954. */
  93955. var EnvironmentTextureTools = /** @class */ (function () {
  93956. function EnvironmentTextureTools() {
  93957. }
  93958. /**
  93959. * Gets the environment info from an env file.
  93960. * @param data The array buffer containing the .env bytes.
  93961. * @returns the environment file info (the json header) if successfully parsed.
  93962. */
  93963. EnvironmentTextureTools.GetEnvInfo = function (data) {
  93964. var dataView = new DataView(data);
  93965. var pos = 0;
  93966. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  93967. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  93968. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  93969. return null;
  93970. }
  93971. }
  93972. // Read json manifest - collect characters up to null terminator
  93973. var manifestString = '';
  93974. var charCode = 0x00;
  93975. while ((charCode = dataView.getUint8(pos++))) {
  93976. manifestString += String.fromCharCode(charCode);
  93977. }
  93978. var manifest = JSON.parse(manifestString);
  93979. if (manifest.specular) {
  93980. // Extend the header with the position of the payload.
  93981. manifest.specular.specularDataPosition = pos;
  93982. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  93983. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  93984. }
  93985. return manifest;
  93986. };
  93987. /**
  93988. * Creates an environment texture from a loaded cube texture.
  93989. * @param texture defines the cube texture to convert in env file
  93990. * @return a promise containing the environment data if succesfull.
  93991. */
  93992. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  93993. var _this = this;
  93994. var internalTexture = texture.getInternalTexture();
  93995. if (!internalTexture) {
  93996. return Promise.reject("The cube texture is invalid.");
  93997. }
  93998. if (!texture._prefiltered) {
  93999. return Promise.reject("The cube texture is invalid (not prefiltered).");
  94000. }
  94001. var engine = internalTexture.getEngine();
  94002. if (engine && engine.premultipliedAlpha) {
  94003. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  94004. }
  94005. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  94006. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  94007. }
  94008. var canvas = engine.getRenderingCanvas();
  94009. if (!canvas) {
  94010. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  94011. }
  94012. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94013. if (!engine.getCaps().textureFloatRender) {
  94014. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94015. if (!engine.getCaps().textureHalfFloatRender) {
  94016. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  94017. }
  94018. }
  94019. var cubeWidth = internalTexture.width;
  94020. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  94021. var specularTextures = {};
  94022. var promises = [];
  94023. // Read and collect all mipmaps data from the cube.
  94024. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  94025. mipmapsCount = Math.round(mipmapsCount);
  94026. var _loop_1 = function (i) {
  94027. var faceWidth = Math.pow(2, mipmapsCount - i);
  94028. var _loop_2 = function (face) {
  94029. var data = texture.readPixels(face, i);
  94030. // Creates a temp texture with the face data.
  94031. 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);
  94032. // And rgbdEncode them.
  94033. var promise = new Promise(function (resolve, reject) {
  94034. 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);
  94035. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94036. rgbdPostProcess.onApply = function (effect) {
  94037. effect._bindTexture("textureSampler", tempTexture);
  94038. };
  94039. // As the process needs to happen on the main canvas, keep track of the current size
  94040. var currentW = engine.getRenderWidth();
  94041. var currentH = engine.getRenderHeight();
  94042. // Set the desired size for the texture
  94043. engine.setSize(faceWidth, faceWidth);
  94044. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  94045. // Reading datas from WebGL
  94046. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  94047. var fileReader = new FileReader();
  94048. fileReader.onload = function (event) {
  94049. var arrayBuffer = event.target.result;
  94050. specularTextures[i * 6 + face] = arrayBuffer;
  94051. resolve();
  94052. };
  94053. fileReader.readAsArrayBuffer(blob);
  94054. });
  94055. // Reapply the previous canvas size
  94056. engine.setSize(currentW, currentH);
  94057. });
  94058. });
  94059. promises.push(promise);
  94060. };
  94061. // All faces of the cube.
  94062. for (var face = 0; face < 6; face++) {
  94063. _loop_2(face);
  94064. }
  94065. };
  94066. for (var i = 0; i <= mipmapsCount; i++) {
  94067. _loop_1(i);
  94068. }
  94069. // Once all the textures haves been collected as RGBD stored in PNGs
  94070. return Promise.all(promises).then(function () {
  94071. // We can delete the hosting scene keeping track of all the creation objects
  94072. hostingScene.dispose();
  94073. // Creates the json header for the env texture
  94074. var info = {
  94075. version: 1,
  94076. width: cubeWidth,
  94077. irradiance: _this._CreateEnvTextureIrradiance(texture),
  94078. specular: {
  94079. mipmaps: [],
  94080. lodGenerationScale: texture.lodGenerationScale
  94081. }
  94082. };
  94083. // Sets the specular image data information
  94084. var position = 0;
  94085. for (var i = 0; i <= mipmapsCount; i++) {
  94086. for (var face = 0; face < 6; face++) {
  94087. var byteLength = specularTextures[i * 6 + face].byteLength;
  94088. info.specular.mipmaps.push({
  94089. length: byteLength,
  94090. position: position
  94091. });
  94092. position += byteLength;
  94093. }
  94094. }
  94095. // Encode the JSON as an array buffer
  94096. var infoString = JSON.stringify(info);
  94097. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  94098. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  94099. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  94100. infoView[i] = infoString.charCodeAt(i);
  94101. }
  94102. // Ends up with a null terminator for easier parsing
  94103. infoView[infoString.length] = 0x00;
  94104. // Computes the final required size and creates the storage
  94105. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  94106. var finalBuffer = new ArrayBuffer(totalSize);
  94107. var finalBufferView = new Uint8Array(finalBuffer);
  94108. var dataView = new DataView(finalBuffer);
  94109. // Copy the magic bytes identifying the file in
  94110. var pos = 0;
  94111. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  94112. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  94113. }
  94114. // Add the json info
  94115. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  94116. pos += infoBuffer.byteLength;
  94117. // Finally inserts the texture data
  94118. for (var i = 0; i <= mipmapsCount; i++) {
  94119. for (var face = 0; face < 6; face++) {
  94120. var dataBuffer = specularTextures[i * 6 + face];
  94121. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  94122. pos += dataBuffer.byteLength;
  94123. }
  94124. }
  94125. // Voila
  94126. return finalBuffer;
  94127. });
  94128. };
  94129. /**
  94130. * Creates a JSON representation of the spherical data.
  94131. * @param texture defines the texture containing the polynomials
  94132. * @return the JSON representation of the spherical info
  94133. */
  94134. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  94135. var polynmials = texture.sphericalPolynomial;
  94136. if (polynmials == null) {
  94137. return null;
  94138. }
  94139. return {
  94140. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  94141. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  94142. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  94143. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  94144. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  94145. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  94146. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  94147. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  94148. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  94149. };
  94150. };
  94151. /**
  94152. * Uploads the texture info contained in the env file to the GPU.
  94153. * @param texture defines the internal texture to upload to
  94154. * @param arrayBuffer defines the buffer cotaining the data to load
  94155. * @param info defines the texture info retrieved through the GetEnvInfo method
  94156. * @returns a promise
  94157. */
  94158. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  94159. if (info.version !== 1) {
  94160. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  94161. }
  94162. var specularInfo = info.specular;
  94163. if (!specularInfo) {
  94164. // Nothing else parsed so far
  94165. return Promise.resolve();
  94166. }
  94167. // Double checks the enclosed info
  94168. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  94169. mipmapsCount = Math.round(mipmapsCount) + 1;
  94170. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  94171. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  94172. }
  94173. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  94174. var imageData = new Array(mipmapsCount);
  94175. for (var i = 0; i < mipmapsCount; i++) {
  94176. imageData[i] = new Array(6);
  94177. for (var face = 0; face < 6; face++) {
  94178. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  94179. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  94180. }
  94181. }
  94182. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  94183. };
  94184. /**
  94185. * Uploads the levels of image data to the GPU.
  94186. * @param texture defines the internal texture to upload to
  94187. * @param imageData defines the array buffer views of image data [mipmap][face]
  94188. * @returns a promise
  94189. */
  94190. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  94191. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  94192. throw new Error("Texture size must be a power of two");
  94193. }
  94194. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  94195. // Gets everything ready.
  94196. var engine = texture.getEngine();
  94197. var expandTexture = false;
  94198. var generateNonLODTextures = false;
  94199. var rgbdPostProcess = null;
  94200. var cubeRtt = null;
  94201. var lodTextures = null;
  94202. var caps = engine.getCaps();
  94203. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  94204. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94205. texture.generateMipMaps = true;
  94206. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  94207. // Add extra process if texture lod is not supported
  94208. if (!caps.textureLOD) {
  94209. expandTexture = false;
  94210. generateNonLODTextures = true;
  94211. lodTextures = {};
  94212. }
  94213. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  94214. else if (engine.webGLVersion < 2) {
  94215. expandTexture = false;
  94216. }
  94217. // If half float available we can uncompress the texture
  94218. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  94219. expandTexture = true;
  94220. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94221. }
  94222. // If full float available we can uncompress the texture
  94223. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  94224. expandTexture = true;
  94225. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94226. }
  94227. // Expand the texture if possible
  94228. if (expandTexture) {
  94229. // Simply run through the decode PP
  94230. 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);
  94231. texture._isRGBD = false;
  94232. texture.invertY = false;
  94233. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  94234. generateDepthBuffer: false,
  94235. generateMipMaps: true,
  94236. generateStencilBuffer: false,
  94237. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  94238. type: texture.type,
  94239. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  94240. });
  94241. }
  94242. else {
  94243. texture._isRGBD = true;
  94244. texture.invertY = true;
  94245. // In case of missing support, applies the same patch than DDS files.
  94246. if (generateNonLODTextures) {
  94247. var mipSlices = 3;
  94248. var scale = texture._lodGenerationScale;
  94249. var offset = texture._lodGenerationOffset;
  94250. for (var i = 0; i < mipSlices; i++) {
  94251. //compute LOD from even spacing in smoothness (matching shader calculation)
  94252. var smoothness = i / (mipSlices - 1);
  94253. var roughness = 1 - smoothness;
  94254. var minLODIndex = offset; // roughness = 0
  94255. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  94256. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  94257. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  94258. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  94259. glTextureFromLod.isCube = true;
  94260. glTextureFromLod.invertY = true;
  94261. glTextureFromLod.generateMipMaps = false;
  94262. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  94263. // Wrap in a base texture for easy binding.
  94264. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  94265. lodTexture.isCube = true;
  94266. lodTexture._texture = glTextureFromLod;
  94267. lodTextures[mipmapIndex] = lodTexture;
  94268. switch (i) {
  94269. case 0:
  94270. texture._lodTextureLow = lodTexture;
  94271. break;
  94272. case 1:
  94273. texture._lodTextureMid = lodTexture;
  94274. break;
  94275. case 2:
  94276. texture._lodTextureHigh = lodTexture;
  94277. break;
  94278. }
  94279. }
  94280. }
  94281. }
  94282. var promises = [];
  94283. var _loop_3 = function (i) {
  94284. var _loop_4 = function (face) {
  94285. // Constructs an image element from image data
  94286. var bytes = imageData[i][face];
  94287. var blob = new Blob([bytes], { type: 'image/png' });
  94288. var url = URL.createObjectURL(blob);
  94289. var image = new Image();
  94290. image.src = url;
  94291. // Enqueue promise to upload to the texture.
  94292. var promise = new Promise(function (resolve, reject) {
  94293. image.onload = function () {
  94294. if (expandTexture) {
  94295. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  94296. reject(message);
  94297. }, image);
  94298. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94299. // Uncompress the data to a RTT
  94300. rgbdPostProcess.onApply = function (effect) {
  94301. effect._bindTexture("textureSampler", tempTexture_1);
  94302. effect.setFloat2("scale", 1, 1);
  94303. };
  94304. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  94305. // Cleanup
  94306. engine.restoreDefaultFramebuffer();
  94307. tempTexture_1.dispose();
  94308. window.URL.revokeObjectURL(url);
  94309. resolve();
  94310. });
  94311. }
  94312. else {
  94313. engine._uploadImageToTexture(texture, image, face, i);
  94314. // Upload the face to the non lod texture support
  94315. if (generateNonLODTextures) {
  94316. var lodTexture = lodTextures[i];
  94317. if (lodTexture) {
  94318. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  94319. }
  94320. }
  94321. resolve();
  94322. }
  94323. };
  94324. image.onerror = function (error) {
  94325. reject(error);
  94326. };
  94327. });
  94328. promises.push(promise);
  94329. };
  94330. // All faces
  94331. for (var face = 0; face < 6; face++) {
  94332. _loop_4(face);
  94333. }
  94334. };
  94335. // All mipmaps up to provided number of images
  94336. for (var i = 0; i < imageData.length; i++) {
  94337. _loop_3(i);
  94338. }
  94339. // Fill remaining mipmaps with black textures.
  94340. if (imageData.length < mipmapsCount) {
  94341. var data = void 0;
  94342. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  94343. var dataLength = size * size * 4;
  94344. switch (texture.type) {
  94345. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  94346. data = new Uint8Array(dataLength);
  94347. break;
  94348. }
  94349. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  94350. data = new Uint16Array(dataLength);
  94351. break;
  94352. }
  94353. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  94354. data = new Float32Array(dataLength);
  94355. break;
  94356. }
  94357. }
  94358. for (var i = imageData.length; i < mipmapsCount; i++) {
  94359. for (var face = 0; face < 6; face++) {
  94360. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  94361. }
  94362. }
  94363. }
  94364. // Once all done, finishes the cleanup and return
  94365. return Promise.all(promises).then(function () {
  94366. // Release temp RTT.
  94367. if (cubeRtt) {
  94368. engine._releaseFramebufferObjects(cubeRtt);
  94369. cubeRtt._swapAndDie(texture);
  94370. }
  94371. // Release temp Post Process.
  94372. if (rgbdPostProcess) {
  94373. rgbdPostProcess.dispose();
  94374. }
  94375. // Flag internal texture as ready in case they are in use.
  94376. if (generateNonLODTextures) {
  94377. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  94378. texture._lodTextureHigh._texture.isReady = true;
  94379. }
  94380. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  94381. texture._lodTextureMid._texture.isReady = true;
  94382. }
  94383. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  94384. texture._lodTextureLow._texture.isReady = true;
  94385. }
  94386. }
  94387. });
  94388. };
  94389. /**
  94390. * Uploads spherical polynomials information to the texture.
  94391. * @param texture defines the texture we are trying to upload the information to
  94392. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  94393. */
  94394. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  94395. if (info.version !== 1) {
  94396. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  94397. }
  94398. var irradianceInfo = info.irradiance;
  94399. if (!irradianceInfo) {
  94400. return;
  94401. }
  94402. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  94403. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  94404. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  94405. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  94406. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  94407. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  94408. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  94409. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  94410. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  94411. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  94412. texture._sphericalPolynomial = sp;
  94413. };
  94414. /** @hidden */
  94415. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  94416. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  94417. internalTexture._bufferViewArrayArray = data;
  94418. internalTexture._lodGenerationScale = lodScale;
  94419. internalTexture._lodGenerationOffset = lodOffset;
  94420. internalTexture._sphericalPolynomial = sphericalPolynomial;
  94421. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  94422. internalTexture.isReady = true;
  94423. });
  94424. };
  94425. /**
  94426. * Magic number identifying the env file.
  94427. */
  94428. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  94429. return EnvironmentTextureTools;
  94430. }());
  94431. // References the dependencies.
  94432. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  94433. /***/ }),
  94434. /***/ "./Misc/filesInput.ts":
  94435. /*!****************************!*\
  94436. !*** ./Misc/filesInput.ts ***!
  94437. \****************************/
  94438. /*! exports provided: FilesInput */
  94439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94440. "use strict";
  94441. __webpack_require__.r(__webpack_exports__);
  94442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  94443. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  94444. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94445. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94446. /**
  94447. * Class used to help managing file picking and drag'n'drop
  94448. */
  94449. var FilesInput = /** @class */ (function () {
  94450. /**
  94451. * Creates a new FilesInput
  94452. * @param engine defines the rendering engine
  94453. * @param scene defines the hosting scene
  94454. * @param sceneLoadedCallback callback called when scene is loaded
  94455. * @param progressCallback callback called to track progress
  94456. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  94457. * @param textureLoadingCallback callback called when a texture is loading
  94458. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  94459. * @param onReloadCallback callback called when a reload is requested
  94460. * @param errorCallback callback call if an error occurs
  94461. */
  94462. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  94463. /**
  94464. * Callback called when a file is processed
  94465. */
  94466. this.onProcessFileCallback = function () { return true; };
  94467. this._engine = engine;
  94468. this._currentScene = scene;
  94469. this._sceneLoadedCallback = sceneLoadedCallback;
  94470. this._progressCallback = progressCallback;
  94471. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  94472. this._textureLoadingCallback = textureLoadingCallback;
  94473. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  94474. this._onReloadCallback = onReloadCallback;
  94475. this._errorCallback = errorCallback;
  94476. }
  94477. Object.defineProperty(FilesInput, "FilesToLoad", {
  94478. /**
  94479. * List of files ready to be loaded
  94480. */
  94481. get: function () {
  94482. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  94483. },
  94484. enumerable: true,
  94485. configurable: true
  94486. });
  94487. /**
  94488. * Calls this function to listen to drag'n'drop events on a specific DOM element
  94489. * @param elementToMonitor defines the DOM element to track
  94490. */
  94491. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  94492. var _this = this;
  94493. if (elementToMonitor) {
  94494. this._elementToMonitor = elementToMonitor;
  94495. this._dragEnterHandler = function (e) { _this.drag(e); };
  94496. this._dragOverHandler = function (e) { _this.drag(e); };
  94497. this._dropHandler = function (e) { _this.drop(e); };
  94498. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  94499. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  94500. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  94501. }
  94502. };
  94503. /**
  94504. * Release all associated resources
  94505. */
  94506. FilesInput.prototype.dispose = function () {
  94507. if (!this._elementToMonitor) {
  94508. return;
  94509. }
  94510. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  94511. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  94512. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  94513. };
  94514. FilesInput.prototype.renderFunction = function () {
  94515. if (this._additionalRenderLoopLogicCallback) {
  94516. this._additionalRenderLoopLogicCallback();
  94517. }
  94518. if (this._currentScene) {
  94519. if (this._textureLoadingCallback) {
  94520. var remaining = this._currentScene.getWaitingItemsCount();
  94521. if (remaining > 0) {
  94522. this._textureLoadingCallback(remaining);
  94523. }
  94524. }
  94525. this._currentScene.render();
  94526. }
  94527. };
  94528. FilesInput.prototype.drag = function (e) {
  94529. e.stopPropagation();
  94530. e.preventDefault();
  94531. };
  94532. FilesInput.prototype.drop = function (eventDrop) {
  94533. eventDrop.stopPropagation();
  94534. eventDrop.preventDefault();
  94535. this.loadFiles(eventDrop);
  94536. };
  94537. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  94538. var _this = this;
  94539. var reader = folder.createReader();
  94540. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  94541. reader.readEntries(function (entries) {
  94542. remaining.count += entries.length;
  94543. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  94544. var entry = entries_1[_i];
  94545. if (entry.isFile) {
  94546. entry.file(function (file) {
  94547. file.correctName = relativePath + file.name;
  94548. files.push(file);
  94549. if (--remaining.count === 0) {
  94550. callback();
  94551. }
  94552. });
  94553. }
  94554. else if (entry.isDirectory) {
  94555. _this._traverseFolder(entry, files, remaining, callback);
  94556. }
  94557. }
  94558. if (--remaining.count) {
  94559. callback();
  94560. }
  94561. });
  94562. };
  94563. FilesInput.prototype._processFiles = function (files) {
  94564. for (var i = 0; i < files.length; i++) {
  94565. var name = files[i].correctName.toLowerCase();
  94566. var extension = name.split('.').pop();
  94567. if (!this.onProcessFileCallback(files[i], name, extension)) {
  94568. continue;
  94569. }
  94570. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  94571. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  94572. this._sceneFileToLoad = files[i];
  94573. }
  94574. FilesInput.FilesToLoad[name] = files[i];
  94575. }
  94576. };
  94577. /**
  94578. * Load files from a drop event
  94579. * @param event defines the drop event to use as source
  94580. */
  94581. FilesInput.prototype.loadFiles = function (event) {
  94582. var _this = this;
  94583. // Handling data transfer via drag'n'drop
  94584. if (event && event.dataTransfer && event.dataTransfer.files) {
  94585. this._filesToLoad = event.dataTransfer.files;
  94586. }
  94587. // Handling files from input files
  94588. if (event && event.target && event.target.files) {
  94589. this._filesToLoad = event.target.files;
  94590. }
  94591. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  94592. return;
  94593. }
  94594. if (this._startingProcessingFilesCallback) {
  94595. this._startingProcessingFilesCallback(this._filesToLoad);
  94596. }
  94597. if (this._filesToLoad && this._filesToLoad.length > 0) {
  94598. var files_1 = new Array();
  94599. var folders = [];
  94600. var items = event.dataTransfer ? event.dataTransfer.items : null;
  94601. for (var i = 0; i < this._filesToLoad.length; i++) {
  94602. var fileToLoad = this._filesToLoad[i];
  94603. var name_1 = fileToLoad.name.toLowerCase();
  94604. var entry = void 0;
  94605. fileToLoad.correctName = name_1;
  94606. if (items) {
  94607. var item = items[i];
  94608. if (item.getAsEntry) {
  94609. entry = item.getAsEntry();
  94610. }
  94611. else if (item.webkitGetAsEntry) {
  94612. entry = item.webkitGetAsEntry();
  94613. }
  94614. }
  94615. if (!entry) {
  94616. files_1.push(fileToLoad);
  94617. }
  94618. else {
  94619. if (entry.isDirectory) {
  94620. folders.push(entry);
  94621. }
  94622. else {
  94623. files_1.push(fileToLoad);
  94624. }
  94625. }
  94626. }
  94627. if (folders.length === 0) {
  94628. this._processFiles(files_1);
  94629. this._processReload();
  94630. }
  94631. else {
  94632. var remaining = { count: folders.length };
  94633. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  94634. var folder = folders_1[_i];
  94635. this._traverseFolder(folder, files_1, remaining, function () {
  94636. _this._processFiles(files_1);
  94637. if (remaining.count === 0) {
  94638. _this._processReload();
  94639. }
  94640. });
  94641. }
  94642. }
  94643. }
  94644. };
  94645. FilesInput.prototype._processReload = function () {
  94646. if (this._onReloadCallback) {
  94647. this._onReloadCallback(this._sceneFileToLoad);
  94648. }
  94649. else {
  94650. this.reload();
  94651. }
  94652. };
  94653. /**
  94654. * Reload the current scene from the loaded files
  94655. */
  94656. FilesInput.prototype.reload = function () {
  94657. var _this = this;
  94658. // If a scene file has been provided
  94659. if (this._sceneFileToLoad) {
  94660. if (this._currentScene) {
  94661. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  94662. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  94663. }
  94664. this._engine.stopRenderLoop();
  94665. }
  94666. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  94667. if (_this._progressCallback) {
  94668. _this._progressCallback(progress);
  94669. }
  94670. }).then(function (scene) {
  94671. if (_this._currentScene) {
  94672. _this._currentScene.dispose();
  94673. }
  94674. _this._currentScene = scene;
  94675. if (_this._sceneLoadedCallback) {
  94676. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  94677. }
  94678. // Wait for textures and shaders to be ready
  94679. _this._currentScene.executeWhenReady(function () {
  94680. _this._engine.runRenderLoop(function () {
  94681. _this.renderFunction();
  94682. });
  94683. });
  94684. }).catch(function (error) {
  94685. if (_this._errorCallback) {
  94686. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  94687. }
  94688. });
  94689. }
  94690. else {
  94691. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  94692. }
  94693. };
  94694. return FilesInput;
  94695. }());
  94696. /***/ }),
  94697. /***/ "./Misc/filesInputStore.ts":
  94698. /*!*********************************!*\
  94699. !*** ./Misc/filesInputStore.ts ***!
  94700. \*********************************/
  94701. /*! exports provided: FilesInputStore */
  94702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94703. "use strict";
  94704. __webpack_require__.r(__webpack_exports__);
  94705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  94706. /**
  94707. * Class used to help managing file picking and drag'n'drop
  94708. * File Storage
  94709. */
  94710. var FilesInputStore = /** @class */ (function () {
  94711. function FilesInputStore() {
  94712. }
  94713. /**
  94714. * List of files ready to be loaded
  94715. */
  94716. FilesInputStore.FilesToLoad = {};
  94717. return FilesInputStore;
  94718. }());
  94719. /***/ }),
  94720. /***/ "./Misc/index.ts":
  94721. /*!***********************!*\
  94722. !*** ./Misc/index.ts ***!
  94723. \***********************/
  94724. /*! 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 */
  94725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94726. "use strict";
  94727. __webpack_require__.r(__webpack_exports__);
  94728. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  94729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  94730. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  94731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  94732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  94733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  94734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  94735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  94736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  94737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  94738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  94739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  94740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  94741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  94742. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  94743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  94744. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  94745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  94746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  94747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  94748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  94749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  94750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  94751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  94752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  94753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  94754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  94755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  94756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  94757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  94758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  94759. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  94760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  94761. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  94762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  94763. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  94764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  94765. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  94766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  94767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  94768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  94769. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  94770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  94771. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  94773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  94774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  94775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  94776. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  94777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  94778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  94779. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  94780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  94781. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  94782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  94783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  94784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  94785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  94786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  94787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  94788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  94789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  94790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  94791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  94792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  94793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  94794. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  94795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  94796. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  94797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  94798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  94799. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  94800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  94801. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  94802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  94803. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  94804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  94805. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  94806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  94807. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  94809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  94810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  94811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  94812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  94813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  94814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  94815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  94816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  94817. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  94818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  94819. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  94820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  94821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  94822. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  94823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  94824. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  94825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  94826. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  94827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  94828. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  94830. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  94831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  94832. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  94833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  94834. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  94835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  94836. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  94837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  94838. /* empty/unused harmony star reexport */
  94839. /***/ }),
  94840. /***/ "./Misc/khronosTextureContainer.ts":
  94841. /*!*****************************************!*\
  94842. !*** ./Misc/khronosTextureContainer.ts ***!
  94843. \*****************************************/
  94844. /*! exports provided: KhronosTextureContainer */
  94845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94846. "use strict";
  94847. __webpack_require__.r(__webpack_exports__);
  94848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  94849. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94850. /**
  94851. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94852. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94853. */
  94854. var KhronosTextureContainer = /** @class */ (function () {
  94855. /**
  94856. * Creates a new KhronosTextureContainer
  94857. * @param arrayBuffer contents of the KTX container file
  94858. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  94859. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  94860. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  94861. */
  94862. function KhronosTextureContainer(
  94863. /** contents of the KTX container file */
  94864. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  94865. this.arrayBuffer = arrayBuffer;
  94866. /**
  94867. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  94868. */
  94869. this.isInvalid = false;
  94870. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  94871. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  94872. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  94873. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  94874. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  94875. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  94876. this.isInvalid = true;
  94877. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  94878. return;
  94879. }
  94880. // load the reset of the header in native 32 bit uint
  94881. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  94882. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  94883. var endianness = headerDataView.getUint32(0, true);
  94884. var littleEndian = endianness === 0x04030201;
  94885. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  94886. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  94887. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  94888. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  94889. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  94890. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  94891. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  94892. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  94893. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  94894. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  94895. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  94896. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  94897. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  94898. if (this.glType !== 0) {
  94899. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  94900. return;
  94901. }
  94902. else {
  94903. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  94904. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  94905. }
  94906. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  94907. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  94908. return;
  94909. }
  94910. if (this.numberOfArrayElements !== 0) {
  94911. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  94912. return;
  94913. }
  94914. if (this.numberOfFaces !== facesExpected) {
  94915. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  94916. return;
  94917. }
  94918. // we now have a completely validated file, so could use existence of loadType as success
  94919. // would need to make this more elaborate & adjust checks above to support more than one load type
  94920. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  94921. }
  94922. /**
  94923. * Uploads KTX content to a Babylon Texture.
  94924. * It is assumed that the texture has already been created & is currently bound
  94925. * @hidden
  94926. */
  94927. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  94928. switch (this.loadType) {
  94929. case KhronosTextureContainer.COMPRESSED_2D:
  94930. this._upload2DCompressedLevels(texture, loadMipmaps);
  94931. break;
  94932. case KhronosTextureContainer.TEX_2D:
  94933. case KhronosTextureContainer.COMPRESSED_3D:
  94934. case KhronosTextureContainer.TEX_3D:
  94935. }
  94936. };
  94937. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  94938. // initialize width & height for level 1
  94939. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  94940. var width = this.pixelWidth;
  94941. var height = this.pixelHeight;
  94942. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  94943. for (var level = 0; level < mipmapCount; level++) {
  94944. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  94945. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  94946. for (var face = 0; face < this.numberOfFaces; face++) {
  94947. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  94948. var engine = texture.getEngine();
  94949. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  94950. dataOffset += imageSize; // add size of the image for the next face/mipmap
  94951. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  94952. }
  94953. width = Math.max(1.0, width * 0.5);
  94954. height = Math.max(1.0, height * 0.5);
  94955. }
  94956. };
  94957. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  94958. // load types
  94959. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  94960. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  94961. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  94962. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  94963. return KhronosTextureContainer;
  94964. }());
  94965. /***/ }),
  94966. /***/ "./Misc/logger.ts":
  94967. /*!************************!*\
  94968. !*** ./Misc/logger.ts ***!
  94969. \************************/
  94970. /*! exports provided: Logger */
  94971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94972. "use strict";
  94973. __webpack_require__.r(__webpack_exports__);
  94974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  94975. /**
  94976. * Logger used througouht the application to allow configuration of
  94977. * the log level required for the messages.
  94978. */
  94979. var Logger = /** @class */ (function () {
  94980. function Logger() {
  94981. }
  94982. Logger._AddLogEntry = function (entry) {
  94983. Logger._LogCache = entry + Logger._LogCache;
  94984. if (Logger.OnNewCacheEntry) {
  94985. Logger.OnNewCacheEntry(entry);
  94986. }
  94987. };
  94988. Logger._FormatMessage = function (message) {
  94989. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  94990. var date = new Date();
  94991. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  94992. };
  94993. Logger._LogDisabled = function (message) {
  94994. // nothing to do
  94995. };
  94996. Logger._LogEnabled = function (message) {
  94997. var formattedMessage = Logger._FormatMessage(message);
  94998. console.log("BJS - " + formattedMessage);
  94999. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  95000. Logger._AddLogEntry(entry);
  95001. };
  95002. Logger._WarnDisabled = function (message) {
  95003. // nothing to do
  95004. };
  95005. Logger._WarnEnabled = function (message) {
  95006. var formattedMessage = Logger._FormatMessage(message);
  95007. console.warn("BJS - " + formattedMessage);
  95008. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  95009. Logger._AddLogEntry(entry);
  95010. };
  95011. Logger._ErrorDisabled = function (message) {
  95012. // nothing to do
  95013. };
  95014. Logger._ErrorEnabled = function (message) {
  95015. Logger.errorsCount++;
  95016. var formattedMessage = Logger._FormatMessage(message);
  95017. console.error("BJS - " + formattedMessage);
  95018. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  95019. Logger._AddLogEntry(entry);
  95020. };
  95021. Object.defineProperty(Logger, "LogCache", {
  95022. /**
  95023. * Gets current log cache (list of logs)
  95024. */
  95025. get: function () {
  95026. return Logger._LogCache;
  95027. },
  95028. enumerable: true,
  95029. configurable: true
  95030. });
  95031. /**
  95032. * Clears the log cache
  95033. */
  95034. Logger.ClearLogCache = function () {
  95035. Logger._LogCache = "";
  95036. Logger.errorsCount = 0;
  95037. };
  95038. Object.defineProperty(Logger, "LogLevels", {
  95039. /**
  95040. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95041. */
  95042. set: function (level) {
  95043. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  95044. Logger.Log = Logger._LogEnabled;
  95045. }
  95046. else {
  95047. Logger.Log = Logger._LogDisabled;
  95048. }
  95049. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  95050. Logger.Warn = Logger._WarnEnabled;
  95051. }
  95052. else {
  95053. Logger.Warn = Logger._WarnDisabled;
  95054. }
  95055. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  95056. Logger.Error = Logger._ErrorEnabled;
  95057. }
  95058. else {
  95059. Logger.Error = Logger._ErrorDisabled;
  95060. }
  95061. },
  95062. enumerable: true,
  95063. configurable: true
  95064. });
  95065. /**
  95066. * No log
  95067. */
  95068. Logger.NoneLogLevel = 0;
  95069. /**
  95070. * Only message logs
  95071. */
  95072. Logger.MessageLogLevel = 1;
  95073. /**
  95074. * Only warning logs
  95075. */
  95076. Logger.WarningLogLevel = 2;
  95077. /**
  95078. * Only error logs
  95079. */
  95080. Logger.ErrorLogLevel = 4;
  95081. /**
  95082. * All logs
  95083. */
  95084. Logger.AllLogLevel = 7;
  95085. Logger._LogCache = "";
  95086. /**
  95087. * Gets a value indicating the number of loading errors
  95088. * @ignorenaming
  95089. */
  95090. Logger.errorsCount = 0;
  95091. /**
  95092. * Log a message to the console
  95093. */
  95094. Logger.Log = Logger._LogEnabled;
  95095. /**
  95096. * Write a warning message to the console
  95097. */
  95098. Logger.Warn = Logger._WarnEnabled;
  95099. /**
  95100. * Write an error message to the console
  95101. */
  95102. Logger.Error = Logger._ErrorEnabled;
  95103. return Logger;
  95104. }());
  95105. /***/ }),
  95106. /***/ "./Misc/observable.ts":
  95107. /*!****************************!*\
  95108. !*** ./Misc/observable.ts ***!
  95109. \****************************/
  95110. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  95111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95112. "use strict";
  95113. __webpack_require__.r(__webpack_exports__);
  95114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  95115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  95116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  95117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  95118. /**
  95119. * A class serves as a medium between the observable and its observers
  95120. */
  95121. var EventState = /** @class */ (function () {
  95122. /**
  95123. * Create a new EventState
  95124. * @param mask defines the mask associated with this state
  95125. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  95126. * @param target defines the original target of the state
  95127. * @param currentTarget defines the current target of the state
  95128. */
  95129. function EventState(mask, skipNextObservers, target, currentTarget) {
  95130. if (skipNextObservers === void 0) { skipNextObservers = false; }
  95131. this.initalize(mask, skipNextObservers, target, currentTarget);
  95132. }
  95133. /**
  95134. * Initialize the current event state
  95135. * @param mask defines the mask associated with this state
  95136. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  95137. * @param target defines the original target of the state
  95138. * @param currentTarget defines the current target of the state
  95139. * @returns the current event state
  95140. */
  95141. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  95142. if (skipNextObservers === void 0) { skipNextObservers = false; }
  95143. this.mask = mask;
  95144. this.skipNextObservers = skipNextObservers;
  95145. this.target = target;
  95146. this.currentTarget = currentTarget;
  95147. return this;
  95148. };
  95149. return EventState;
  95150. }());
  95151. /**
  95152. * Represent an Observer registered to a given Observable object.
  95153. */
  95154. var Observer = /** @class */ (function () {
  95155. /**
  95156. * Creates a new observer
  95157. * @param callback defines the callback to call when the observer is notified
  95158. * @param mask defines the mask of the observer (used to filter notifications)
  95159. * @param scope defines the current scope used to restore the JS context
  95160. */
  95161. function Observer(
  95162. /**
  95163. * Defines the callback to call when the observer is notified
  95164. */
  95165. callback,
  95166. /**
  95167. * Defines the mask of the observer (used to filter notifications)
  95168. */
  95169. mask,
  95170. /**
  95171. * Defines the current scope used to restore the JS context
  95172. */
  95173. scope) {
  95174. if (scope === void 0) { scope = null; }
  95175. this.callback = callback;
  95176. this.mask = mask;
  95177. this.scope = scope;
  95178. /** @hidden */
  95179. this._willBeUnregistered = false;
  95180. /**
  95181. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  95182. */
  95183. this.unregisterOnNextCall = false;
  95184. }
  95185. return Observer;
  95186. }());
  95187. /**
  95188. * Represent a list of observers registered to multiple Observables object.
  95189. */
  95190. var MultiObserver = /** @class */ (function () {
  95191. function MultiObserver() {
  95192. }
  95193. /**
  95194. * Release associated resources
  95195. */
  95196. MultiObserver.prototype.dispose = function () {
  95197. if (this._observers && this._observables) {
  95198. for (var index = 0; index < this._observers.length; index++) {
  95199. this._observables[index].remove(this._observers[index]);
  95200. }
  95201. }
  95202. this._observers = null;
  95203. this._observables = null;
  95204. };
  95205. /**
  95206. * Raise a callback when one of the observable will notify
  95207. * @param observables defines a list of observables to watch
  95208. * @param callback defines the callback to call on notification
  95209. * @param mask defines the mask used to filter notifications
  95210. * @param scope defines the current scope used to restore the JS context
  95211. * @returns the new MultiObserver
  95212. */
  95213. MultiObserver.Watch = function (observables, callback, mask, scope) {
  95214. if (mask === void 0) { mask = -1; }
  95215. if (scope === void 0) { scope = null; }
  95216. var result = new MultiObserver();
  95217. result._observers = new Array();
  95218. result._observables = observables;
  95219. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  95220. var observable = observables_1[_i];
  95221. var observer = observable.add(callback, mask, false, scope);
  95222. if (observer) {
  95223. result._observers.push(observer);
  95224. }
  95225. }
  95226. return result;
  95227. };
  95228. return MultiObserver;
  95229. }());
  95230. /**
  95231. * The Observable class is a simple implementation of the Observable pattern.
  95232. *
  95233. * 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.
  95234. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  95235. * 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).
  95236. * 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.
  95237. */
  95238. var Observable = /** @class */ (function () {
  95239. /**
  95240. * Creates a new observable
  95241. * @param onObserverAdded defines a callback to call when a new observer is added
  95242. */
  95243. function Observable(onObserverAdded) {
  95244. this._observers = new Array();
  95245. this._eventState = new EventState(0);
  95246. if (onObserverAdded) {
  95247. this._onObserverAdded = onObserverAdded;
  95248. }
  95249. }
  95250. /**
  95251. * Create a new Observer with the specified callback
  95252. * @param callback the callback that will be executed for that Observer
  95253. * @param mask the mask used to filter observers
  95254. * @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.
  95255. * @param scope optional scope for the callback to be called from
  95256. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  95257. * @returns the new observer created for the callback
  95258. */
  95259. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  95260. if (mask === void 0) { mask = -1; }
  95261. if (insertFirst === void 0) { insertFirst = false; }
  95262. if (scope === void 0) { scope = null; }
  95263. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  95264. if (!callback) {
  95265. return null;
  95266. }
  95267. var observer = new Observer(callback, mask, scope);
  95268. observer.unregisterOnNextCall = unregisterOnFirstCall;
  95269. if (insertFirst) {
  95270. this._observers.unshift(observer);
  95271. }
  95272. else {
  95273. this._observers.push(observer);
  95274. }
  95275. if (this._onObserverAdded) {
  95276. this._onObserverAdded(observer);
  95277. }
  95278. return observer;
  95279. };
  95280. /**
  95281. * Create a new Observer with the specified callback and unregisters after the next notification
  95282. * @param callback the callback that will be executed for that Observer
  95283. * @returns the new observer created for the callback
  95284. */
  95285. Observable.prototype.addOnce = function (callback) {
  95286. return this.add(callback, undefined, undefined, undefined, true);
  95287. };
  95288. /**
  95289. * Remove an Observer from the Observable object
  95290. * @param observer the instance of the Observer to remove
  95291. * @returns false if it doesn't belong to this Observable
  95292. */
  95293. Observable.prototype.remove = function (observer) {
  95294. if (!observer) {
  95295. return false;
  95296. }
  95297. var index = this._observers.indexOf(observer);
  95298. if (index !== -1) {
  95299. this._deferUnregister(observer);
  95300. return true;
  95301. }
  95302. return false;
  95303. };
  95304. /**
  95305. * Remove a callback from the Observable object
  95306. * @param callback the callback to remove
  95307. * @param scope optional scope. If used only the callbacks with this scope will be removed
  95308. * @returns false if it doesn't belong to this Observable
  95309. */
  95310. Observable.prototype.removeCallback = function (callback, scope) {
  95311. for (var index = 0; index < this._observers.length; index++) {
  95312. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  95313. this._deferUnregister(this._observers[index]);
  95314. return true;
  95315. }
  95316. }
  95317. return false;
  95318. };
  95319. Observable.prototype._deferUnregister = function (observer) {
  95320. var _this = this;
  95321. observer.unregisterOnNextCall = false;
  95322. observer._willBeUnregistered = true;
  95323. setTimeout(function () {
  95324. _this._remove(observer);
  95325. }, 0);
  95326. };
  95327. // This should only be called when not iterating over _observers to avoid callback skipping.
  95328. // Removes an observer from the _observer Array.
  95329. Observable.prototype._remove = function (observer) {
  95330. if (!observer) {
  95331. return false;
  95332. }
  95333. var index = this._observers.indexOf(observer);
  95334. if (index !== -1) {
  95335. this._observers.splice(index, 1);
  95336. return true;
  95337. }
  95338. return false;
  95339. };
  95340. /**
  95341. * Notify all Observers by calling their respective callback with the given data
  95342. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  95343. * @param eventData defines the data to send to all observers
  95344. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  95345. * @param target defines the original target of the state
  95346. * @param currentTarget defines the current target of the state
  95347. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  95348. */
  95349. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  95350. if (mask === void 0) { mask = -1; }
  95351. if (!this._observers.length) {
  95352. return true;
  95353. }
  95354. var state = this._eventState;
  95355. state.mask = mask;
  95356. state.target = target;
  95357. state.currentTarget = currentTarget;
  95358. state.skipNextObservers = false;
  95359. state.lastReturnValue = eventData;
  95360. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95361. var obs = _a[_i];
  95362. if (obs._willBeUnregistered) {
  95363. continue;
  95364. }
  95365. if (obs.mask & mask) {
  95366. if (obs.scope) {
  95367. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  95368. }
  95369. else {
  95370. state.lastReturnValue = obs.callback(eventData, state);
  95371. }
  95372. if (obs.unregisterOnNextCall) {
  95373. this._deferUnregister(obs);
  95374. }
  95375. }
  95376. if (state.skipNextObservers) {
  95377. return false;
  95378. }
  95379. }
  95380. return true;
  95381. };
  95382. /**
  95383. * Calling this will execute each callback, expecting it to be a promise or return a value.
  95384. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  95385. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  95386. * and it is crucial that all callbacks will be executed.
  95387. * The order of the callbacks is kept, callbacks are not executed parallel.
  95388. *
  95389. * @param eventData The data to be sent to each callback
  95390. * @param mask is used to filter observers defaults to -1
  95391. * @param target defines the callback target (see EventState)
  95392. * @param currentTarget defines he current object in the bubbling phase
  95393. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  95394. */
  95395. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  95396. var _this = this;
  95397. if (mask === void 0) { mask = -1; }
  95398. // create an empty promise
  95399. var p = Promise.resolve(eventData);
  95400. // no observers? return this promise.
  95401. if (!this._observers.length) {
  95402. return p;
  95403. }
  95404. var state = this._eventState;
  95405. state.mask = mask;
  95406. state.target = target;
  95407. state.currentTarget = currentTarget;
  95408. state.skipNextObservers = false;
  95409. // execute one callback after another (not using Promise.all, the order is important)
  95410. this._observers.forEach(function (obs) {
  95411. if (state.skipNextObservers) {
  95412. return;
  95413. }
  95414. if (obs._willBeUnregistered) {
  95415. return;
  95416. }
  95417. if (obs.mask & mask) {
  95418. if (obs.scope) {
  95419. p = p.then(function (lastReturnedValue) {
  95420. state.lastReturnValue = lastReturnedValue;
  95421. return obs.callback.apply(obs.scope, [eventData, state]);
  95422. });
  95423. }
  95424. else {
  95425. p = p.then(function (lastReturnedValue) {
  95426. state.lastReturnValue = lastReturnedValue;
  95427. return obs.callback(eventData, state);
  95428. });
  95429. }
  95430. if (obs.unregisterOnNextCall) {
  95431. _this._deferUnregister(obs);
  95432. }
  95433. }
  95434. });
  95435. // return the eventData
  95436. return p.then(function () { return eventData; });
  95437. };
  95438. /**
  95439. * Notify a specific observer
  95440. * @param observer defines the observer to notify
  95441. * @param eventData defines the data to be sent to each callback
  95442. * @param mask is used to filter observers defaults to -1
  95443. */
  95444. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  95445. if (mask === void 0) { mask = -1; }
  95446. var state = this._eventState;
  95447. state.mask = mask;
  95448. state.skipNextObservers = false;
  95449. observer.callback(eventData, state);
  95450. };
  95451. /**
  95452. * Gets a boolean indicating if the observable has at least one observer
  95453. * @returns true is the Observable has at least one Observer registered
  95454. */
  95455. Observable.prototype.hasObservers = function () {
  95456. return this._observers.length > 0;
  95457. };
  95458. /**
  95459. * Clear the list of observers
  95460. */
  95461. Observable.prototype.clear = function () {
  95462. this._observers = new Array();
  95463. this._onObserverAdded = null;
  95464. };
  95465. /**
  95466. * Clone the current observable
  95467. * @returns a new observable
  95468. */
  95469. Observable.prototype.clone = function () {
  95470. var result = new Observable();
  95471. result._observers = this._observers.slice(0);
  95472. return result;
  95473. };
  95474. /**
  95475. * Does this observable handles observer registered with a given mask
  95476. * @param mask defines the mask to be tested
  95477. * @return whether or not one observer registered with the given mask is handeled
  95478. **/
  95479. Observable.prototype.hasSpecificMask = function (mask) {
  95480. if (mask === void 0) { mask = -1; }
  95481. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95482. var obs = _a[_i];
  95483. if (obs.mask & mask || obs.mask === mask) {
  95484. return true;
  95485. }
  95486. }
  95487. return false;
  95488. };
  95489. return Observable;
  95490. }());
  95491. /***/ }),
  95492. /***/ "./Misc/performanceMonitor.ts":
  95493. /*!************************************!*\
  95494. !*** ./Misc/performanceMonitor.ts ***!
  95495. \************************************/
  95496. /*! exports provided: PerformanceMonitor, RollingAverage */
  95497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95498. "use strict";
  95499. __webpack_require__.r(__webpack_exports__);
  95500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  95501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  95502. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  95503. /**
  95504. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  95505. */
  95506. var PerformanceMonitor = /** @class */ (function () {
  95507. /**
  95508. * constructor
  95509. * @param frameSampleSize The number of samples required to saturate the sliding window
  95510. */
  95511. function PerformanceMonitor(frameSampleSize) {
  95512. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  95513. this._enabled = true;
  95514. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  95515. }
  95516. /**
  95517. * Samples current frame
  95518. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  95519. */
  95520. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  95521. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  95522. if (!this._enabled) {
  95523. return;
  95524. }
  95525. if (this._lastFrameTimeMs != null) {
  95526. var dt = timeMs - this._lastFrameTimeMs;
  95527. this._rollingFrameTime.add(dt);
  95528. }
  95529. this._lastFrameTimeMs = timeMs;
  95530. };
  95531. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  95532. /**
  95533. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95534. */
  95535. get: function () {
  95536. return this._rollingFrameTime.average;
  95537. },
  95538. enumerable: true,
  95539. configurable: true
  95540. });
  95541. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  95542. /**
  95543. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95544. */
  95545. get: function () {
  95546. return this._rollingFrameTime.variance;
  95547. },
  95548. enumerable: true,
  95549. configurable: true
  95550. });
  95551. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  95552. /**
  95553. * Returns the frame time of the most recent frame
  95554. */
  95555. get: function () {
  95556. return this._rollingFrameTime.history(0);
  95557. },
  95558. enumerable: true,
  95559. configurable: true
  95560. });
  95561. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  95562. /**
  95563. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  95564. */
  95565. get: function () {
  95566. return 1000.0 / this._rollingFrameTime.average;
  95567. },
  95568. enumerable: true,
  95569. configurable: true
  95570. });
  95571. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  95572. /**
  95573. * Returns the average framerate in frames per second using the most recent frame time
  95574. */
  95575. get: function () {
  95576. var history = this._rollingFrameTime.history(0);
  95577. if (history === 0) {
  95578. return 0;
  95579. }
  95580. return 1000.0 / history;
  95581. },
  95582. enumerable: true,
  95583. configurable: true
  95584. });
  95585. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  95586. /**
  95587. * Returns true if enough samples have been taken to completely fill the sliding window
  95588. */
  95589. get: function () {
  95590. return this._rollingFrameTime.isSaturated();
  95591. },
  95592. enumerable: true,
  95593. configurable: true
  95594. });
  95595. /**
  95596. * Enables contributions to the sliding window sample set
  95597. */
  95598. PerformanceMonitor.prototype.enable = function () {
  95599. this._enabled = true;
  95600. };
  95601. /**
  95602. * Disables contributions to the sliding window sample set
  95603. * Samples will not be interpolated over the disabled period
  95604. */
  95605. PerformanceMonitor.prototype.disable = function () {
  95606. this._enabled = false;
  95607. //clear last sample to avoid interpolating over the disabled period when next enabled
  95608. this._lastFrameTimeMs = null;
  95609. };
  95610. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  95611. /**
  95612. * Returns true if sampling is enabled
  95613. */
  95614. get: function () {
  95615. return this._enabled;
  95616. },
  95617. enumerable: true,
  95618. configurable: true
  95619. });
  95620. /**
  95621. * Resets performance monitor
  95622. */
  95623. PerformanceMonitor.prototype.reset = function () {
  95624. //clear last sample to avoid interpolating over the disabled period when next enabled
  95625. this._lastFrameTimeMs = null;
  95626. //wipe record
  95627. this._rollingFrameTime.reset();
  95628. };
  95629. return PerformanceMonitor;
  95630. }());
  95631. /**
  95632. * RollingAverage
  95633. *
  95634. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  95635. */
  95636. var RollingAverage = /** @class */ (function () {
  95637. /**
  95638. * constructor
  95639. * @param length The number of samples required to saturate the sliding window
  95640. */
  95641. function RollingAverage(length) {
  95642. this._samples = new Array(length);
  95643. this.reset();
  95644. }
  95645. /**
  95646. * Adds a sample to the sample set
  95647. * @param v The sample value
  95648. */
  95649. RollingAverage.prototype.add = function (v) {
  95650. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  95651. var delta;
  95652. //we need to check if we've already wrapped round
  95653. if (this.isSaturated()) {
  95654. //remove bottom of stack from mean
  95655. var bottomValue = this._samples[this._pos];
  95656. delta = bottomValue - this.average;
  95657. this.average -= delta / (this._sampleCount - 1);
  95658. this._m2 -= delta * (bottomValue - this.average);
  95659. }
  95660. else {
  95661. this._sampleCount++;
  95662. }
  95663. //add new value to mean
  95664. delta = v - this.average;
  95665. this.average += delta / (this._sampleCount);
  95666. this._m2 += delta * (v - this.average);
  95667. //set the new variance
  95668. this.variance = this._m2 / (this._sampleCount - 1);
  95669. this._samples[this._pos] = v;
  95670. this._pos++;
  95671. this._pos %= this._samples.length; //positive wrap around
  95672. };
  95673. /**
  95674. * Returns previously added values or null if outside of history or outside the sliding window domain
  95675. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  95676. * @return Value previously recorded with add() or null if outside of range
  95677. */
  95678. RollingAverage.prototype.history = function (i) {
  95679. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  95680. return 0;
  95681. }
  95682. var i0 = this._wrapPosition(this._pos - 1.0);
  95683. return this._samples[this._wrapPosition(i0 - i)];
  95684. };
  95685. /**
  95686. * Returns true if enough samples have been taken to completely fill the sliding window
  95687. * @return true if sample-set saturated
  95688. */
  95689. RollingAverage.prototype.isSaturated = function () {
  95690. return this._sampleCount >= this._samples.length;
  95691. };
  95692. /**
  95693. * Resets the rolling average (equivalent to 0 samples taken so far)
  95694. */
  95695. RollingAverage.prototype.reset = function () {
  95696. this.average = 0;
  95697. this.variance = 0;
  95698. this._sampleCount = 0;
  95699. this._pos = 0;
  95700. this._m2 = 0;
  95701. };
  95702. /**
  95703. * Wraps a value around the sample range boundaries
  95704. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  95705. * @return Wrapped position in sample range
  95706. */
  95707. RollingAverage.prototype._wrapPosition = function (i) {
  95708. var max = this._samples.length;
  95709. return ((i % max) + max) % max;
  95710. };
  95711. return RollingAverage;
  95712. }());
  95713. /***/ }),
  95714. /***/ "./Misc/pivotTools.ts":
  95715. /*!****************************!*\
  95716. !*** ./Misc/pivotTools.ts ***!
  95717. \****************************/
  95718. /*! exports provided: PivotTools */
  95719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95720. "use strict";
  95721. __webpack_require__.r(__webpack_exports__);
  95722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  95723. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95724. /**
  95725. * Class containing a set of static utilities functions for managing Pivots
  95726. * @hidden
  95727. */
  95728. var PivotTools = /** @class */ (function () {
  95729. function PivotTools() {
  95730. }
  95731. /** @hidden */
  95732. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  95733. if (mesh && PivotTools._PivotCached === 0) {
  95734. // Save old pivot and set pivot to 0,0,0
  95735. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  95736. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  95737. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  95738. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  95739. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95740. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95741. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95742. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  95743. }
  95744. }
  95745. PivotTools._PivotCached++;
  95746. };
  95747. /** @hidden */
  95748. PivotTools._RestorePivotPoint = function (mesh) {
  95749. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  95750. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  95751. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95752. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95753. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95754. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  95755. }
  95756. this._PivotCached--;
  95757. };
  95758. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  95759. // store/remove pivot point should only be applied during their outermost calls
  95760. PivotTools._PivotCached = 0;
  95761. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95762. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95763. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95764. return PivotTools;
  95765. }());
  95766. /***/ }),
  95767. /***/ "./Misc/precisionDate.ts":
  95768. /*!*******************************!*\
  95769. !*** ./Misc/precisionDate.ts ***!
  95770. \*******************************/
  95771. /*! exports provided: PrecisionDate */
  95772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95773. "use strict";
  95774. __webpack_require__.r(__webpack_exports__);
  95775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  95776. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  95777. /**
  95778. * Class containing a set of static utilities functions for precision date
  95779. */
  95780. var PrecisionDate = /** @class */ (function () {
  95781. function PrecisionDate() {
  95782. }
  95783. Object.defineProperty(PrecisionDate, "Now", {
  95784. /**
  95785. * Gets either window.performance.now() if supported or Date.now() else
  95786. */
  95787. get: function () {
  95788. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  95789. return window.performance.now();
  95790. }
  95791. return Date.now();
  95792. },
  95793. enumerable: true,
  95794. configurable: true
  95795. });
  95796. return PrecisionDate;
  95797. }());
  95798. /***/ }),
  95799. /***/ "./Misc/promise.ts":
  95800. /*!*************************!*\
  95801. !*** ./Misc/promise.ts ***!
  95802. \*************************/
  95803. /*! exports provided: PromisePolyfill */
  95804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95805. "use strict";
  95806. __webpack_require__.r(__webpack_exports__);
  95807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  95808. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95809. var PromiseStates;
  95810. (function (PromiseStates) {
  95811. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  95812. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  95813. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  95814. })(PromiseStates || (PromiseStates = {}));
  95815. var FulFillmentAgregator = /** @class */ (function () {
  95816. function FulFillmentAgregator() {
  95817. this.count = 0;
  95818. this.target = 0;
  95819. this.results = [];
  95820. }
  95821. return FulFillmentAgregator;
  95822. }());
  95823. var InternalPromise = /** @class */ (function () {
  95824. function InternalPromise(resolver) {
  95825. var _this = this;
  95826. this._state = PromiseStates.Pending;
  95827. this._children = new Array();
  95828. this._rejectWasConsumed = false;
  95829. if (!resolver) {
  95830. return;
  95831. }
  95832. try {
  95833. resolver(function (value) {
  95834. _this._resolve(value);
  95835. }, function (reason) {
  95836. _this._reject(reason);
  95837. });
  95838. }
  95839. catch (e) {
  95840. this._reject(e);
  95841. }
  95842. }
  95843. Object.defineProperty(InternalPromise.prototype, "_result", {
  95844. get: function () {
  95845. return this._resultValue;
  95846. },
  95847. set: function (value) {
  95848. this._resultValue = value;
  95849. if (this._parent && this._parent._result === undefined) {
  95850. this._parent._result = value;
  95851. }
  95852. },
  95853. enumerable: true,
  95854. configurable: true
  95855. });
  95856. InternalPromise.prototype.catch = function (onRejected) {
  95857. return this.then(undefined, onRejected);
  95858. };
  95859. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  95860. var _this = this;
  95861. var newPromise = new InternalPromise();
  95862. newPromise._onFulfilled = onFulfilled;
  95863. newPromise._onRejected = onRejected;
  95864. // Composition
  95865. this._children.push(newPromise);
  95866. newPromise._parent = this;
  95867. if (this._state !== PromiseStates.Pending) {
  95868. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  95869. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  95870. var returnedValue = newPromise._resolve(_this._result);
  95871. if (returnedValue !== undefined && returnedValue !== null) {
  95872. if (returnedValue._state !== undefined) {
  95873. var returnedPromise = returnedValue;
  95874. newPromise._children.push(returnedPromise);
  95875. returnedPromise._parent = newPromise;
  95876. newPromise = returnedPromise;
  95877. }
  95878. else {
  95879. newPromise._result = returnedValue;
  95880. }
  95881. }
  95882. }
  95883. else {
  95884. newPromise._reject(_this._reason);
  95885. }
  95886. });
  95887. }
  95888. return newPromise;
  95889. };
  95890. InternalPromise.prototype._moveChildren = function (children) {
  95891. var _this = this;
  95892. var _a;
  95893. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  95894. this._children.forEach(function (child) {
  95895. child._parent = _this;
  95896. });
  95897. if (this._state === PromiseStates.Fulfilled) {
  95898. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  95899. var child = _b[_i];
  95900. child._resolve(this._result);
  95901. }
  95902. }
  95903. else if (this._state === PromiseStates.Rejected) {
  95904. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  95905. var child = _d[_c];
  95906. child._reject(this._reason);
  95907. }
  95908. }
  95909. };
  95910. InternalPromise.prototype._resolve = function (value) {
  95911. try {
  95912. this._state = PromiseStates.Fulfilled;
  95913. var returnedValue = null;
  95914. if (this._onFulfilled) {
  95915. returnedValue = this._onFulfilled(value);
  95916. }
  95917. if (returnedValue !== undefined && returnedValue !== null) {
  95918. if (returnedValue._state !== undefined) {
  95919. // Transmit children
  95920. var returnedPromise = returnedValue;
  95921. returnedPromise._parent = this;
  95922. returnedPromise._moveChildren(this._children);
  95923. value = returnedPromise._result;
  95924. }
  95925. else {
  95926. value = returnedValue;
  95927. }
  95928. }
  95929. this._result = value;
  95930. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95931. var child = _a[_i];
  95932. child._resolve(value);
  95933. }
  95934. this._children.length = 0;
  95935. delete this._onFulfilled;
  95936. delete this._onRejected;
  95937. }
  95938. catch (e) {
  95939. this._reject(e, true);
  95940. }
  95941. };
  95942. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  95943. if (onLocalThrow === void 0) { onLocalThrow = false; }
  95944. this._state = PromiseStates.Rejected;
  95945. this._reason = reason;
  95946. if (this._onRejected && !onLocalThrow) {
  95947. try {
  95948. this._onRejected(reason);
  95949. this._rejectWasConsumed = true;
  95950. }
  95951. catch (e) {
  95952. reason = e;
  95953. }
  95954. }
  95955. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95956. var child = _a[_i];
  95957. if (this._rejectWasConsumed) {
  95958. child._resolve(null);
  95959. }
  95960. else {
  95961. child._reject(reason);
  95962. }
  95963. }
  95964. this._children.length = 0;
  95965. delete this._onFulfilled;
  95966. delete this._onRejected;
  95967. };
  95968. InternalPromise.resolve = function (value) {
  95969. var newPromise = new InternalPromise();
  95970. newPromise._resolve(value);
  95971. return newPromise;
  95972. };
  95973. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  95974. promise.then(function (value) {
  95975. agregator.results[index] = value;
  95976. agregator.count++;
  95977. if (agregator.count === agregator.target) {
  95978. agregator.rootPromise._resolve(agregator.results);
  95979. }
  95980. return null;
  95981. }, function (reason) {
  95982. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  95983. agregator.rootPromise._reject(reason);
  95984. }
  95985. });
  95986. };
  95987. InternalPromise.all = function (promises) {
  95988. var newPromise = new InternalPromise();
  95989. var agregator = new FulFillmentAgregator();
  95990. agregator.target = promises.length;
  95991. agregator.rootPromise = newPromise;
  95992. if (promises.length) {
  95993. for (var index = 0; index < promises.length; index++) {
  95994. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  95995. }
  95996. }
  95997. else {
  95998. newPromise._resolve([]);
  95999. }
  96000. return newPromise;
  96001. };
  96002. InternalPromise.race = function (promises) {
  96003. var newPromise = new InternalPromise();
  96004. if (promises.length) {
  96005. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  96006. var promise = promises_1[_i];
  96007. promise.then(function (value) {
  96008. if (newPromise) {
  96009. newPromise._resolve(value);
  96010. newPromise = null;
  96011. }
  96012. return null;
  96013. }, function (reason) {
  96014. if (newPromise) {
  96015. newPromise._reject(reason);
  96016. newPromise = null;
  96017. }
  96018. });
  96019. }
  96020. }
  96021. return newPromise;
  96022. };
  96023. return InternalPromise;
  96024. }());
  96025. /**
  96026. * Helper class that provides a small promise polyfill
  96027. */
  96028. var PromisePolyfill = /** @class */ (function () {
  96029. function PromisePolyfill() {
  96030. }
  96031. /**
  96032. * Static function used to check if the polyfill is required
  96033. * If this is the case then the function will inject the polyfill to window.Promise
  96034. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96035. */
  96036. PromisePolyfill.Apply = function (force) {
  96037. if (force === void 0) { force = false; }
  96038. if (force || typeof Promise === 'undefined') {
  96039. var root = window;
  96040. root.Promise = InternalPromise;
  96041. }
  96042. };
  96043. return PromisePolyfill;
  96044. }());
  96045. /***/ }),
  96046. /***/ "./Misc/sceneOptimizer.ts":
  96047. /*!********************************!*\
  96048. !*** ./Misc/sceneOptimizer.ts ***!
  96049. \********************************/
  96050. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  96051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96052. "use strict";
  96053. __webpack_require__.r(__webpack_exports__);
  96054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  96055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  96056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  96057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  96058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  96059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  96060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  96061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  96062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  96063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  96064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  96065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  96066. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96067. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  96068. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96069. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96070. /**
  96071. * Defines the root class used to create scene optimization to use with SceneOptimizer
  96072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96073. */
  96074. var SceneOptimization = /** @class */ (function () {
  96075. /**
  96076. * Creates the SceneOptimization object
  96077. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96078. * @param desc defines the description associated with the optimization
  96079. */
  96080. function SceneOptimization(
  96081. /**
  96082. * Defines the priority of this optimization (0 by default which means first in the list)
  96083. */
  96084. priority) {
  96085. if (priority === void 0) { priority = 0; }
  96086. this.priority = priority;
  96087. }
  96088. /**
  96089. * Gets a string describing the action executed by the current optimization
  96090. * @returns description string
  96091. */
  96092. SceneOptimization.prototype.getDescription = function () {
  96093. return "";
  96094. };
  96095. /**
  96096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96097. * @param scene defines the current scene where to apply this optimization
  96098. * @param optimizer defines the current optimizer
  96099. * @returns true if everything that can be done was applied
  96100. */
  96101. SceneOptimization.prototype.apply = function (scene, optimizer) {
  96102. return true;
  96103. };
  96104. return SceneOptimization;
  96105. }());
  96106. /**
  96107. * Defines an optimization used to reduce the size of render target textures
  96108. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96109. */
  96110. var TextureOptimization = /** @class */ (function (_super) {
  96111. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  96112. /**
  96113. * Creates the TextureOptimization object
  96114. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96115. * @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
  96116. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  96117. */
  96118. function TextureOptimization(
  96119. /**
  96120. * Defines the priority of this optimization (0 by default which means first in the list)
  96121. */
  96122. priority,
  96123. /**
  96124. * 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
  96125. */
  96126. maximumSize,
  96127. /**
  96128. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  96129. */
  96130. step) {
  96131. if (priority === void 0) { priority = 0; }
  96132. if (maximumSize === void 0) { maximumSize = 1024; }
  96133. if (step === void 0) { step = 0.5; }
  96134. var _this = _super.call(this, priority) || this;
  96135. _this.priority = priority;
  96136. _this.maximumSize = maximumSize;
  96137. _this.step = step;
  96138. return _this;
  96139. }
  96140. /**
  96141. * Gets a string describing the action executed by the current optimization
  96142. * @returns description string
  96143. */
  96144. TextureOptimization.prototype.getDescription = function () {
  96145. return "Reducing render target texture size to " + this.maximumSize;
  96146. };
  96147. /**
  96148. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96149. * @param scene defines the current scene where to apply this optimization
  96150. * @param optimizer defines the current optimizer
  96151. * @returns true if everything that can be done was applied
  96152. */
  96153. TextureOptimization.prototype.apply = function (scene, optimizer) {
  96154. var allDone = true;
  96155. for (var index = 0; index < scene.textures.length; index++) {
  96156. var texture = scene.textures[index];
  96157. if (!texture.canRescale || texture.getContext) {
  96158. continue;
  96159. }
  96160. var currentSize = texture.getSize();
  96161. var maxDimension = Math.max(currentSize.width, currentSize.height);
  96162. if (maxDimension > this.maximumSize) {
  96163. texture.scale(this.step);
  96164. allDone = false;
  96165. }
  96166. }
  96167. return allDone;
  96168. };
  96169. return TextureOptimization;
  96170. }(SceneOptimization));
  96171. /**
  96172. * Defines an optimization used to increase or decrease the rendering resolution
  96173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96174. */
  96175. var HardwareScalingOptimization = /** @class */ (function (_super) {
  96176. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  96177. /**
  96178. * Creates the HardwareScalingOptimization object
  96179. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96180. * @param maximumScale defines the maximum scale to use (2 by default)
  96181. * @param step defines the step to use between two passes (0.5 by default)
  96182. */
  96183. function HardwareScalingOptimization(
  96184. /**
  96185. * Defines the priority of this optimization (0 by default which means first in the list)
  96186. */
  96187. priority,
  96188. /**
  96189. * Defines the maximum scale to use (2 by default)
  96190. */
  96191. maximumScale,
  96192. /**
  96193. * Defines the step to use between two passes (0.5 by default)
  96194. */
  96195. step) {
  96196. if (priority === void 0) { priority = 0; }
  96197. if (maximumScale === void 0) { maximumScale = 2; }
  96198. if (step === void 0) { step = 0.25; }
  96199. var _this = _super.call(this, priority) || this;
  96200. _this.priority = priority;
  96201. _this.maximumScale = maximumScale;
  96202. _this.step = step;
  96203. _this._currentScale = -1;
  96204. _this._directionOffset = 1;
  96205. return _this;
  96206. }
  96207. /**
  96208. * Gets a string describing the action executed by the current optimization
  96209. * @return description string
  96210. */
  96211. HardwareScalingOptimization.prototype.getDescription = function () {
  96212. return "Setting hardware scaling level to " + this._currentScale;
  96213. };
  96214. /**
  96215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96216. * @param scene defines the current scene where to apply this optimization
  96217. * @param optimizer defines the current optimizer
  96218. * @returns true if everything that can be done was applied
  96219. */
  96220. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  96221. if (this._currentScale === -1) {
  96222. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  96223. if (this._currentScale > this.maximumScale) {
  96224. this._directionOffset = -1;
  96225. }
  96226. }
  96227. this._currentScale += this._directionOffset * this.step;
  96228. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  96229. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  96230. };
  96231. return HardwareScalingOptimization;
  96232. }(SceneOptimization));
  96233. /**
  96234. * Defines an optimization used to remove shadows
  96235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96236. */
  96237. var ShadowsOptimization = /** @class */ (function (_super) {
  96238. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  96239. function ShadowsOptimization() {
  96240. return _super !== null && _super.apply(this, arguments) || this;
  96241. }
  96242. /**
  96243. * Gets a string describing the action executed by the current optimization
  96244. * @return description string
  96245. */
  96246. ShadowsOptimization.prototype.getDescription = function () {
  96247. return "Turning shadows on/off";
  96248. };
  96249. /**
  96250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96251. * @param scene defines the current scene where to apply this optimization
  96252. * @param optimizer defines the current optimizer
  96253. * @returns true if everything that can be done was applied
  96254. */
  96255. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  96256. scene.shadowsEnabled = optimizer.isInImprovementMode;
  96257. return true;
  96258. };
  96259. return ShadowsOptimization;
  96260. }(SceneOptimization));
  96261. /**
  96262. * Defines an optimization used to turn post-processes off
  96263. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96264. */
  96265. var PostProcessesOptimization = /** @class */ (function (_super) {
  96266. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  96267. function PostProcessesOptimization() {
  96268. return _super !== null && _super.apply(this, arguments) || this;
  96269. }
  96270. /**
  96271. * Gets a string describing the action executed by the current optimization
  96272. * @return description string
  96273. */
  96274. PostProcessesOptimization.prototype.getDescription = function () {
  96275. return "Turning post-processes on/off";
  96276. };
  96277. /**
  96278. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96279. * @param scene defines the current scene where to apply this optimization
  96280. * @param optimizer defines the current optimizer
  96281. * @returns true if everything that can be done was applied
  96282. */
  96283. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  96284. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  96285. return true;
  96286. };
  96287. return PostProcessesOptimization;
  96288. }(SceneOptimization));
  96289. /**
  96290. * Defines an optimization used to turn lens flares off
  96291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96292. */
  96293. var LensFlaresOptimization = /** @class */ (function (_super) {
  96294. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  96295. function LensFlaresOptimization() {
  96296. return _super !== null && _super.apply(this, arguments) || this;
  96297. }
  96298. /**
  96299. * Gets a string describing the action executed by the current optimization
  96300. * @return description string
  96301. */
  96302. LensFlaresOptimization.prototype.getDescription = function () {
  96303. return "Turning lens flares on/off";
  96304. };
  96305. /**
  96306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96307. * @param scene defines the current scene where to apply this optimization
  96308. * @param optimizer defines the current optimizer
  96309. * @returns true if everything that can be done was applied
  96310. */
  96311. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  96312. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  96313. return true;
  96314. };
  96315. return LensFlaresOptimization;
  96316. }(SceneOptimization));
  96317. /**
  96318. * Defines an optimization based on user defined callback.
  96319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96320. */
  96321. var CustomOptimization = /** @class */ (function (_super) {
  96322. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  96323. function CustomOptimization() {
  96324. return _super !== null && _super.apply(this, arguments) || this;
  96325. }
  96326. /**
  96327. * Gets a string describing the action executed by the current optimization
  96328. * @returns description string
  96329. */
  96330. CustomOptimization.prototype.getDescription = function () {
  96331. if (this.onGetDescription) {
  96332. return this.onGetDescription();
  96333. }
  96334. return "Running user defined callback";
  96335. };
  96336. /**
  96337. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96338. * @param scene defines the current scene where to apply this optimization
  96339. * @param optimizer defines the current optimizer
  96340. * @returns true if everything that can be done was applied
  96341. */
  96342. CustomOptimization.prototype.apply = function (scene, optimizer) {
  96343. if (this.onApply) {
  96344. return this.onApply(scene, optimizer);
  96345. }
  96346. return true;
  96347. };
  96348. return CustomOptimization;
  96349. }(SceneOptimization));
  96350. /**
  96351. * Defines an optimization used to turn particles off
  96352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96353. */
  96354. var ParticlesOptimization = /** @class */ (function (_super) {
  96355. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  96356. function ParticlesOptimization() {
  96357. return _super !== null && _super.apply(this, arguments) || this;
  96358. }
  96359. /**
  96360. * Gets a string describing the action executed by the current optimization
  96361. * @return description string
  96362. */
  96363. ParticlesOptimization.prototype.getDescription = function () {
  96364. return "Turning particles on/off";
  96365. };
  96366. /**
  96367. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96368. * @param scene defines the current scene where to apply this optimization
  96369. * @param optimizer defines the current optimizer
  96370. * @returns true if everything that can be done was applied
  96371. */
  96372. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  96373. scene.particlesEnabled = optimizer.isInImprovementMode;
  96374. return true;
  96375. };
  96376. return ParticlesOptimization;
  96377. }(SceneOptimization));
  96378. /**
  96379. * Defines an optimization used to turn render targets off
  96380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96381. */
  96382. var RenderTargetsOptimization = /** @class */ (function (_super) {
  96383. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  96384. function RenderTargetsOptimization() {
  96385. return _super !== null && _super.apply(this, arguments) || this;
  96386. }
  96387. /**
  96388. * Gets a string describing the action executed by the current optimization
  96389. * @return description string
  96390. */
  96391. RenderTargetsOptimization.prototype.getDescription = function () {
  96392. return "Turning render targets off";
  96393. };
  96394. /**
  96395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96396. * @param scene defines the current scene where to apply this optimization
  96397. * @param optimizer defines the current optimizer
  96398. * @returns true if everything that can be done was applied
  96399. */
  96400. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  96401. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  96402. return true;
  96403. };
  96404. return RenderTargetsOptimization;
  96405. }(SceneOptimization));
  96406. /**
  96407. * Defines an optimization used to merge meshes with compatible materials
  96408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96409. */
  96410. var MergeMeshesOptimization = /** @class */ (function (_super) {
  96411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  96412. function MergeMeshesOptimization() {
  96413. var _this = _super !== null && _super.apply(this, arguments) || this;
  96414. _this._canBeMerged = function (abstractMesh) {
  96415. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  96416. return false;
  96417. }
  96418. var mesh = abstractMesh;
  96419. if (mesh.isDisposed()) {
  96420. return false;
  96421. }
  96422. if (!mesh.isVisible || !mesh.isEnabled()) {
  96423. return false;
  96424. }
  96425. if (mesh.instances.length > 0) {
  96426. return false;
  96427. }
  96428. if (mesh.skeleton || mesh.hasLODLevels) {
  96429. return false;
  96430. }
  96431. return true;
  96432. };
  96433. return _this;
  96434. }
  96435. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  96436. /**
  96437. * Gets or sets a boolean which defines if optimization octree has to be updated
  96438. */
  96439. get: function () {
  96440. return MergeMeshesOptimization._UpdateSelectionTree;
  96441. },
  96442. /**
  96443. * Gets or sets a boolean which defines if optimization octree has to be updated
  96444. */
  96445. set: function (value) {
  96446. MergeMeshesOptimization._UpdateSelectionTree = value;
  96447. },
  96448. enumerable: true,
  96449. configurable: true
  96450. });
  96451. /**
  96452. * Gets a string describing the action executed by the current optimization
  96453. * @return description string
  96454. */
  96455. MergeMeshesOptimization.prototype.getDescription = function () {
  96456. return "Merging similar meshes together";
  96457. };
  96458. /**
  96459. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96460. * @param scene defines the current scene where to apply this optimization
  96461. * @param optimizer defines the current optimizer
  96462. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  96463. * @returns true if everything that can be done was applied
  96464. */
  96465. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  96466. var globalPool = scene.meshes.slice(0);
  96467. var globalLength = globalPool.length;
  96468. for (var index = 0; index < globalLength; index++) {
  96469. var currentPool = new Array();
  96470. var current = globalPool[index];
  96471. // Checks
  96472. if (!this._canBeMerged(current)) {
  96473. continue;
  96474. }
  96475. currentPool.push(current);
  96476. // Find compatible meshes
  96477. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  96478. var otherMesh = globalPool[subIndex];
  96479. if (!this._canBeMerged(otherMesh)) {
  96480. continue;
  96481. }
  96482. if (otherMesh.material !== current.material) {
  96483. continue;
  96484. }
  96485. if (otherMesh.checkCollisions !== current.checkCollisions) {
  96486. continue;
  96487. }
  96488. currentPool.push(otherMesh);
  96489. globalLength--;
  96490. globalPool.splice(subIndex, 1);
  96491. subIndex--;
  96492. }
  96493. if (currentPool.length < 2) {
  96494. continue;
  96495. }
  96496. // Merge meshes
  96497. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  96498. }
  96499. // Call the octree system optimization if it is defined.
  96500. var sceneAsAny = scene;
  96501. if (sceneAsAny.createOrUpdateSelectionOctree) {
  96502. if (updateSelectionTree != undefined) {
  96503. if (updateSelectionTree) {
  96504. sceneAsAny.createOrUpdateSelectionOctree();
  96505. }
  96506. }
  96507. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  96508. sceneAsAny.createOrUpdateSelectionOctree();
  96509. }
  96510. }
  96511. return true;
  96512. };
  96513. MergeMeshesOptimization._UpdateSelectionTree = false;
  96514. return MergeMeshesOptimization;
  96515. }(SceneOptimization));
  96516. /**
  96517. * Defines a list of options used by SceneOptimizer
  96518. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96519. */
  96520. var SceneOptimizerOptions = /** @class */ (function () {
  96521. /**
  96522. * Creates a new list of options used by SceneOptimizer
  96523. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  96524. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  96525. */
  96526. function SceneOptimizerOptions(
  96527. /**
  96528. * Defines the target frame rate to reach (60 by default)
  96529. */
  96530. targetFrameRate,
  96531. /**
  96532. * Defines the interval between two checkes (2000ms by default)
  96533. */
  96534. trackerDuration) {
  96535. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  96536. if (trackerDuration === void 0) { trackerDuration = 2000; }
  96537. this.targetFrameRate = targetFrameRate;
  96538. this.trackerDuration = trackerDuration;
  96539. /**
  96540. * Gets the list of optimizations to apply
  96541. */
  96542. this.optimizations = new Array();
  96543. }
  96544. /**
  96545. * Add a new optimization
  96546. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  96547. * @returns the current SceneOptimizerOptions
  96548. */
  96549. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  96550. this.optimizations.push(optimization);
  96551. return this;
  96552. };
  96553. /**
  96554. * Add a new custom optimization
  96555. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  96556. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  96557. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96558. * @returns the current SceneOptimizerOptions
  96559. */
  96560. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  96561. if (priority === void 0) { priority = 0; }
  96562. var optimization = new CustomOptimization(priority);
  96563. optimization.onApply = onApply;
  96564. optimization.onGetDescription = onGetDescription;
  96565. this.optimizations.push(optimization);
  96566. return this;
  96567. };
  96568. /**
  96569. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  96570. * @param targetFrameRate defines the target frame rate (60 by default)
  96571. * @returns a SceneOptimizerOptions object
  96572. */
  96573. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  96574. var result = new SceneOptimizerOptions(targetFrameRate);
  96575. var priority = 0;
  96576. result.addOptimization(new MergeMeshesOptimization(priority));
  96577. result.addOptimization(new ShadowsOptimization(priority));
  96578. result.addOptimization(new LensFlaresOptimization(priority));
  96579. // Next priority
  96580. priority++;
  96581. result.addOptimization(new PostProcessesOptimization(priority));
  96582. result.addOptimization(new ParticlesOptimization(priority));
  96583. // Next priority
  96584. priority++;
  96585. result.addOptimization(new TextureOptimization(priority, 1024));
  96586. return result;
  96587. };
  96588. /**
  96589. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  96590. * @param targetFrameRate defines the target frame rate (60 by default)
  96591. * @returns a SceneOptimizerOptions object
  96592. */
  96593. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  96594. var result = new SceneOptimizerOptions(targetFrameRate);
  96595. var priority = 0;
  96596. result.addOptimization(new MergeMeshesOptimization(priority));
  96597. result.addOptimization(new ShadowsOptimization(priority));
  96598. result.addOptimization(new LensFlaresOptimization(priority));
  96599. // Next priority
  96600. priority++;
  96601. result.addOptimization(new PostProcessesOptimization(priority));
  96602. result.addOptimization(new ParticlesOptimization(priority));
  96603. // Next priority
  96604. priority++;
  96605. result.addOptimization(new TextureOptimization(priority, 512));
  96606. // Next priority
  96607. priority++;
  96608. result.addOptimization(new RenderTargetsOptimization(priority));
  96609. // Next priority
  96610. priority++;
  96611. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  96612. return result;
  96613. };
  96614. /**
  96615. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  96616. * @param targetFrameRate defines the target frame rate (60 by default)
  96617. * @returns a SceneOptimizerOptions object
  96618. */
  96619. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  96620. var result = new SceneOptimizerOptions(targetFrameRate);
  96621. var priority = 0;
  96622. result.addOptimization(new MergeMeshesOptimization(priority));
  96623. result.addOptimization(new ShadowsOptimization(priority));
  96624. result.addOptimization(new LensFlaresOptimization(priority));
  96625. // Next priority
  96626. priority++;
  96627. result.addOptimization(new PostProcessesOptimization(priority));
  96628. result.addOptimization(new ParticlesOptimization(priority));
  96629. // Next priority
  96630. priority++;
  96631. result.addOptimization(new TextureOptimization(priority, 256));
  96632. // Next priority
  96633. priority++;
  96634. result.addOptimization(new RenderTargetsOptimization(priority));
  96635. // Next priority
  96636. priority++;
  96637. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  96638. return result;
  96639. };
  96640. return SceneOptimizerOptions;
  96641. }());
  96642. /**
  96643. * Class used to run optimizations in order to reach a target frame rate
  96644. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96645. */
  96646. var SceneOptimizer = /** @class */ (function () {
  96647. /**
  96648. * Creates a new SceneOptimizer
  96649. * @param scene defines the scene to work on
  96650. * @param options defines the options to use with the SceneOptimizer
  96651. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  96652. * @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)
  96653. */
  96654. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  96655. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  96656. if (improvementMode === void 0) { improvementMode = false; }
  96657. var _this = this;
  96658. this._isRunning = false;
  96659. this._currentPriorityLevel = 0;
  96660. this._targetFrameRate = 60;
  96661. this._trackerDuration = 2000;
  96662. this._currentFrameRate = 0;
  96663. this._improvementMode = false;
  96664. /**
  96665. * Defines an observable called when the optimizer reaches the target frame rate
  96666. */
  96667. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96668. /**
  96669. * Defines an observable called when the optimizer enables an optimization
  96670. */
  96671. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96672. /**
  96673. * Defines an observable called when the optimizer is not able to reach the target frame rate
  96674. */
  96675. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96676. if (!options) {
  96677. this._options = new SceneOptimizerOptions();
  96678. }
  96679. else {
  96680. this._options = options;
  96681. }
  96682. if (this._options.targetFrameRate) {
  96683. this._targetFrameRate = this._options.targetFrameRate;
  96684. }
  96685. if (this._options.trackerDuration) {
  96686. this._trackerDuration = this._options.trackerDuration;
  96687. }
  96688. if (autoGeneratePriorities) {
  96689. var priority = 0;
  96690. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  96691. var optim = _a[_i];
  96692. optim.priority = priority++;
  96693. }
  96694. }
  96695. this._improvementMode = improvementMode;
  96696. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  96697. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  96698. _this._sceneDisposeObserver = null;
  96699. _this.dispose();
  96700. });
  96701. }
  96702. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  96703. /**
  96704. * Gets a boolean indicating if the optimizer is in improvement mode
  96705. */
  96706. get: function () {
  96707. return this._improvementMode;
  96708. },
  96709. enumerable: true,
  96710. configurable: true
  96711. });
  96712. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  96713. /**
  96714. * Gets the current priority level (0 at start)
  96715. */
  96716. get: function () {
  96717. return this._currentPriorityLevel;
  96718. },
  96719. enumerable: true,
  96720. configurable: true
  96721. });
  96722. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  96723. /**
  96724. * Gets the current frame rate checked by the SceneOptimizer
  96725. */
  96726. get: function () {
  96727. return this._currentFrameRate;
  96728. },
  96729. enumerable: true,
  96730. configurable: true
  96731. });
  96732. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  96733. /**
  96734. * Gets or sets the current target frame rate (60 by default)
  96735. */
  96736. get: function () {
  96737. return this._targetFrameRate;
  96738. },
  96739. /**
  96740. * Gets or sets the current target frame rate (60 by default)
  96741. */
  96742. set: function (value) {
  96743. this._targetFrameRate = value;
  96744. },
  96745. enumerable: true,
  96746. configurable: true
  96747. });
  96748. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  96749. /**
  96750. * Gets or sets the current interval between two checks (every 2000ms by default)
  96751. */
  96752. get: function () {
  96753. return this._trackerDuration;
  96754. },
  96755. /**
  96756. * Gets or sets the current interval between two checks (every 2000ms by default)
  96757. */
  96758. set: function (value) {
  96759. this._trackerDuration = value;
  96760. },
  96761. enumerable: true,
  96762. configurable: true
  96763. });
  96764. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  96765. /**
  96766. * Gets the list of active optimizations
  96767. */
  96768. get: function () {
  96769. return this._options.optimizations;
  96770. },
  96771. enumerable: true,
  96772. configurable: true
  96773. });
  96774. /**
  96775. * Stops the current optimizer
  96776. */
  96777. SceneOptimizer.prototype.stop = function () {
  96778. this._isRunning = false;
  96779. };
  96780. /**
  96781. * Reset the optimizer to initial step (current priority level = 0)
  96782. */
  96783. SceneOptimizer.prototype.reset = function () {
  96784. this._currentPriorityLevel = 0;
  96785. };
  96786. /**
  96787. * Start the optimizer. By default it will try to reach a specific framerate
  96788. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  96789. */
  96790. SceneOptimizer.prototype.start = function () {
  96791. var _this = this;
  96792. if (this._isRunning) {
  96793. return;
  96794. }
  96795. this._isRunning = true;
  96796. // Let's wait for the scene to be ready before running our check
  96797. this._scene.executeWhenReady(function () {
  96798. setTimeout(function () {
  96799. _this._checkCurrentState();
  96800. }, _this._trackerDuration);
  96801. });
  96802. };
  96803. SceneOptimizer.prototype._checkCurrentState = function () {
  96804. var _this = this;
  96805. if (!this._isRunning) {
  96806. return;
  96807. }
  96808. var scene = this._scene;
  96809. var options = this._options;
  96810. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  96811. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  96812. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  96813. this._isRunning = false;
  96814. this.onSuccessObservable.notifyObservers(this);
  96815. return;
  96816. }
  96817. // Apply current level of optimizations
  96818. var allDone = true;
  96819. var noOptimizationApplied = true;
  96820. for (var index = 0; index < options.optimizations.length; index++) {
  96821. var optimization = options.optimizations[index];
  96822. if (optimization.priority === this._currentPriorityLevel) {
  96823. noOptimizationApplied = false;
  96824. allDone = allDone && optimization.apply(scene, this);
  96825. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  96826. }
  96827. }
  96828. // If no optimization was applied, this is a failure :(
  96829. if (noOptimizationApplied) {
  96830. this._isRunning = false;
  96831. this.onFailureObservable.notifyObservers(this);
  96832. return;
  96833. }
  96834. // If all optimizations were done, move to next level
  96835. if (allDone) {
  96836. this._currentPriorityLevel++;
  96837. }
  96838. // Let's the system running for a specific amount of time before checking FPS
  96839. scene.executeWhenReady(function () {
  96840. setTimeout(function () {
  96841. _this._checkCurrentState();
  96842. }, _this._trackerDuration);
  96843. });
  96844. };
  96845. /**
  96846. * Release all resources
  96847. */
  96848. SceneOptimizer.prototype.dispose = function () {
  96849. this.stop();
  96850. this.onSuccessObservable.clear();
  96851. this.onFailureObservable.clear();
  96852. this.onNewOptimizationAppliedObservable.clear();
  96853. if (this._sceneDisposeObserver) {
  96854. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  96855. }
  96856. };
  96857. /**
  96858. * Helper function to create a SceneOptimizer with one single line of code
  96859. * @param scene defines the scene to work on
  96860. * @param options defines the options to use with the SceneOptimizer
  96861. * @param onSuccess defines a callback to call on success
  96862. * @param onFailure defines a callback to call on failure
  96863. * @returns the new SceneOptimizer object
  96864. */
  96865. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  96866. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  96867. if (onSuccess) {
  96868. optimizer.onSuccessObservable.add(function () {
  96869. onSuccess();
  96870. });
  96871. }
  96872. if (onFailure) {
  96873. optimizer.onFailureObservable.add(function () {
  96874. onFailure();
  96875. });
  96876. }
  96877. optimizer.start();
  96878. return optimizer;
  96879. };
  96880. return SceneOptimizer;
  96881. }());
  96882. /***/ }),
  96883. /***/ "./Misc/sceneSerializer.ts":
  96884. /*!*********************************!*\
  96885. !*** ./Misc/sceneSerializer.ts ***!
  96886. \*********************************/
  96887. /*! exports provided: SceneSerializer */
  96888. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96889. "use strict";
  96890. __webpack_require__.r(__webpack_exports__);
  96891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  96892. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96893. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96894. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  96895. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  96896. var serializedGeometries = [];
  96897. var serializeGeometry = function (geometry, serializationGeometries) {
  96898. if (serializedGeometries[geometry.id]) {
  96899. return;
  96900. }
  96901. if (geometry.doNotSerialize) {
  96902. return;
  96903. }
  96904. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  96905. serializedGeometries[geometry.id] = true;
  96906. };
  96907. var serializeMesh = function (mesh, serializationScene) {
  96908. var serializationObject = {};
  96909. // Geometry
  96910. var geometry = mesh._geometry;
  96911. if (geometry) {
  96912. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  96913. // 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
  96914. serializeGeometry(geometry, serializationScene.geometries);
  96915. }
  96916. }
  96917. // Custom
  96918. if (mesh.serialize) {
  96919. mesh.serialize(serializationObject);
  96920. }
  96921. return serializationObject;
  96922. };
  96923. var finalizeSingleMesh = function (mesh, serializationObject) {
  96924. //only works if the mesh is already loaded
  96925. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  96926. //serialize material
  96927. if (mesh.material) {
  96928. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  96929. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  96930. serializationObject.materials = serializationObject.materials || [];
  96931. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96932. serializationObject.multiMaterials.push(mesh.material.serialize());
  96933. var _loop_1 = function (submaterial) {
  96934. if (submaterial) {
  96935. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  96936. serializationObject.materials.push(submaterial.serialize());
  96937. }
  96938. }
  96939. };
  96940. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  96941. var submaterial = _a[_i];
  96942. _loop_1(submaterial);
  96943. }
  96944. }
  96945. }
  96946. else {
  96947. serializationObject.materials = serializationObject.materials || [];
  96948. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96949. serializationObject.materials.push(mesh.material.serialize());
  96950. }
  96951. }
  96952. }
  96953. //serialize geometry
  96954. var geometry = mesh._geometry;
  96955. if (geometry) {
  96956. if (!serializationObject.geometries) {
  96957. serializationObject.geometries = {};
  96958. serializationObject.geometries.boxes = [];
  96959. serializationObject.geometries.spheres = [];
  96960. serializationObject.geometries.cylinders = [];
  96961. serializationObject.geometries.toruses = [];
  96962. serializationObject.geometries.grounds = [];
  96963. serializationObject.geometries.planes = [];
  96964. serializationObject.geometries.torusKnots = [];
  96965. serializationObject.geometries.vertexData = [];
  96966. }
  96967. serializeGeometry(geometry, serializationObject.geometries);
  96968. }
  96969. // Skeletons
  96970. if (mesh.skeleton) {
  96971. serializationObject.skeletons = serializationObject.skeletons || [];
  96972. serializationObject.skeletons.push(mesh.skeleton.serialize());
  96973. }
  96974. //serialize the actual mesh
  96975. serializationObject.meshes = serializationObject.meshes || [];
  96976. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96977. }
  96978. };
  96979. /**
  96980. * Class used to serialize a scene into a string
  96981. */
  96982. var SceneSerializer = /** @class */ (function () {
  96983. function SceneSerializer() {
  96984. }
  96985. /**
  96986. * Clear cache used by a previous serialization
  96987. */
  96988. SceneSerializer.ClearCache = function () {
  96989. serializedGeometries = [];
  96990. };
  96991. /**
  96992. * Serialize a scene into a JSON compatible object
  96993. * @param scene defines the scene to serialize
  96994. * @returns a JSON compatible object
  96995. */
  96996. SceneSerializer.Serialize = function (scene) {
  96997. var serializationObject = {};
  96998. SceneSerializer.ClearCache();
  96999. // Scene
  97000. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  97001. serializationObject.autoClear = scene.autoClear;
  97002. serializationObject.clearColor = scene.clearColor.asArray();
  97003. serializationObject.ambientColor = scene.ambientColor.asArray();
  97004. serializationObject.gravity = scene.gravity.asArray();
  97005. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  97006. // Fog
  97007. if (scene.fogMode && scene.fogMode !== 0) {
  97008. serializationObject.fogMode = scene.fogMode;
  97009. serializationObject.fogColor = scene.fogColor.asArray();
  97010. serializationObject.fogStart = scene.fogStart;
  97011. serializationObject.fogEnd = scene.fogEnd;
  97012. serializationObject.fogDensity = scene.fogDensity;
  97013. }
  97014. //Physics
  97015. if (scene.isPhysicsEnabled()) {
  97016. var physicEngine = scene.getPhysicsEngine();
  97017. if (physicEngine) {
  97018. serializationObject.physicsEnabled = true;
  97019. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  97020. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  97021. }
  97022. }
  97023. // Metadata
  97024. if (scene.metadata) {
  97025. serializationObject.metadata = scene.metadata;
  97026. }
  97027. // Morph targets
  97028. serializationObject.morphTargetManagers = [];
  97029. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  97030. var abstractMesh = _a[_i];
  97031. var manager = abstractMesh.morphTargetManager;
  97032. if (manager) {
  97033. serializationObject.morphTargetManagers.push(manager.serialize());
  97034. }
  97035. }
  97036. // Lights
  97037. serializationObject.lights = [];
  97038. var index;
  97039. var light;
  97040. for (index = 0; index < scene.lights.length; index++) {
  97041. light = scene.lights[index];
  97042. if (!light.doNotSerialize) {
  97043. serializationObject.lights.push(light.serialize());
  97044. }
  97045. }
  97046. // Cameras
  97047. serializationObject.cameras = [];
  97048. for (index = 0; index < scene.cameras.length; index++) {
  97049. var camera = scene.cameras[index];
  97050. if (!camera.doNotSerialize) {
  97051. serializationObject.cameras.push(camera.serialize());
  97052. }
  97053. }
  97054. if (scene.activeCamera) {
  97055. serializationObject.activeCameraID = scene.activeCamera.id;
  97056. }
  97057. // Animations
  97058. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  97059. // Reflection probes
  97060. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  97061. serializationObject.reflectionProbes = [];
  97062. for (index = 0; index < scene.reflectionProbes.length; index++) {
  97063. var reflectionProbe = scene.reflectionProbes[index];
  97064. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  97065. }
  97066. }
  97067. // Materials
  97068. serializationObject.materials = [];
  97069. serializationObject.multiMaterials = [];
  97070. var material;
  97071. for (index = 0; index < scene.materials.length; index++) {
  97072. material = scene.materials[index];
  97073. if (!material.doNotSerialize) {
  97074. serializationObject.materials.push(material.serialize());
  97075. }
  97076. }
  97077. // MultiMaterials
  97078. serializationObject.multiMaterials = [];
  97079. for (index = 0; index < scene.multiMaterials.length; index++) {
  97080. var multiMaterial = scene.multiMaterials[index];
  97081. serializationObject.multiMaterials.push(multiMaterial.serialize());
  97082. }
  97083. // Environment texture
  97084. if (scene.environmentTexture) {
  97085. serializationObject.environmentTexture = scene.environmentTexture.name;
  97086. }
  97087. // Skeletons
  97088. serializationObject.skeletons = [];
  97089. for (index = 0; index < scene.skeletons.length; index++) {
  97090. var skeleton = scene.skeletons[index];
  97091. if (!skeleton.doNotSerialize) {
  97092. serializationObject.skeletons.push(skeleton.serialize());
  97093. }
  97094. }
  97095. // Transform nodes
  97096. serializationObject.transformNodes = [];
  97097. for (index = 0; index < scene.transformNodes.length; index++) {
  97098. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  97099. }
  97100. // Geometries
  97101. serializationObject.geometries = {};
  97102. serializationObject.geometries.boxes = [];
  97103. serializationObject.geometries.spheres = [];
  97104. serializationObject.geometries.cylinders = [];
  97105. serializationObject.geometries.toruses = [];
  97106. serializationObject.geometries.grounds = [];
  97107. serializationObject.geometries.planes = [];
  97108. serializationObject.geometries.torusKnots = [];
  97109. serializationObject.geometries.vertexData = [];
  97110. serializedGeometries = [];
  97111. var geometries = scene.getGeometries();
  97112. for (index = 0; index < geometries.length; index++) {
  97113. var geometry = geometries[index];
  97114. if (geometry.isReady()) {
  97115. serializeGeometry(geometry, serializationObject.geometries);
  97116. }
  97117. }
  97118. // Meshes
  97119. serializationObject.meshes = [];
  97120. for (index = 0; index < scene.meshes.length; index++) {
  97121. var abstractMesh = scene.meshes[index];
  97122. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  97123. var mesh = abstractMesh;
  97124. if (!mesh.doNotSerialize) {
  97125. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  97126. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  97127. }
  97128. }
  97129. }
  97130. }
  97131. // Particles Systems
  97132. serializationObject.particleSystems = [];
  97133. for (index = 0; index < scene.particleSystems.length; index++) {
  97134. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  97135. }
  97136. // Action Manager
  97137. if (scene.actionManager) {
  97138. serializationObject.actions = scene.actionManager.serialize("scene");
  97139. }
  97140. // Components
  97141. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  97142. var component = _c[_b];
  97143. component.serialize(serializationObject);
  97144. }
  97145. return serializationObject;
  97146. };
  97147. /**
  97148. * Serialize a mesh into a JSON compatible object
  97149. * @param toSerialize defines the mesh to serialize
  97150. * @param withParents defines if parents must be serialized as well
  97151. * @param withChildren defines if children must be serialized as well
  97152. * @returns a JSON compatible object
  97153. */
  97154. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  97155. if (withParents === void 0) { withParents = false; }
  97156. if (withChildren === void 0) { withChildren = false; }
  97157. var serializationObject = {};
  97158. SceneSerializer.ClearCache();
  97159. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  97160. if (withParents || withChildren) {
  97161. //deliberate for loop! not for each, appended should be processed as well.
  97162. for (var i = 0; i < toSerialize.length; ++i) {
  97163. if (withChildren) {
  97164. toSerialize[i].getDescendants().forEach(function (node) {
  97165. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  97166. toSerialize.push(node);
  97167. }
  97168. });
  97169. }
  97170. //make sure the array doesn't contain the object already
  97171. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  97172. toSerialize.push(toSerialize[i].parent);
  97173. }
  97174. }
  97175. }
  97176. toSerialize.forEach(function (mesh) {
  97177. finalizeSingleMesh(mesh, serializationObject);
  97178. });
  97179. return serializationObject;
  97180. };
  97181. return SceneSerializer;
  97182. }());
  97183. /***/ }),
  97184. /***/ "./Misc/screenshotTools.ts":
  97185. /*!*********************************!*\
  97186. !*** ./Misc/screenshotTools.ts ***!
  97187. \*********************************/
  97188. /*! exports provided: ScreenshotTools */
  97189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97190. "use strict";
  97191. __webpack_require__.r(__webpack_exports__);
  97192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  97193. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97194. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97195. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  97196. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97197. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97198. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97199. // Screenshots
  97200. var screenshotCanvas;
  97201. /**
  97202. * Class containing a set of static utilities functions for screenshots
  97203. */
  97204. var ScreenshotTools = /** @class */ (function () {
  97205. function ScreenshotTools() {
  97206. }
  97207. /**
  97208. * Captures a screenshot of the current rendering
  97209. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97210. * @param engine defines the rendering engine
  97211. * @param camera defines the source camera
  97212. * @param size This parameter can be set to a single number or to an object with the
  97213. * following (optional) properties: precision, width, height. If a single number is passed,
  97214. * it will be used for both width and height. If an object is passed, the screenshot size
  97215. * will be derived from the parameters. The precision property is a multiplier allowing
  97216. * rendering at a higher or lower resolution
  97217. * @param successCallback defines the callback receives a single parameter which contains the
  97218. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97219. * src parameter of an <img> to display it
  97220. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97221. * Check your browser for supported MIME types
  97222. */
  97223. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  97224. if (mimeType === void 0) { mimeType = "image/png"; }
  97225. var width;
  97226. var height;
  97227. // If a precision value is specified
  97228. if (size.precision) {
  97229. width = Math.round(engine.getRenderWidth() * size.precision);
  97230. height = Math.round(width / engine.getAspectRatio(camera));
  97231. }
  97232. else if (size.width && size.height) {
  97233. width = size.width;
  97234. height = size.height;
  97235. }
  97236. //If passing only width, computing height to keep display canvas ratio.
  97237. else if (size.width && !size.height) {
  97238. width = size.width;
  97239. height = Math.round(width / engine.getAspectRatio(camera));
  97240. }
  97241. //If passing only height, computing width to keep display canvas ratio.
  97242. else if (size.height && !size.width) {
  97243. height = size.height;
  97244. width = Math.round(height * engine.getAspectRatio(camera));
  97245. }
  97246. //Assuming here that "size" parameter is a number
  97247. else if (!isNaN(size)) {
  97248. height = size;
  97249. width = size;
  97250. }
  97251. else {
  97252. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97253. return;
  97254. }
  97255. if (!screenshotCanvas) {
  97256. screenshotCanvas = document.createElement('canvas');
  97257. }
  97258. screenshotCanvas.width = width;
  97259. screenshotCanvas.height = height;
  97260. var renderContext = screenshotCanvas.getContext("2d");
  97261. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  97262. var newWidth = width;
  97263. var newHeight = newWidth / ratio;
  97264. if (newHeight > height) {
  97265. newHeight = height;
  97266. newWidth = newHeight * ratio;
  97267. }
  97268. var offsetX = Math.max(0, width - newWidth) / 2;
  97269. var offsetY = Math.max(0, height - newHeight) / 2;
  97270. var renderingCanvas = engine.getRenderingCanvas();
  97271. if (renderContext && renderingCanvas) {
  97272. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  97273. }
  97274. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  97275. };
  97276. /**
  97277. * Generates an image screenshot from the specified camera.
  97278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97279. * @param engine The engine to use for rendering
  97280. * @param camera The camera to use for rendering
  97281. * @param size This parameter can be set to a single number or to an object with the
  97282. * following (optional) properties: precision, width, height. If a single number is passed,
  97283. * it will be used for both width and height. If an object is passed, the screenshot size
  97284. * will be derived from the parameters. The precision property is a multiplier allowing
  97285. * rendering at a higher or lower resolution
  97286. * @param successCallback The callback receives a single parameter which contains the
  97287. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97288. * src parameter of an <img> to display it
  97289. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97290. * Check your browser for supported MIME types
  97291. * @param samples Texture samples (default: 1)
  97292. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97293. * @param fileName A name for for the downloaded file.
  97294. */
  97295. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  97296. if (mimeType === void 0) { mimeType = "image/png"; }
  97297. if (samples === void 0) { samples = 1; }
  97298. if (antialiasing === void 0) { antialiasing = false; }
  97299. var width;
  97300. var height;
  97301. //If a precision value is specified
  97302. if (size.precision) {
  97303. width = Math.round(engine.getRenderWidth() * size.precision);
  97304. height = Math.round(width / engine.getAspectRatio(camera));
  97305. size = { width: width, height: height };
  97306. }
  97307. else if (size.width && size.height) {
  97308. width = size.width;
  97309. height = size.height;
  97310. }
  97311. //If passing only width, computing height to keep display canvas ratio.
  97312. else if (size.width && !size.height) {
  97313. width = size.width;
  97314. height = Math.round(width / engine.getAspectRatio(camera));
  97315. size = { width: width, height: height };
  97316. }
  97317. //If passing only height, computing width to keep display canvas ratio.
  97318. else if (size.height && !size.width) {
  97319. height = size.height;
  97320. width = Math.round(height * engine.getAspectRatio(camera));
  97321. size = { width: width, height: height };
  97322. }
  97323. //Assuming here that "size" parameter is a number
  97324. else if (!isNaN(size)) {
  97325. height = size;
  97326. width = size;
  97327. }
  97328. else {
  97329. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97330. return;
  97331. }
  97332. var scene = camera.getScene();
  97333. var previousCamera = null;
  97334. if (scene.activeCamera !== camera) {
  97335. previousCamera = scene.activeCamera;
  97336. scene.activeCamera = camera;
  97337. }
  97338. var renderCanvas = engine.getRenderingCanvas();
  97339. if (!renderCanvas) {
  97340. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  97341. return;
  97342. }
  97343. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  97344. engine.setSize(width, height);
  97345. scene.render();
  97346. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  97347. 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);
  97348. texture.renderList = null;
  97349. texture.samples = samples;
  97350. if (antialiasing) {
  97351. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  97352. }
  97353. texture.onAfterRenderObservable.add(function () {
  97354. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  97355. });
  97356. scene.incrementRenderId();
  97357. scene.resetCachedMaterial();
  97358. texture.render(true);
  97359. texture.dispose();
  97360. if (previousCamera) {
  97361. scene.activeCamera = previousCamera;
  97362. }
  97363. engine.setSize(originalSize.width, originalSize.height);
  97364. camera.getProjectionMatrix(true); // Force cache refresh;
  97365. };
  97366. return ScreenshotTools;
  97367. }());
  97368. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  97369. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  97370. /***/ }),
  97371. /***/ "./Misc/smartArray.ts":
  97372. /*!****************************!*\
  97373. !*** ./Misc/smartArray.ts ***!
  97374. \****************************/
  97375. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  97376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97377. "use strict";
  97378. __webpack_require__.r(__webpack_exports__);
  97379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  97380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  97381. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97382. /**
  97383. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97384. */
  97385. var SmartArray = /** @class */ (function () {
  97386. /**
  97387. * Instantiates a Smart Array.
  97388. * @param capacity defines the default capacity of the array.
  97389. */
  97390. function SmartArray(capacity) {
  97391. /**
  97392. * The active length of the array.
  97393. */
  97394. this.length = 0;
  97395. this.data = new Array(capacity);
  97396. this._id = SmartArray._GlobalId++;
  97397. }
  97398. /**
  97399. * Pushes a value at the end of the active data.
  97400. * @param value defines the object to push in the array.
  97401. */
  97402. SmartArray.prototype.push = function (value) {
  97403. this.data[this.length++] = value;
  97404. if (this.length > this.data.length) {
  97405. this.data.length *= 2;
  97406. }
  97407. };
  97408. /**
  97409. * Iterates over the active data and apply the lambda to them.
  97410. * @param func defines the action to apply on each value.
  97411. */
  97412. SmartArray.prototype.forEach = function (func) {
  97413. for (var index = 0; index < this.length; index++) {
  97414. func(this.data[index]);
  97415. }
  97416. };
  97417. /**
  97418. * Sorts the full sets of data.
  97419. * @param compareFn defines the comparison function to apply.
  97420. */
  97421. SmartArray.prototype.sort = function (compareFn) {
  97422. this.data.sort(compareFn);
  97423. };
  97424. /**
  97425. * Resets the active data to an empty array.
  97426. */
  97427. SmartArray.prototype.reset = function () {
  97428. this.length = 0;
  97429. };
  97430. /**
  97431. * Releases all the data from the array as well as the array.
  97432. */
  97433. SmartArray.prototype.dispose = function () {
  97434. this.reset();
  97435. if (this.data) {
  97436. this.data.length = 0;
  97437. this.data = [];
  97438. }
  97439. };
  97440. /**
  97441. * Concats the active data with a given array.
  97442. * @param array defines the data to concatenate with.
  97443. */
  97444. SmartArray.prototype.concat = function (array) {
  97445. if (array.length === 0) {
  97446. return;
  97447. }
  97448. if (this.length + array.length > this.data.length) {
  97449. this.data.length = (this.length + array.length) * 2;
  97450. }
  97451. for (var index = 0; index < array.length; index++) {
  97452. this.data[this.length++] = (array.data || array)[index];
  97453. }
  97454. };
  97455. /**
  97456. * Returns the position of a value in the active data.
  97457. * @param value defines the value to find the index for
  97458. * @returns the index if found in the active data otherwise -1
  97459. */
  97460. SmartArray.prototype.indexOf = function (value) {
  97461. var position = this.data.indexOf(value);
  97462. if (position >= this.length) {
  97463. return -1;
  97464. }
  97465. return position;
  97466. };
  97467. /**
  97468. * Returns whether an element is part of the active data.
  97469. * @param value defines the value to look for
  97470. * @returns true if found in the active data otherwise false
  97471. */
  97472. SmartArray.prototype.contains = function (value) {
  97473. return this.indexOf(value) !== -1;
  97474. };
  97475. // Statics
  97476. SmartArray._GlobalId = 0;
  97477. return SmartArray;
  97478. }());
  97479. /**
  97480. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97481. * The data in this array can only be present once
  97482. */
  97483. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  97484. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  97485. function SmartArrayNoDuplicate() {
  97486. var _this = _super !== null && _super.apply(this, arguments) || this;
  97487. _this._duplicateId = 0;
  97488. return _this;
  97489. }
  97490. /**
  97491. * Pushes a value at the end of the active data.
  97492. * THIS DOES NOT PREVENT DUPPLICATE DATA
  97493. * @param value defines the object to push in the array.
  97494. */
  97495. SmartArrayNoDuplicate.prototype.push = function (value) {
  97496. _super.prototype.push.call(this, value);
  97497. if (!value.__smartArrayFlags) {
  97498. value.__smartArrayFlags = {};
  97499. }
  97500. value.__smartArrayFlags[this._id] = this._duplicateId;
  97501. };
  97502. /**
  97503. * Pushes a value at the end of the active data.
  97504. * If the data is already present, it won t be added again
  97505. * @param value defines the object to push in the array.
  97506. * @returns true if added false if it was already present
  97507. */
  97508. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  97509. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  97510. return false;
  97511. }
  97512. this.push(value);
  97513. return true;
  97514. };
  97515. /**
  97516. * Resets the active data to an empty array.
  97517. */
  97518. SmartArrayNoDuplicate.prototype.reset = function () {
  97519. _super.prototype.reset.call(this);
  97520. this._duplicateId++;
  97521. };
  97522. /**
  97523. * Concats the active data with a given array.
  97524. * This ensures no dupplicate will be present in the result.
  97525. * @param array defines the data to concatenate with.
  97526. */
  97527. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  97528. if (array.length === 0) {
  97529. return;
  97530. }
  97531. if (this.length + array.length > this.data.length) {
  97532. this.data.length = (this.length + array.length) * 2;
  97533. }
  97534. for (var index = 0; index < array.length; index++) {
  97535. var item = (array.data || array)[index];
  97536. this.pushNoDuplicate(item);
  97537. }
  97538. };
  97539. return SmartArrayNoDuplicate;
  97540. }(SmartArray));
  97541. /***/ }),
  97542. /***/ "./Misc/stringDictionary.ts":
  97543. /*!**********************************!*\
  97544. !*** ./Misc/stringDictionary.ts ***!
  97545. \**********************************/
  97546. /*! exports provided: StringDictionary */
  97547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97548. "use strict";
  97549. __webpack_require__.r(__webpack_exports__);
  97550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  97551. /**
  97552. * This class implement a typical dictionary using a string as key and the generic type T as value.
  97553. * The underlying implementation relies on an associative array to ensure the best performances.
  97554. * The value can be anything including 'null' but except 'undefined'
  97555. */
  97556. var StringDictionary = /** @class */ (function () {
  97557. function StringDictionary() {
  97558. this._count = 0;
  97559. this._data = {};
  97560. }
  97561. /**
  97562. * This will clear this dictionary and copy the content from the 'source' one.
  97563. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  97564. * @param source the dictionary to take the content from and copy to this dictionary
  97565. */
  97566. StringDictionary.prototype.copyFrom = function (source) {
  97567. var _this = this;
  97568. this.clear();
  97569. source.forEach(function (t, v) { return _this.add(t, v); });
  97570. };
  97571. /**
  97572. * Get a value based from its key
  97573. * @param key the given key to get the matching value from
  97574. * @return the value if found, otherwise undefined is returned
  97575. */
  97576. StringDictionary.prototype.get = function (key) {
  97577. var val = this._data[key];
  97578. if (val !== undefined) {
  97579. return val;
  97580. }
  97581. return undefined;
  97582. };
  97583. /**
  97584. * Get a value from its key or add it if it doesn't exist.
  97585. * This method will ensure you that a given key/data will be present in the dictionary.
  97586. * @param key the given key to get the matching value from
  97587. * @param factory the factory that will create the value if the key is not present in the dictionary.
  97588. * The factory will only be invoked if there's no data for the given key.
  97589. * @return the value corresponding to the key.
  97590. */
  97591. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  97592. var val = this.get(key);
  97593. if (val !== undefined) {
  97594. return val;
  97595. }
  97596. val = factory(key);
  97597. if (val) {
  97598. this.add(key, val);
  97599. }
  97600. return val;
  97601. };
  97602. /**
  97603. * Get a value from its key if present in the dictionary otherwise add it
  97604. * @param key the key to get the value from
  97605. * @param val if there's no such key/value pair in the dictionary add it with this value
  97606. * @return the value corresponding to the key
  97607. */
  97608. StringDictionary.prototype.getOrAdd = function (key, val) {
  97609. var curVal = this.get(key);
  97610. if (curVal !== undefined) {
  97611. return curVal;
  97612. }
  97613. this.add(key, val);
  97614. return val;
  97615. };
  97616. /**
  97617. * Check if there's a given key in the dictionary
  97618. * @param key the key to check for
  97619. * @return true if the key is present, false otherwise
  97620. */
  97621. StringDictionary.prototype.contains = function (key) {
  97622. return this._data[key] !== undefined;
  97623. };
  97624. /**
  97625. * Add a new key and its corresponding value
  97626. * @param key the key to add
  97627. * @param value the value corresponding to the key
  97628. * @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
  97629. */
  97630. StringDictionary.prototype.add = function (key, value) {
  97631. if (this._data[key] !== undefined) {
  97632. return false;
  97633. }
  97634. this._data[key] = value;
  97635. ++this._count;
  97636. return true;
  97637. };
  97638. /**
  97639. * Update a specific value associated to a key
  97640. * @param key defines the key to use
  97641. * @param value defines the value to store
  97642. * @returns true if the value was updated (or false if the key was not found)
  97643. */
  97644. StringDictionary.prototype.set = function (key, value) {
  97645. if (this._data[key] === undefined) {
  97646. return false;
  97647. }
  97648. this._data[key] = value;
  97649. return true;
  97650. };
  97651. /**
  97652. * Get the element of the given key and remove it from the dictionary
  97653. * @param key defines the key to search
  97654. * @returns the value associated with the key or null if not found
  97655. */
  97656. StringDictionary.prototype.getAndRemove = function (key) {
  97657. var val = this.get(key);
  97658. if (val !== undefined) {
  97659. delete this._data[key];
  97660. --this._count;
  97661. return val;
  97662. }
  97663. return null;
  97664. };
  97665. /**
  97666. * Remove a key/value from the dictionary.
  97667. * @param key the key to remove
  97668. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  97669. */
  97670. StringDictionary.prototype.remove = function (key) {
  97671. if (this.contains(key)) {
  97672. delete this._data[key];
  97673. --this._count;
  97674. return true;
  97675. }
  97676. return false;
  97677. };
  97678. /**
  97679. * Clear the whole content of the dictionary
  97680. */
  97681. StringDictionary.prototype.clear = function () {
  97682. this._data = {};
  97683. this._count = 0;
  97684. };
  97685. Object.defineProperty(StringDictionary.prototype, "count", {
  97686. /**
  97687. * Gets the current count
  97688. */
  97689. get: function () {
  97690. return this._count;
  97691. },
  97692. enumerable: true,
  97693. configurable: true
  97694. });
  97695. /**
  97696. * Execute a callback on each key/val of the dictionary.
  97697. * Note that you can remove any element in this dictionary in the callback implementation
  97698. * @param callback the callback to execute on a given key/value pair
  97699. */
  97700. StringDictionary.prototype.forEach = function (callback) {
  97701. for (var cur in this._data) {
  97702. var val = this._data[cur];
  97703. callback(cur, val);
  97704. }
  97705. };
  97706. /**
  97707. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  97708. * If the callback returns null or undefined the method will iterate to the next key/value pair
  97709. * Note that you can remove any element in this dictionary in the callback implementation
  97710. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  97711. * @returns the first item
  97712. */
  97713. StringDictionary.prototype.first = function (callback) {
  97714. for (var cur in this._data) {
  97715. var val = this._data[cur];
  97716. var res = callback(cur, val);
  97717. if (res) {
  97718. return res;
  97719. }
  97720. }
  97721. return null;
  97722. };
  97723. return StringDictionary;
  97724. }());
  97725. /***/ }),
  97726. /***/ "./Misc/tags.ts":
  97727. /*!**********************!*\
  97728. !*** ./Misc/tags.ts ***!
  97729. \**********************/
  97730. /*! exports provided: Tags */
  97731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97732. "use strict";
  97733. __webpack_require__.r(__webpack_exports__);
  97734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  97735. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97736. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  97737. /**
  97738. * Class used to store custom tags
  97739. */
  97740. var Tags = /** @class */ (function () {
  97741. function Tags() {
  97742. }
  97743. /**
  97744. * Adds support for tags on the given object
  97745. * @param obj defines the object to use
  97746. */
  97747. Tags.EnableFor = function (obj) {
  97748. obj._tags = obj._tags || {};
  97749. obj.hasTags = function () {
  97750. return Tags.HasTags(obj);
  97751. };
  97752. obj.addTags = function (tagsString) {
  97753. return Tags.AddTagsTo(obj, tagsString);
  97754. };
  97755. obj.removeTags = function (tagsString) {
  97756. return Tags.RemoveTagsFrom(obj, tagsString);
  97757. };
  97758. obj.matchesTagsQuery = function (tagsQuery) {
  97759. return Tags.MatchesQuery(obj, tagsQuery);
  97760. };
  97761. };
  97762. /**
  97763. * Removes tags support
  97764. * @param obj defines the object to use
  97765. */
  97766. Tags.DisableFor = function (obj) {
  97767. delete obj._tags;
  97768. delete obj.hasTags;
  97769. delete obj.addTags;
  97770. delete obj.removeTags;
  97771. delete obj.matchesTagsQuery;
  97772. };
  97773. /**
  97774. * Gets a boolean indicating if the given object has tags
  97775. * @param obj defines the object to use
  97776. * @returns a boolean
  97777. */
  97778. Tags.HasTags = function (obj) {
  97779. if (!obj._tags) {
  97780. return false;
  97781. }
  97782. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  97783. };
  97784. /**
  97785. * Gets the tags available on a given object
  97786. * @param obj defines the object to use
  97787. * @param asString defines if the tags must be returned as a string instead of an array of strings
  97788. * @returns the tags
  97789. */
  97790. Tags.GetTags = function (obj, asString) {
  97791. if (asString === void 0) { asString = true; }
  97792. if (!obj._tags) {
  97793. return null;
  97794. }
  97795. if (asString) {
  97796. var tagsArray = [];
  97797. for (var tag in obj._tags) {
  97798. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  97799. tagsArray.push(tag);
  97800. }
  97801. }
  97802. return tagsArray.join(" ");
  97803. }
  97804. else {
  97805. return obj._tags;
  97806. }
  97807. };
  97808. /**
  97809. * Adds tags to an object
  97810. * @param obj defines the object to use
  97811. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  97812. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  97813. */
  97814. Tags.AddTagsTo = function (obj, tagsString) {
  97815. if (!tagsString) {
  97816. return;
  97817. }
  97818. if (typeof tagsString !== "string") {
  97819. return;
  97820. }
  97821. var tags = tagsString.split(" ");
  97822. tags.forEach(function (tag, index, array) {
  97823. Tags._AddTagTo(obj, tag);
  97824. });
  97825. };
  97826. /**
  97827. * @hidden
  97828. */
  97829. Tags._AddTagTo = function (obj, tag) {
  97830. tag = tag.trim();
  97831. if (tag === "" || tag === "true" || tag === "false") {
  97832. return;
  97833. }
  97834. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  97835. return;
  97836. }
  97837. Tags.EnableFor(obj);
  97838. obj._tags[tag] = true;
  97839. };
  97840. /**
  97841. * Removes specific tags from a specific object
  97842. * @param obj defines the object to use
  97843. * @param tagsString defines the tags to remove
  97844. */
  97845. Tags.RemoveTagsFrom = function (obj, tagsString) {
  97846. if (!Tags.HasTags(obj)) {
  97847. return;
  97848. }
  97849. var tags = tagsString.split(" ");
  97850. for (var t in tags) {
  97851. Tags._RemoveTagFrom(obj, tags[t]);
  97852. }
  97853. };
  97854. /**
  97855. * @hidden
  97856. */
  97857. Tags._RemoveTagFrom = function (obj, tag) {
  97858. delete obj._tags[tag];
  97859. };
  97860. /**
  97861. * Defines if tags hosted on an object match a given query
  97862. * @param obj defines the object to use
  97863. * @param tagsQuery defines the tag query
  97864. * @returns a boolean
  97865. */
  97866. Tags.MatchesQuery = function (obj, tagsQuery) {
  97867. if (tagsQuery === undefined) {
  97868. return true;
  97869. }
  97870. if (tagsQuery === "") {
  97871. return Tags.HasTags(obj);
  97872. }
  97873. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  97874. };
  97875. return Tags;
  97876. }());
  97877. /***/ }),
  97878. /***/ "./Misc/textureTools.ts":
  97879. /*!******************************!*\
  97880. !*** ./Misc/textureTools.ts ***!
  97881. \******************************/
  97882. /*! exports provided: TextureTools */
  97883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97884. "use strict";
  97885. __webpack_require__.r(__webpack_exports__);
  97886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  97887. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97888. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97889. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  97890. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97891. /**
  97892. * Class used to host texture specific utilities
  97893. */
  97894. var TextureTools = /** @class */ (function () {
  97895. function TextureTools() {
  97896. }
  97897. /**
  97898. * Uses the GPU to create a copy texture rescaled at a given size
  97899. * @param texture Texture to copy from
  97900. * @param width defines the desired width
  97901. * @param height defines the desired height
  97902. * @param useBilinearMode defines if bilinear mode has to be used
  97903. * @return the generated texture
  97904. */
  97905. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  97906. if (useBilinearMode === void 0) { useBilinearMode = true; }
  97907. var scene = texture.getScene();
  97908. var engine = scene.getEngine();
  97909. 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);
  97910. rtt.wrapU = texture.wrapU;
  97911. rtt.wrapV = texture.wrapV;
  97912. rtt.uOffset = texture.uOffset;
  97913. rtt.vOffset = texture.vOffset;
  97914. rtt.uScale = texture.uScale;
  97915. rtt.vScale = texture.vScale;
  97916. rtt.uAng = texture.uAng;
  97917. rtt.vAng = texture.vAng;
  97918. rtt.wAng = texture.wAng;
  97919. rtt.coordinatesIndex = texture.coordinatesIndex;
  97920. rtt.level = texture.level;
  97921. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  97922. rtt._texture.isReady = false;
  97923. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97924. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97925. 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);
  97926. passPostProcess.getEffect().executeWhenCompiled(function () {
  97927. passPostProcess.onApply = function (effect) {
  97928. effect.setTexture("textureSampler", texture);
  97929. };
  97930. var internalTexture = rtt.getInternalTexture();
  97931. if (internalTexture) {
  97932. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  97933. engine.unBindFramebuffer(internalTexture);
  97934. rtt.disposeFramebufferObjects();
  97935. passPostProcess.dispose();
  97936. internalTexture.isReady = true;
  97937. }
  97938. });
  97939. return rtt;
  97940. };
  97941. /**
  97942. * Gets an environment BRDF texture for a given scene
  97943. * @param scene defines the hosting scene
  97944. * @returns the environment BRDF texture
  97945. */
  97946. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  97947. if (!scene._environmentBRDFTexture) {
  97948. 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);
  97949. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97950. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97951. scene._environmentBRDFTexture = texture;
  97952. }
  97953. return scene._environmentBRDFTexture;
  97954. };
  97955. 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=";
  97956. return TextureTools;
  97957. }());
  97958. /***/ }),
  97959. /***/ "./Misc/tga.ts":
  97960. /*!*********************!*\
  97961. !*** ./Misc/tga.ts ***!
  97962. \*********************/
  97963. /*! exports provided: TGATools */
  97964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97965. "use strict";
  97966. __webpack_require__.r(__webpack_exports__);
  97967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  97968. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97969. /**
  97970. * Based on jsTGALoader - Javascript loader for TGA file
  97971. * By Vincent Thibault
  97972. * @see http://blog.robrowser.com/javascript-tga-loader.html
  97973. */
  97974. var TGATools = /** @class */ (function () {
  97975. function TGATools() {
  97976. }
  97977. /**
  97978. * Gets the header of a TGA file
  97979. * @param data defines the TGA data
  97980. * @returns the header
  97981. */
  97982. TGATools.GetTGAHeader = function (data) {
  97983. var offset = 0;
  97984. var header = {
  97985. id_length: data[offset++],
  97986. colormap_type: data[offset++],
  97987. image_type: data[offset++],
  97988. colormap_index: data[offset++] | data[offset++] << 8,
  97989. colormap_length: data[offset++] | data[offset++] << 8,
  97990. colormap_size: data[offset++],
  97991. origin: [
  97992. data[offset++] | data[offset++] << 8,
  97993. data[offset++] | data[offset++] << 8
  97994. ],
  97995. width: data[offset++] | data[offset++] << 8,
  97996. height: data[offset++] | data[offset++] << 8,
  97997. pixel_size: data[offset++],
  97998. flags: data[offset++]
  97999. };
  98000. return header;
  98001. };
  98002. /**
  98003. * Uploads TGA content to a Babylon Texture
  98004. * @hidden
  98005. */
  98006. TGATools.UploadContent = function (texture, data) {
  98007. // Not enough data to contain header ?
  98008. if (data.length < 19) {
  98009. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  98010. return;
  98011. }
  98012. // Read Header
  98013. var offset = 18;
  98014. var header = TGATools.GetTGAHeader(data);
  98015. // Assume it's a valid Targa file.
  98016. if (header.id_length + offset > data.length) {
  98017. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  98018. return;
  98019. }
  98020. // Skip not needed data
  98021. offset += header.id_length;
  98022. var use_rle = false;
  98023. var use_pal = false;
  98024. var use_grey = false;
  98025. // Get some informations.
  98026. switch (header.image_type) {
  98027. case TGATools._TYPE_RLE_INDEXED:
  98028. use_rle = true;
  98029. case TGATools._TYPE_INDEXED:
  98030. use_pal = true;
  98031. break;
  98032. case TGATools._TYPE_RLE_RGB:
  98033. use_rle = true;
  98034. case TGATools._TYPE_RGB:
  98035. // use_rgb = true;
  98036. break;
  98037. case TGATools._TYPE_RLE_GREY:
  98038. use_rle = true;
  98039. case TGATools._TYPE_GREY:
  98040. use_grey = true;
  98041. break;
  98042. }
  98043. var pixel_data;
  98044. // var numAlphaBits = header.flags & 0xf;
  98045. var pixel_size = header.pixel_size >> 3;
  98046. var pixel_total = header.width * header.height * pixel_size;
  98047. // Read palettes
  98048. var palettes;
  98049. if (use_pal) {
  98050. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  98051. }
  98052. // Read LRE
  98053. if (use_rle) {
  98054. pixel_data = new Uint8Array(pixel_total);
  98055. var c, count, i;
  98056. var localOffset = 0;
  98057. var pixels = new Uint8Array(pixel_size);
  98058. while (offset < pixel_total && localOffset < pixel_total) {
  98059. c = data[offset++];
  98060. count = (c & 0x7f) + 1;
  98061. // RLE pixels
  98062. if (c & 0x80) {
  98063. // Bind pixel tmp array
  98064. for (i = 0; i < pixel_size; ++i) {
  98065. pixels[i] = data[offset++];
  98066. }
  98067. // Copy pixel array
  98068. for (i = 0; i < count; ++i) {
  98069. pixel_data.set(pixels, localOffset + i * pixel_size);
  98070. }
  98071. localOffset += pixel_size * count;
  98072. }
  98073. // Raw pixels
  98074. else {
  98075. count *= pixel_size;
  98076. for (i = 0; i < count; ++i) {
  98077. pixel_data[localOffset + i] = data[offset++];
  98078. }
  98079. localOffset += count;
  98080. }
  98081. }
  98082. }
  98083. // RAW Pixels
  98084. else {
  98085. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  98086. }
  98087. // Load to texture
  98088. var x_start, y_start, x_step, y_step, y_end, x_end;
  98089. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  98090. default:
  98091. case TGATools._ORIGIN_UL:
  98092. x_start = 0;
  98093. x_step = 1;
  98094. x_end = header.width;
  98095. y_start = 0;
  98096. y_step = 1;
  98097. y_end = header.height;
  98098. break;
  98099. case TGATools._ORIGIN_BL:
  98100. x_start = 0;
  98101. x_step = 1;
  98102. x_end = header.width;
  98103. y_start = header.height - 1;
  98104. y_step = -1;
  98105. y_end = -1;
  98106. break;
  98107. case TGATools._ORIGIN_UR:
  98108. x_start = header.width - 1;
  98109. x_step = -1;
  98110. x_end = -1;
  98111. y_start = 0;
  98112. y_step = 1;
  98113. y_end = header.height;
  98114. break;
  98115. case TGATools._ORIGIN_BR:
  98116. x_start = header.width - 1;
  98117. x_step = -1;
  98118. x_end = -1;
  98119. y_start = header.height - 1;
  98120. y_step = -1;
  98121. y_end = -1;
  98122. break;
  98123. }
  98124. // Load the specify method
  98125. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  98126. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  98127. var engine = texture.getEngine();
  98128. engine._uploadDataToTextureDirectly(texture, imageData);
  98129. };
  98130. /** @hidden */
  98131. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98132. var image = pixel_data, colormap = palettes;
  98133. var width = header.width, height = header.height;
  98134. var color, i = 0, x, y;
  98135. var imageData = new Uint8Array(width * height * 4);
  98136. for (y = y_start; y !== y_end; y += y_step) {
  98137. for (x = x_start; x !== x_end; x += x_step, i++) {
  98138. color = image[i];
  98139. imageData[(x + width * y) * 4 + 3] = 255;
  98140. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  98141. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  98142. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  98143. }
  98144. }
  98145. return imageData;
  98146. };
  98147. /** @hidden */
  98148. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98149. var image = pixel_data;
  98150. var width = header.width, height = header.height;
  98151. var color, i = 0, x, y;
  98152. var imageData = new Uint8Array(width * height * 4);
  98153. for (y = y_start; y !== y_end; y += y_step) {
  98154. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98155. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  98156. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  98157. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  98158. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  98159. imageData[(x + width * y) * 4 + 0] = r;
  98160. imageData[(x + width * y) * 4 + 1] = g;
  98161. imageData[(x + width * y) * 4 + 2] = b;
  98162. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  98163. }
  98164. }
  98165. return imageData;
  98166. };
  98167. /** @hidden */
  98168. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98169. var image = pixel_data;
  98170. var width = header.width, height = header.height;
  98171. var i = 0, x, y;
  98172. var imageData = new Uint8Array(width * height * 4);
  98173. for (y = y_start; y !== y_end; y += y_step) {
  98174. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  98175. imageData[(x + width * y) * 4 + 3] = 255;
  98176. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98177. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98178. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98179. }
  98180. }
  98181. return imageData;
  98182. };
  98183. /** @hidden */
  98184. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98185. var image = pixel_data;
  98186. var width = header.width, height = header.height;
  98187. var i = 0, x, y;
  98188. var imageData = new Uint8Array(width * height * 4);
  98189. for (y = y_start; y !== y_end; y += y_step) {
  98190. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  98191. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98192. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98193. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98194. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  98195. }
  98196. }
  98197. return imageData;
  98198. };
  98199. /** @hidden */
  98200. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98201. var image = pixel_data;
  98202. var width = header.width, height = header.height;
  98203. var color, i = 0, x, y;
  98204. var imageData = new Uint8Array(width * height * 4);
  98205. for (y = y_start; y !== y_end; y += y_step) {
  98206. for (x = x_start; x !== x_end; x += x_step, i++) {
  98207. color = image[i];
  98208. imageData[(x + width * y) * 4 + 0] = color;
  98209. imageData[(x + width * y) * 4 + 1] = color;
  98210. imageData[(x + width * y) * 4 + 2] = color;
  98211. imageData[(x + width * y) * 4 + 3] = 255;
  98212. }
  98213. }
  98214. return imageData;
  98215. };
  98216. /** @hidden */
  98217. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98218. var image = pixel_data;
  98219. var width = header.width, height = header.height;
  98220. var i = 0, x, y;
  98221. var imageData = new Uint8Array(width * height * 4);
  98222. for (y = y_start; y !== y_end; y += y_step) {
  98223. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98224. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  98225. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  98226. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98227. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  98228. }
  98229. }
  98230. return imageData;
  98231. };
  98232. //private static _TYPE_NO_DATA = 0;
  98233. TGATools._TYPE_INDEXED = 1;
  98234. TGATools._TYPE_RGB = 2;
  98235. TGATools._TYPE_GREY = 3;
  98236. TGATools._TYPE_RLE_INDEXED = 9;
  98237. TGATools._TYPE_RLE_RGB = 10;
  98238. TGATools._TYPE_RLE_GREY = 11;
  98239. TGATools._ORIGIN_MASK = 0x30;
  98240. TGATools._ORIGIN_SHIFT = 0x04;
  98241. TGATools._ORIGIN_BL = 0x00;
  98242. TGATools._ORIGIN_BR = 0x01;
  98243. TGATools._ORIGIN_UL = 0x02;
  98244. TGATools._ORIGIN_UR = 0x03;
  98245. return TGATools;
  98246. }());
  98247. /***/ }),
  98248. /***/ "./Misc/tools.ts":
  98249. /*!***********************!*\
  98250. !*** ./Misc/tools.ts ***!
  98251. \***********************/
  98252. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  98253. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98254. "use strict";
  98255. __webpack_require__.r(__webpack_exports__);
  98256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  98257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  98258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  98259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  98260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  98261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  98262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  98263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  98264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  98265. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98266. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98267. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  98268. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98269. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  98270. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98271. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  98272. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  98273. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  98274. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  98275. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  98276. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  98277. /** Class used to store color4 gradient */
  98278. var ColorGradient = /** @class */ (function () {
  98279. function ColorGradient() {
  98280. }
  98281. /**
  98282. * Will get a color picked randomly between color1 and color2.
  98283. * If color2 is undefined then color1 will be used
  98284. * @param result defines the target Color4 to store the result in
  98285. */
  98286. ColorGradient.prototype.getColorToRef = function (result) {
  98287. if (!this.color2) {
  98288. result.copyFrom(this.color1);
  98289. return;
  98290. }
  98291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  98292. };
  98293. return ColorGradient;
  98294. }());
  98295. /** Class used to store color 3 gradient */
  98296. var Color3Gradient = /** @class */ (function () {
  98297. function Color3Gradient() {
  98298. }
  98299. return Color3Gradient;
  98300. }());
  98301. /** Class used to store factor gradient */
  98302. var FactorGradient = /** @class */ (function () {
  98303. function FactorGradient() {
  98304. }
  98305. /**
  98306. * Will get a number picked randomly between factor1 and factor2.
  98307. * If factor2 is undefined then factor1 will be used
  98308. * @returns the picked number
  98309. */
  98310. FactorGradient.prototype.getFactor = function () {
  98311. if (this.factor2 === undefined) {
  98312. return this.factor1;
  98313. }
  98314. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  98315. };
  98316. return FactorGradient;
  98317. }());
  98318. /**
  98319. * @ignore
  98320. * Application error to support additional information when loading a file
  98321. */
  98322. var LoadFileError = /** @class */ (function (_super) {
  98323. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  98324. /**
  98325. * Creates a new LoadFileError
  98326. * @param message defines the message of the error
  98327. * @param request defines the optional XHR request
  98328. */
  98329. function LoadFileError(message,
  98330. /** defines the optional XHR request */
  98331. request) {
  98332. var _this = _super.call(this, message) || this;
  98333. _this.request = request;
  98334. _this.name = "LoadFileError";
  98335. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  98336. return _this;
  98337. }
  98338. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  98339. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  98340. // Polyfill for Object.setPrototypeOf if necessary.
  98341. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  98342. return LoadFileError;
  98343. }(Error));
  98344. /**
  98345. * Class used to define a retry strategy when error happens while loading assets
  98346. */
  98347. var RetryStrategy = /** @class */ (function () {
  98348. function RetryStrategy() {
  98349. }
  98350. /**
  98351. * Function used to defines an exponential back off strategy
  98352. * @param maxRetries defines the maximum number of retries (3 by default)
  98353. * @param baseInterval defines the interval between retries
  98354. * @returns the strategy function to use
  98355. */
  98356. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  98357. if (maxRetries === void 0) { maxRetries = 3; }
  98358. if (baseInterval === void 0) { baseInterval = 500; }
  98359. return function (url, request, retryIndex) {
  98360. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  98361. return -1;
  98362. }
  98363. return Math.pow(2, retryIndex) * baseInterval;
  98364. };
  98365. };
  98366. return RetryStrategy;
  98367. }());
  98368. // Screenshots
  98369. var screenshotCanvas;
  98370. /**
  98371. * Class containing a set of static utilities functions
  98372. */
  98373. var Tools = /** @class */ (function () {
  98374. function Tools() {
  98375. }
  98376. /**
  98377. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98378. * @param u defines the coordinate on X axis
  98379. * @param v defines the coordinate on Y axis
  98380. * @param width defines the width of the source data
  98381. * @param height defines the height of the source data
  98382. * @param pixels defines the source byte array
  98383. * @param color defines the output color
  98384. */
  98385. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  98386. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  98387. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  98388. var position = (wrappedU + wrappedV * width) * 4;
  98389. color.r = pixels[position] / 255;
  98390. color.g = pixels[position + 1] / 255;
  98391. color.b = pixels[position + 2] / 255;
  98392. color.a = pixels[position + 3] / 255;
  98393. };
  98394. /**
  98395. * Interpolates between a and b via alpha
  98396. * @param a The lower value (returned when alpha = 0)
  98397. * @param b The upper value (returned when alpha = 1)
  98398. * @param alpha The interpolation-factor
  98399. * @return The mixed value
  98400. */
  98401. Tools.Mix = function (a, b, alpha) {
  98402. return a * (1 - alpha) + b * alpha;
  98403. };
  98404. /**
  98405. * Tries to instantiate a new object from a given class name
  98406. * @param className defines the class name to instantiate
  98407. * @returns the new object or null if the system was not able to do the instantiation
  98408. */
  98409. Tools.Instantiate = function (className) {
  98410. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  98411. return Tools.RegisteredExternalClasses[className];
  98412. }
  98413. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  98414. if (internalClass) {
  98415. return internalClass;
  98416. }
  98417. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  98418. var arr = className.split(".");
  98419. var fn = (window || this);
  98420. for (var i = 0, len = arr.length; i < len; i++) {
  98421. fn = fn[arr[i]];
  98422. }
  98423. if (typeof fn !== "function") {
  98424. return null;
  98425. }
  98426. return fn;
  98427. };
  98428. /**
  98429. * Provides a slice function that will work even on IE
  98430. * @param data defines the array to slice
  98431. * @param start defines the start of the data (optional)
  98432. * @param end defines the end of the data (optional)
  98433. * @returns the new sliced array
  98434. */
  98435. Tools.Slice = function (data, start, end) {
  98436. if (data.slice) {
  98437. return data.slice(start, end);
  98438. }
  98439. return Array.prototype.slice.call(data, start, end);
  98440. };
  98441. /**
  98442. * Polyfill for setImmediate
  98443. * @param action defines the action to execute after the current execution block
  98444. */
  98445. Tools.SetImmediate = function (action) {
  98446. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  98447. window.setImmediate(action);
  98448. }
  98449. else {
  98450. setTimeout(action, 1);
  98451. }
  98452. };
  98453. /**
  98454. * Function indicating if a number is an exponent of 2
  98455. * @param value defines the value to test
  98456. * @returns true if the value is an exponent of 2
  98457. */
  98458. Tools.IsExponentOfTwo = function (value) {
  98459. var count = 1;
  98460. do {
  98461. count *= 2;
  98462. } while (count < value);
  98463. return count === value;
  98464. };
  98465. /**
  98466. * Returns the nearest 32-bit single precision float representation of a Number
  98467. * @param value A Number. If the parameter is of a different type, it will get converted
  98468. * to a number or to NaN if it cannot be converted
  98469. * @returns number
  98470. */
  98471. Tools.FloatRound = function (value) {
  98472. if (Math.fround) {
  98473. return Math.fround(value);
  98474. }
  98475. return (Tools._tmpFloatArray[0] = value);
  98476. };
  98477. /**
  98478. * Find the next highest power of two.
  98479. * @param x Number to start search from.
  98480. * @return Next highest power of two.
  98481. */
  98482. Tools.CeilingPOT = function (x) {
  98483. x--;
  98484. x |= x >> 1;
  98485. x |= x >> 2;
  98486. x |= x >> 4;
  98487. x |= x >> 8;
  98488. x |= x >> 16;
  98489. x++;
  98490. return x;
  98491. };
  98492. /**
  98493. * Find the next lowest power of two.
  98494. * @param x Number to start search from.
  98495. * @return Next lowest power of two.
  98496. */
  98497. Tools.FloorPOT = function (x) {
  98498. x = x | (x >> 1);
  98499. x = x | (x >> 2);
  98500. x = x | (x >> 4);
  98501. x = x | (x >> 8);
  98502. x = x | (x >> 16);
  98503. return x - (x >> 1);
  98504. };
  98505. /**
  98506. * Find the nearest power of two.
  98507. * @param x Number to start search from.
  98508. * @return Next nearest power of two.
  98509. */
  98510. Tools.NearestPOT = function (x) {
  98511. var c = Tools.CeilingPOT(x);
  98512. var f = Tools.FloorPOT(x);
  98513. return (c - x) > (x - f) ? f : c;
  98514. };
  98515. /**
  98516. * Get the closest exponent of two
  98517. * @param value defines the value to approximate
  98518. * @param max defines the maximum value to return
  98519. * @param mode defines how to define the closest value
  98520. * @returns closest exponent of two of the given value
  98521. */
  98522. Tools.GetExponentOfTwo = function (value, max, mode) {
  98523. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  98524. var pot;
  98525. switch (mode) {
  98526. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  98527. pot = Tools.FloorPOT(value);
  98528. break;
  98529. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  98530. pot = Tools.NearestPOT(value);
  98531. break;
  98532. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  98533. default:
  98534. pot = Tools.CeilingPOT(value);
  98535. break;
  98536. }
  98537. return Math.min(pot, max);
  98538. };
  98539. /**
  98540. * Extracts the filename from a path
  98541. * @param path defines the path to use
  98542. * @returns the filename
  98543. */
  98544. Tools.GetFilename = function (path) {
  98545. var index = path.lastIndexOf("/");
  98546. if (index < 0) {
  98547. return path;
  98548. }
  98549. return path.substring(index + 1);
  98550. };
  98551. /**
  98552. * Extracts the "folder" part of a path (everything before the filename).
  98553. * @param uri The URI to extract the info from
  98554. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98555. * @returns The "folder" part of the path
  98556. */
  98557. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  98558. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  98559. var index = uri.lastIndexOf("/");
  98560. if (index < 0) {
  98561. if (returnUnchangedIfNoSlash) {
  98562. return uri;
  98563. }
  98564. return "";
  98565. }
  98566. return uri.substring(0, index + 1);
  98567. };
  98568. /**
  98569. * Convert an angle in radians to degrees
  98570. * @param angle defines the angle to convert
  98571. * @returns the angle in degrees
  98572. */
  98573. Tools.ToDegrees = function (angle) {
  98574. return angle * 180 / Math.PI;
  98575. };
  98576. /**
  98577. * Convert an angle in degrees to radians
  98578. * @param angle defines the angle to convert
  98579. * @returns the angle in radians
  98580. */
  98581. Tools.ToRadians = function (angle) {
  98582. return angle * Math.PI / 180;
  98583. };
  98584. /**
  98585. * Encode a buffer to a base64 string
  98586. * @param buffer defines the buffer to encode
  98587. * @returns the encoded string
  98588. */
  98589. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  98590. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  98591. var output = "";
  98592. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  98593. var i = 0;
  98594. var bytes = new Uint8Array(buffer);
  98595. while (i < bytes.length) {
  98596. chr1 = bytes[i++];
  98597. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  98598. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  98599. enc1 = chr1 >> 2;
  98600. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  98601. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  98602. enc4 = chr3 & 63;
  98603. if (isNaN(chr2)) {
  98604. enc3 = enc4 = 64;
  98605. }
  98606. else if (isNaN(chr3)) {
  98607. enc4 = 64;
  98608. }
  98609. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  98610. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  98611. }
  98612. return "data:image/png;base64," + output;
  98613. };
  98614. /**
  98615. * Extracts minimum and maximum values from a list of indexed positions
  98616. * @param positions defines the positions to use
  98617. * @param indices defines the indices to the positions
  98618. * @param indexStart defines the start index
  98619. * @param indexCount defines the end index
  98620. * @param bias defines bias value to add to the result
  98621. * @return minimum and maximum values
  98622. */
  98623. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  98624. if (bias === void 0) { bias = null; }
  98625. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98626. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98627. for (var index = indexStart; index < indexStart + indexCount; index++) {
  98628. var offset = indices[index] * 3;
  98629. var x = positions[offset];
  98630. var y = positions[offset + 1];
  98631. var z = positions[offset + 2];
  98632. minimum.minimizeInPlaceFromFloats(x, y, z);
  98633. maximum.maximizeInPlaceFromFloats(x, y, z);
  98634. }
  98635. if (bias) {
  98636. minimum.x -= minimum.x * bias.x + bias.y;
  98637. minimum.y -= minimum.y * bias.x + bias.y;
  98638. minimum.z -= minimum.z * bias.x + bias.y;
  98639. maximum.x += maximum.x * bias.x + bias.y;
  98640. maximum.y += maximum.y * bias.x + bias.y;
  98641. maximum.z += maximum.z * bias.x + bias.y;
  98642. }
  98643. return {
  98644. minimum: minimum,
  98645. maximum: maximum
  98646. };
  98647. };
  98648. /**
  98649. * Extracts minimum and maximum values from a list of positions
  98650. * @param positions defines the positions to use
  98651. * @param start defines the start index in the positions array
  98652. * @param count defines the number of positions to handle
  98653. * @param bias defines bias value to add to the result
  98654. * @param stride defines the stride size to use (distance between two positions in the positions array)
  98655. * @return minimum and maximum values
  98656. */
  98657. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  98658. if (bias === void 0) { bias = null; }
  98659. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98660. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98661. if (!stride) {
  98662. stride = 3;
  98663. }
  98664. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  98665. var x = positions[offset];
  98666. var y = positions[offset + 1];
  98667. var z = positions[offset + 2];
  98668. minimum.minimizeInPlaceFromFloats(x, y, z);
  98669. maximum.maximizeInPlaceFromFloats(x, y, z);
  98670. }
  98671. if (bias) {
  98672. minimum.x -= minimum.x * bias.x + bias.y;
  98673. minimum.y -= minimum.y * bias.x + bias.y;
  98674. minimum.z -= minimum.z * bias.x + bias.y;
  98675. maximum.x += maximum.x * bias.x + bias.y;
  98676. maximum.y += maximum.y * bias.x + bias.y;
  98677. maximum.z += maximum.z * bias.x + bias.y;
  98678. }
  98679. return {
  98680. minimum: minimum,
  98681. maximum: maximum
  98682. };
  98683. };
  98684. /**
  98685. * Returns an array if obj is not an array
  98686. * @param obj defines the object to evaluate as an array
  98687. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98688. * @returns either obj directly if obj is an array or a new array containing obj
  98689. */
  98690. Tools.MakeArray = function (obj, allowsNullUndefined) {
  98691. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  98692. return null;
  98693. }
  98694. return Array.isArray(obj) ? obj : [obj];
  98695. };
  98696. /**
  98697. * Gets the pointer prefix to use
  98698. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98699. */
  98700. Tools.GetPointerPrefix = function () {
  98701. var eventPrefix = "pointer";
  98702. // Check if pointer events are supported
  98703. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  98704. eventPrefix = "mouse";
  98705. }
  98706. return eventPrefix;
  98707. };
  98708. /**
  98709. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98710. * @param func - the function to be called
  98711. * @param requester - the object that will request the next frame. Falls back to window.
  98712. * @returns frame number
  98713. */
  98714. Tools.QueueNewFrame = function (func, requester) {
  98715. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98716. return setTimeout(func, 16);
  98717. }
  98718. if (!requester) {
  98719. requester = window;
  98720. }
  98721. if (requester.requestAnimationFrame) {
  98722. return requester.requestAnimationFrame(func);
  98723. }
  98724. else if (requester.msRequestAnimationFrame) {
  98725. return requester.msRequestAnimationFrame(func);
  98726. }
  98727. else if (requester.webkitRequestAnimationFrame) {
  98728. return requester.webkitRequestAnimationFrame(func);
  98729. }
  98730. else if (requester.mozRequestAnimationFrame) {
  98731. return requester.mozRequestAnimationFrame(func);
  98732. }
  98733. else if (requester.oRequestAnimationFrame) {
  98734. return requester.oRequestAnimationFrame(func);
  98735. }
  98736. else {
  98737. return window.setTimeout(func, 16);
  98738. }
  98739. };
  98740. /**
  98741. * Ask the browser to promote the current element to fullscreen rendering mode
  98742. * @param element defines the DOM element to promote
  98743. */
  98744. Tools.RequestFullscreen = function (element) {
  98745. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  98746. if (!requestFunction) {
  98747. return;
  98748. }
  98749. requestFunction.call(element);
  98750. };
  98751. /**
  98752. * Asks the browser to exit fullscreen mode
  98753. */
  98754. Tools.ExitFullscreen = function () {
  98755. if (document.exitFullscreen) {
  98756. document.exitFullscreen();
  98757. }
  98758. else if (document.mozCancelFullScreen) {
  98759. document.mozCancelFullScreen();
  98760. }
  98761. else if (document.webkitCancelFullScreen) {
  98762. document.webkitCancelFullScreen();
  98763. }
  98764. else if (document.msCancelFullScreen) {
  98765. document.msCancelFullScreen();
  98766. }
  98767. };
  98768. /**
  98769. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98770. * @param url define the url we are trying
  98771. * @param element define the dom element where to configure the cors policy
  98772. */
  98773. Tools.SetCorsBehavior = function (url, element) {
  98774. if (url && url.indexOf("data:") === 0) {
  98775. return;
  98776. }
  98777. if (Tools.CorsBehavior) {
  98778. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  98779. element.crossOrigin = Tools.CorsBehavior;
  98780. }
  98781. else {
  98782. var result = Tools.CorsBehavior(url);
  98783. if (result) {
  98784. element.crossOrigin = result;
  98785. }
  98786. }
  98787. }
  98788. };
  98789. // External files
  98790. /**
  98791. * Removes unwanted characters from an url
  98792. * @param url defines the url to clean
  98793. * @returns the cleaned url
  98794. */
  98795. Tools.CleanUrl = function (url) {
  98796. url = url.replace(/#/mg, "%23");
  98797. return url;
  98798. };
  98799. /**
  98800. * Loads an image as an HTMLImageElement.
  98801. * @param input url string, ArrayBuffer, or Blob to load
  98802. * @param onLoad callback called when the image successfully loads
  98803. * @param onError callback called when the image fails to load
  98804. * @param offlineProvider offline provider for caching
  98805. * @returns the HTMLImageElement of the loaded image
  98806. */
  98807. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  98808. var url;
  98809. var usingObjectURL = false;
  98810. if (input instanceof ArrayBuffer) {
  98811. url = URL.createObjectURL(new Blob([input]));
  98812. usingObjectURL = true;
  98813. }
  98814. else if (input instanceof Blob) {
  98815. url = URL.createObjectURL(input);
  98816. usingObjectURL = true;
  98817. }
  98818. else {
  98819. url = Tools.CleanUrl(input);
  98820. url = Tools.PreprocessUrl(input);
  98821. }
  98822. var img = new Image();
  98823. Tools.SetCorsBehavior(url, img);
  98824. var loadHandler = function () {
  98825. if (usingObjectURL && img.src) {
  98826. URL.revokeObjectURL(img.src);
  98827. }
  98828. img.removeEventListener("load", loadHandler);
  98829. img.removeEventListener("error", errorHandler);
  98830. onLoad(img);
  98831. };
  98832. var errorHandler = function (err) {
  98833. if (usingObjectURL && img.src) {
  98834. URL.revokeObjectURL(img.src);
  98835. }
  98836. img.removeEventListener("load", loadHandler);
  98837. img.removeEventListener("error", errorHandler);
  98838. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  98839. if (onError) {
  98840. onError("Error while trying to load image: " + input, err);
  98841. }
  98842. };
  98843. img.addEventListener("load", loadHandler);
  98844. img.addEventListener("error", errorHandler);
  98845. var noOfflineSupport = function () {
  98846. img.src = url;
  98847. };
  98848. var loadFromOfflineSupport = function () {
  98849. if (offlineProvider) {
  98850. offlineProvider.loadImage(url, img);
  98851. }
  98852. };
  98853. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  98854. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  98855. }
  98856. else {
  98857. if (url.indexOf("file:") !== -1) {
  98858. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  98859. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  98860. try {
  98861. var blobURL;
  98862. try {
  98863. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98864. }
  98865. catch (ex) {
  98866. // Chrome doesn't support oneTimeOnly parameter
  98867. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98868. }
  98869. img.src = blobURL;
  98870. usingObjectURL = true;
  98871. }
  98872. catch (e) {
  98873. img.src = "";
  98874. }
  98875. return img;
  98876. }
  98877. }
  98878. noOfflineSupport();
  98879. }
  98880. return img;
  98881. };
  98882. /**
  98883. * Loads a file
  98884. * @param url url string, ArrayBuffer, or Blob to load
  98885. * @param onSuccess callback called when the file successfully loads
  98886. * @param onProgress callback called while file is loading (if the server supports this mode)
  98887. * @param offlineProvider defines the offline provider for caching
  98888. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98889. * @param onError callback called when the file fails to load
  98890. * @returns a file request object
  98891. */
  98892. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  98893. url = Tools.CleanUrl(url);
  98894. url = Tools.PreprocessUrl(url);
  98895. // If file and file input are set
  98896. if (url.indexOf("file:") !== -1) {
  98897. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  98898. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  98899. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  98900. }
  98901. }
  98902. var loadUrl = Tools.BaseUrl + url;
  98903. var aborted = false;
  98904. var fileRequest = {
  98905. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98906. abort: function () { return aborted = true; },
  98907. };
  98908. var requestFile = function () {
  98909. var request = new XMLHttpRequest();
  98910. var retryHandle = null;
  98911. fileRequest.abort = function () {
  98912. aborted = true;
  98913. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  98914. request.abort();
  98915. }
  98916. if (retryHandle !== null) {
  98917. clearTimeout(retryHandle);
  98918. retryHandle = null;
  98919. }
  98920. };
  98921. var retryLoop = function (retryIndex) {
  98922. request.open('GET', loadUrl, true);
  98923. if (useArrayBuffer) {
  98924. request.responseType = "arraybuffer";
  98925. }
  98926. if (onProgress) {
  98927. request.addEventListener("progress", onProgress);
  98928. }
  98929. var onLoadEnd = function () {
  98930. request.removeEventListener("loadend", onLoadEnd);
  98931. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98932. fileRequest.onCompleteObservable.clear();
  98933. };
  98934. request.addEventListener("loadend", onLoadEnd);
  98935. var onReadyStateChange = function () {
  98936. if (aborted) {
  98937. return;
  98938. }
  98939. // In case of undefined state in some browsers.
  98940. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  98941. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  98942. request.removeEventListener("readystatechange", onReadyStateChange);
  98943. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  98944. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  98945. return;
  98946. }
  98947. var retryStrategy = Tools.DefaultRetryStrategy;
  98948. if (retryStrategy) {
  98949. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  98950. if (waitTime !== -1) {
  98951. // Prevent the request from completing for retry.
  98952. request.removeEventListener("loadend", onLoadEnd);
  98953. request = new XMLHttpRequest();
  98954. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  98955. return;
  98956. }
  98957. }
  98958. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  98959. if (onError) {
  98960. onError(request, e);
  98961. }
  98962. else {
  98963. throw e;
  98964. }
  98965. }
  98966. };
  98967. request.addEventListener("readystatechange", onReadyStateChange);
  98968. if (Tools.UseCustomRequestHeaders) {
  98969. Tools.InjectCustomRequestHeaders(request);
  98970. }
  98971. request.send();
  98972. };
  98973. retryLoop(0);
  98974. };
  98975. // Caching all files
  98976. if (offlineProvider && offlineProvider.enableSceneOffline) {
  98977. var noOfflineSupport_1 = function (request) {
  98978. if (request && request.status > 400) {
  98979. if (onError) {
  98980. onError(request);
  98981. }
  98982. }
  98983. else {
  98984. if (!aborted) {
  98985. requestFile();
  98986. }
  98987. }
  98988. };
  98989. var loadFromOfflineSupport = function () {
  98990. // TODO: database needs to support aborting and should return a IFileRequest
  98991. if (aborted) {
  98992. return;
  98993. }
  98994. if (offlineProvider) {
  98995. offlineProvider.loadFile(url, function (data) {
  98996. if (!aborted) {
  98997. onSuccess(data);
  98998. }
  98999. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  99000. }, onProgress ? function (event) {
  99001. if (!aborted) {
  99002. onProgress(event);
  99003. }
  99004. } : undefined, noOfflineSupport_1, useArrayBuffer);
  99005. }
  99006. };
  99007. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  99008. }
  99009. else {
  99010. requestFile();
  99011. }
  99012. return fileRequest;
  99013. };
  99014. /**
  99015. * Load a script (identified by an url). When the url returns, the
  99016. * content of this file is added into a new script element, attached to the DOM (body element)
  99017. * @param scriptUrl defines the url of the script to laod
  99018. * @param onSuccess defines the callback called when the script is loaded
  99019. * @param onError defines the callback to call if an error occurs
  99020. */
  99021. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  99022. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99023. return;
  99024. }
  99025. var head = document.getElementsByTagName('head')[0];
  99026. var script = document.createElement('script');
  99027. script.type = 'text/javascript';
  99028. script.src = scriptUrl;
  99029. script.onload = function () {
  99030. if (onSuccess) {
  99031. onSuccess();
  99032. }
  99033. };
  99034. script.onerror = function (e) {
  99035. if (onError) {
  99036. onError("Unable to load script '" + scriptUrl + "'", e);
  99037. }
  99038. };
  99039. head.appendChild(script);
  99040. };
  99041. /**
  99042. * Loads a file from a blob
  99043. * @param fileToLoad defines the blob to use
  99044. * @param callback defines the callback to call when data is loaded
  99045. * @param progressCallback defines the callback to call during loading process
  99046. * @returns a file request object
  99047. */
  99048. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  99049. var reader = new FileReader();
  99050. var request = {
  99051. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99052. abort: function () { return reader.abort(); },
  99053. };
  99054. reader.onloadend = function (e) {
  99055. request.onCompleteObservable.notifyObservers(request);
  99056. };
  99057. reader.onload = function (e) {
  99058. //target doesn't have result from ts 1.3
  99059. callback(e.target['result']);
  99060. };
  99061. reader.onprogress = progressCallback;
  99062. reader.readAsDataURL(fileToLoad);
  99063. return request;
  99064. };
  99065. /**
  99066. * Loads a file
  99067. * @param fileToLoad defines the file to load
  99068. * @param callback defines the callback to call when data is loaded
  99069. * @param progressCallBack defines the callback to call during loading process
  99070. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99071. * @returns a file request object
  99072. */
  99073. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  99074. var reader = new FileReader();
  99075. var request = {
  99076. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99077. abort: function () { return reader.abort(); },
  99078. };
  99079. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  99080. reader.onerror = function (e) {
  99081. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  99082. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  99083. };
  99084. reader.onload = function (e) {
  99085. //target doesn't have result from ts 1.3
  99086. callback(e.target['result']);
  99087. };
  99088. if (progressCallBack) {
  99089. reader.onprogress = progressCallBack;
  99090. }
  99091. if (!useArrayBuffer) {
  99092. // Asynchronous read
  99093. reader.readAsText(fileToLoad);
  99094. }
  99095. else {
  99096. reader.readAsArrayBuffer(fileToLoad);
  99097. }
  99098. return request;
  99099. };
  99100. /**
  99101. * Creates a data url from a given string content
  99102. * @param content defines the content to convert
  99103. * @returns the new data url link
  99104. */
  99105. Tools.FileAsURL = function (content) {
  99106. var fileBlob = new Blob([content]);
  99107. var url = window.URL || window.webkitURL;
  99108. var link = url.createObjectURL(fileBlob);
  99109. return link;
  99110. };
  99111. /**
  99112. * Format the given number to a specific decimal format
  99113. * @param value defines the number to format
  99114. * @param decimals defines the number of decimals to use
  99115. * @returns the formatted string
  99116. */
  99117. Tools.Format = function (value, decimals) {
  99118. if (decimals === void 0) { decimals = 2; }
  99119. return value.toFixed(decimals);
  99120. };
  99121. /**
  99122. * Checks if a given vector is inside a specific range
  99123. * @param v defines the vector to test
  99124. * @param min defines the minimum range
  99125. * @param max defines the maximum range
  99126. */
  99127. Tools.CheckExtends = function (v, min, max) {
  99128. min.minimizeInPlace(v);
  99129. max.maximizeInPlace(v);
  99130. };
  99131. /**
  99132. * Tries to copy an object by duplicating every property
  99133. * @param source defines the source object
  99134. * @param destination defines the target object
  99135. * @param doNotCopyList defines a list of properties to avoid
  99136. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99137. */
  99138. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  99139. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  99140. };
  99141. /**
  99142. * Gets a boolean indicating if the given object has no own property
  99143. * @param obj defines the object to test
  99144. * @returns true if object has no own property
  99145. */
  99146. Tools.IsEmpty = function (obj) {
  99147. for (var i in obj) {
  99148. if (obj.hasOwnProperty(i)) {
  99149. return false;
  99150. }
  99151. }
  99152. return true;
  99153. };
  99154. /**
  99155. * Function used to register events at window level
  99156. * @param events defines the events to register
  99157. */
  99158. Tools.RegisterTopRootEvents = function (events) {
  99159. for (var index = 0; index < events.length; index++) {
  99160. var event = events[index];
  99161. window.addEventListener(event.name, event.handler, false);
  99162. try {
  99163. if (window.parent) {
  99164. window.parent.addEventListener(event.name, event.handler, false);
  99165. }
  99166. }
  99167. catch (e) {
  99168. // Silently fails...
  99169. }
  99170. }
  99171. };
  99172. /**
  99173. * Function used to unregister events from window level
  99174. * @param events defines the events to unregister
  99175. */
  99176. Tools.UnregisterTopRootEvents = function (events) {
  99177. for (var index = 0; index < events.length; index++) {
  99178. var event = events[index];
  99179. window.removeEventListener(event.name, event.handler);
  99180. try {
  99181. if (window.parent) {
  99182. window.parent.removeEventListener(event.name, event.handler);
  99183. }
  99184. }
  99185. catch (e) {
  99186. // Silently fails...
  99187. }
  99188. }
  99189. };
  99190. /**
  99191. * Dumps the current bound framebuffer
  99192. * @param width defines the rendering width
  99193. * @param height defines the rendering height
  99194. * @param engine defines the hosting engine
  99195. * @param successCallback defines the callback triggered once the data are available
  99196. * @param mimeType defines the mime type of the result
  99197. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99198. */
  99199. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  99200. if (mimeType === void 0) { mimeType = "image/png"; }
  99201. // Read the contents of the framebuffer
  99202. var numberOfChannelsByLine = width * 4;
  99203. var halfHeight = height / 2;
  99204. //Reading datas from WebGL
  99205. var data = engine.readPixels(0, 0, width, height);
  99206. //To flip image on Y axis.
  99207. for (var i = 0; i < halfHeight; i++) {
  99208. for (var j = 0; j < numberOfChannelsByLine; j++) {
  99209. var currentCell = j + i * numberOfChannelsByLine;
  99210. var targetLine = height - i - 1;
  99211. var targetCell = j + targetLine * numberOfChannelsByLine;
  99212. var temp = data[currentCell];
  99213. data[currentCell] = data[targetCell];
  99214. data[targetCell] = temp;
  99215. }
  99216. }
  99217. // Create a 2D canvas to store the result
  99218. if (!screenshotCanvas) {
  99219. screenshotCanvas = document.createElement('canvas');
  99220. }
  99221. screenshotCanvas.width = width;
  99222. screenshotCanvas.height = height;
  99223. var context = screenshotCanvas.getContext('2d');
  99224. if (context) {
  99225. // Copy the pixels to a 2D canvas
  99226. var imageData = context.createImageData(width, height);
  99227. var castData = (imageData.data);
  99228. castData.set(data);
  99229. context.putImageData(imageData, 0, 0);
  99230. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  99231. }
  99232. };
  99233. /**
  99234. * Converts the canvas data to blob.
  99235. * This acts as a polyfill for browsers not supporting the to blob function.
  99236. * @param canvas Defines the canvas to extract the data from
  99237. * @param successCallback Defines the callback triggered once the data are available
  99238. * @param mimeType Defines the mime type of the result
  99239. */
  99240. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  99241. if (mimeType === void 0) { mimeType = "image/png"; }
  99242. // We need HTMLCanvasElement.toBlob for HD screenshots
  99243. if (!canvas.toBlob) {
  99244. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  99245. canvas.toBlob = function (callback, type, quality) {
  99246. var _this = this;
  99247. setTimeout(function () {
  99248. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  99249. for (var i = 0; i < len; i++) {
  99250. arr[i] = binStr.charCodeAt(i);
  99251. }
  99252. callback(new Blob([arr]));
  99253. });
  99254. };
  99255. }
  99256. canvas.toBlob(function (blob) {
  99257. successCallback(blob);
  99258. }, mimeType);
  99259. };
  99260. /**
  99261. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99262. * @param successCallback defines the callback triggered once the data are available
  99263. * @param mimeType defines the mime type of the result
  99264. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99265. */
  99266. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  99267. if (mimeType === void 0) { mimeType = "image/png"; }
  99268. if (successCallback) {
  99269. var base64Image = screenshotCanvas.toDataURL(mimeType);
  99270. successCallback(base64Image);
  99271. }
  99272. else {
  99273. this.ToBlob(screenshotCanvas, function (blob) {
  99274. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  99275. if (("download" in document.createElement("a"))) {
  99276. if (!fileName) {
  99277. var date = new Date();
  99278. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  99279. fileName = "screenshot_" + stringDate + ".png";
  99280. }
  99281. Tools.Download(blob, fileName);
  99282. }
  99283. else {
  99284. var url = URL.createObjectURL(blob);
  99285. var newWindow = window.open("");
  99286. if (!newWindow) {
  99287. return;
  99288. }
  99289. var img = newWindow.document.createElement("img");
  99290. img.onload = function () {
  99291. // no longer need to read the blob so it's revoked
  99292. URL.revokeObjectURL(url);
  99293. };
  99294. img.src = url;
  99295. newWindow.document.body.appendChild(img);
  99296. }
  99297. }, mimeType);
  99298. }
  99299. };
  99300. /**
  99301. * Downloads a blob in the browser
  99302. * @param blob defines the blob to download
  99303. * @param fileName defines the name of the downloaded file
  99304. */
  99305. Tools.Download = function (blob, fileName) {
  99306. if (navigator && navigator.msSaveBlob) {
  99307. navigator.msSaveBlob(blob, fileName);
  99308. return;
  99309. }
  99310. var url = window.URL.createObjectURL(blob);
  99311. var a = document.createElement("a");
  99312. document.body.appendChild(a);
  99313. a.style.display = "none";
  99314. a.href = url;
  99315. a.download = fileName;
  99316. a.addEventListener("click", function () {
  99317. if (a.parentElement) {
  99318. a.parentElement.removeChild(a);
  99319. }
  99320. });
  99321. a.click();
  99322. window.URL.revokeObjectURL(url);
  99323. };
  99324. /**
  99325. * Captures a screenshot of the current rendering
  99326. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99327. * @param engine defines the rendering engine
  99328. * @param camera defines the source camera
  99329. * @param size This parameter can be set to a single number or to an object with the
  99330. * following (optional) properties: precision, width, height. If a single number is passed,
  99331. * it will be used for both width and height. If an object is passed, the screenshot size
  99332. * will be derived from the parameters. The precision property is a multiplier allowing
  99333. * rendering at a higher or lower resolution
  99334. * @param successCallback defines the callback receives a single parameter which contains the
  99335. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99336. * src parameter of an <img> to display it
  99337. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99338. * Check your browser for supported MIME types
  99339. */
  99340. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  99341. if (mimeType === void 0) { mimeType = "image/png"; }
  99342. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99343. };
  99344. /**
  99345. * Generates an image screenshot from the specified camera.
  99346. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99347. * @param engine The engine to use for rendering
  99348. * @param camera The camera to use for rendering
  99349. * @param size This parameter can be set to a single number or to an object with the
  99350. * following (optional) properties: precision, width, height. If a single number is passed,
  99351. * it will be used for both width and height. If an object is passed, the screenshot size
  99352. * will be derived from the parameters. The precision property is a multiplier allowing
  99353. * rendering at a higher or lower resolution
  99354. * @param successCallback The callback receives a single parameter which contains the
  99355. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99356. * src parameter of an <img> to display it
  99357. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99358. * Check your browser for supported MIME types
  99359. * @param samples Texture samples (default: 1)
  99360. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99361. * @param fileName A name for for the downloaded file.
  99362. */
  99363. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  99364. if (mimeType === void 0) { mimeType = "image/png"; }
  99365. if (samples === void 0) { samples = 1; }
  99366. if (antialiasing === void 0) { antialiasing = false; }
  99367. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99368. };
  99369. /**
  99370. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99371. * Be aware Math.random() could cause collisions, but:
  99372. * "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"
  99373. * @returns a pseudo random id
  99374. */
  99375. Tools.RandomId = function () {
  99376. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  99377. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  99378. return v.toString(16);
  99379. });
  99380. };
  99381. /**
  99382. * Test if the given uri is a base64 string
  99383. * @param uri The uri to test
  99384. * @return True if the uri is a base64 string or false otherwise
  99385. */
  99386. Tools.IsBase64 = function (uri) {
  99387. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  99388. };
  99389. /**
  99390. * Decode the given base64 uri.
  99391. * @param uri The uri to decode
  99392. * @return The decoded base64 data.
  99393. */
  99394. Tools.DecodeBase64 = function (uri) {
  99395. var decodedString = atob(uri.split(",")[1]);
  99396. var bufferLength = decodedString.length;
  99397. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  99398. for (var i = 0; i < bufferLength; i++) {
  99399. bufferView[i] = decodedString.charCodeAt(i);
  99400. }
  99401. return bufferView.buffer;
  99402. };
  99403. Object.defineProperty(Tools, "errorsCount", {
  99404. /**
  99405. * Gets a value indicating the number of loading errors
  99406. * @ignorenaming
  99407. */
  99408. get: function () {
  99409. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  99410. },
  99411. enumerable: true,
  99412. configurable: true
  99413. });
  99414. /**
  99415. * Log a message to the console
  99416. * @param message defines the message to log
  99417. */
  99418. Tools.Log = function (message) {
  99419. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  99420. };
  99421. /**
  99422. * Write a warning message to the console
  99423. * @param message defines the message to log
  99424. */
  99425. Tools.Warn = function (message) {
  99426. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  99427. };
  99428. /**
  99429. * Write an error message to the console
  99430. * @param message defines the message to log
  99431. */
  99432. Tools.Error = function (message) {
  99433. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  99434. };
  99435. Object.defineProperty(Tools, "LogCache", {
  99436. /**
  99437. * Gets current log cache (list of logs)
  99438. */
  99439. get: function () {
  99440. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  99441. },
  99442. enumerable: true,
  99443. configurable: true
  99444. });
  99445. /**
  99446. * Clears the log cache
  99447. */
  99448. Tools.ClearLogCache = function () {
  99449. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  99450. };
  99451. Object.defineProperty(Tools, "LogLevels", {
  99452. /**
  99453. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99454. */
  99455. set: function (level) {
  99456. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  99457. },
  99458. enumerable: true,
  99459. configurable: true
  99460. });
  99461. /**
  99462. * Checks if the loaded document was accessed via `file:`-Protocol.
  99463. * @returns boolean
  99464. */
  99465. Tools.IsFileURL = function () {
  99466. return location.protocol === "file:";
  99467. };
  99468. Object.defineProperty(Tools, "PerformanceLogLevel", {
  99469. /**
  99470. * Sets the current performance log level
  99471. */
  99472. set: function (level) {
  99473. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  99474. Tools.StartPerformanceCounter = Tools._StartUserMark;
  99475. Tools.EndPerformanceCounter = Tools._EndUserMark;
  99476. return;
  99477. }
  99478. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  99479. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  99480. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  99481. return;
  99482. }
  99483. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99484. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99485. },
  99486. enumerable: true,
  99487. configurable: true
  99488. });
  99489. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  99490. };
  99491. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  99492. };
  99493. Tools._StartUserMark = function (counterName, condition) {
  99494. if (condition === void 0) { condition = true; }
  99495. if (!Tools._performance) {
  99496. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99497. return;
  99498. }
  99499. Tools._performance = window.performance;
  99500. }
  99501. if (!condition || !Tools._performance.mark) {
  99502. return;
  99503. }
  99504. Tools._performance.mark(counterName + "-Begin");
  99505. };
  99506. Tools._EndUserMark = function (counterName, condition) {
  99507. if (condition === void 0) { condition = true; }
  99508. if (!condition || !Tools._performance.mark) {
  99509. return;
  99510. }
  99511. Tools._performance.mark(counterName + "-End");
  99512. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  99513. };
  99514. Tools._StartPerformanceConsole = function (counterName, condition) {
  99515. if (condition === void 0) { condition = true; }
  99516. if (!condition) {
  99517. return;
  99518. }
  99519. Tools._StartUserMark(counterName, condition);
  99520. if (console.time) {
  99521. console.time(counterName);
  99522. }
  99523. };
  99524. Tools._EndPerformanceConsole = function (counterName, condition) {
  99525. if (condition === void 0) { condition = true; }
  99526. if (!condition) {
  99527. return;
  99528. }
  99529. Tools._EndUserMark(counterName, condition);
  99530. if (console.time) {
  99531. console.timeEnd(counterName);
  99532. }
  99533. };
  99534. /**
  99535. * Injects the @see CustomRequestHeaders into the given request
  99536. * @param request the request that should be used for injection
  99537. */
  99538. Tools.InjectCustomRequestHeaders = function (request) {
  99539. for (var key in Tools.CustomRequestHeaders) {
  99540. var val = Tools.CustomRequestHeaders[key];
  99541. if (val) {
  99542. request.setRequestHeader(key, val);
  99543. }
  99544. }
  99545. };
  99546. Object.defineProperty(Tools, "Now", {
  99547. /**
  99548. * Gets either window.performance.now() if supported or Date.now() else
  99549. */
  99550. get: function () {
  99551. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99552. },
  99553. enumerable: true,
  99554. configurable: true
  99555. });
  99556. /**
  99557. * This method will return the name of the class used to create the instance of the given object.
  99558. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99559. * @param object the object to get the class name from
  99560. * @param isType defines if the object is actually a type
  99561. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99562. */
  99563. Tools.GetClassName = function (object, isType) {
  99564. if (isType === void 0) { isType = false; }
  99565. var name = null;
  99566. if (!isType && object.getClassName) {
  99567. name = object.getClassName();
  99568. }
  99569. else {
  99570. if (object instanceof Object) {
  99571. var classObj = isType ? object : Object.getPrototypeOf(object);
  99572. name = classObj.constructor["__bjsclassName__"];
  99573. }
  99574. if (!name) {
  99575. name = typeof object;
  99576. }
  99577. }
  99578. return name;
  99579. };
  99580. /**
  99581. * Gets the first element of an array satisfying a given predicate
  99582. * @param array defines the array to browse
  99583. * @param predicate defines the predicate to use
  99584. * @returns null if not found or the element
  99585. */
  99586. Tools.First = function (array, predicate) {
  99587. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  99588. var el = array_1[_i];
  99589. if (predicate(el)) {
  99590. return el;
  99591. }
  99592. }
  99593. return null;
  99594. };
  99595. /**
  99596. * This method will return the name of the full name of the class, including its owning module (if any).
  99597. * 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).
  99598. * @param object the object to get the class name from
  99599. * @param isType defines if the object is actually a type
  99600. * @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.
  99601. * @ignorenaming
  99602. */
  99603. Tools.getFullClassName = function (object, isType) {
  99604. if (isType === void 0) { isType = false; }
  99605. var className = null;
  99606. var moduleName = null;
  99607. if (!isType && object.getClassName) {
  99608. className = object.getClassName();
  99609. }
  99610. else {
  99611. if (object instanceof Object) {
  99612. var classObj = isType ? object : Object.getPrototypeOf(object);
  99613. className = classObj.constructor["__bjsclassName__"];
  99614. moduleName = classObj.constructor["__bjsmoduleName__"];
  99615. }
  99616. if (!className) {
  99617. className = typeof object;
  99618. }
  99619. }
  99620. if (!className) {
  99621. return null;
  99622. }
  99623. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  99624. };
  99625. /**
  99626. * Returns a promise that resolves after the given amount of time.
  99627. * @param delay Number of milliseconds to delay
  99628. * @returns Promise that resolves after the given amount of time
  99629. */
  99630. Tools.DelayAsync = function (delay) {
  99631. return new Promise(function (resolve) {
  99632. setTimeout(function () {
  99633. resolve();
  99634. }, delay);
  99635. });
  99636. };
  99637. /**
  99638. * Gets the current gradient from an array of IValueGradient
  99639. * @param ratio defines the current ratio to get
  99640. * @param gradients defines the array of IValueGradient
  99641. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  99642. */
  99643. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  99644. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  99645. var currentGradient = gradients[gradientIndex];
  99646. var nextGradient = gradients[gradientIndex + 1];
  99647. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  99648. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  99649. updateFunc(currentGradient, nextGradient, scale);
  99650. return;
  99651. }
  99652. }
  99653. // Use last index if over
  99654. var lastIndex = gradients.length - 1;
  99655. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  99656. };
  99657. /**
  99658. * Gets or sets the base URL to use to load assets
  99659. */
  99660. Tools.BaseUrl = "";
  99661. /**
  99662. * Enable/Disable Custom HTTP Request Headers globally.
  99663. * default = false
  99664. * @see CustomRequestHeaders
  99665. */
  99666. Tools.UseCustomRequestHeaders = false;
  99667. /**
  99668. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99669. * i.e. when loading files, where the server/service expects an Authorization header.
  99670. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  99671. */
  99672. Tools.CustomRequestHeaders = {};
  99673. /**
  99674. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99675. */
  99676. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  99677. /**
  99678. * Default behaviour for cors in the application.
  99679. * It can be a string if the expected behavior is identical in the entire app.
  99680. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99681. */
  99682. Tools.CorsBehavior = "anonymous";
  99683. /**
  99684. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99685. * @ignorenaming
  99686. */
  99687. Tools.UseFallbackTexture = true;
  99688. /**
  99689. * Use this object to register external classes like custom textures or material
  99690. * to allow the laoders to instantiate them
  99691. */
  99692. Tools.RegisteredExternalClasses = {};
  99693. /**
  99694. * Texture content used if a texture cannot loaded
  99695. * @ignorenaming
  99696. */
  99697. 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";
  99698. Tools._tmpFloatArray = new Float32Array(1);
  99699. /**
  99700. * Extracts text content from a DOM element hierarchy
  99701. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99702. */
  99703. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  99704. /**
  99705. * Gets or sets a function used to pre-process url before using them to load assets
  99706. */
  99707. Tools.PreprocessUrl = function (url) {
  99708. return url;
  99709. };
  99710. // Logs
  99711. /**
  99712. * No log
  99713. */
  99714. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  99715. /**
  99716. * Only message logs
  99717. */
  99718. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  99719. /**
  99720. * Only warning logs
  99721. */
  99722. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  99723. /**
  99724. * Only error logs
  99725. */
  99726. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  99727. /**
  99728. * All logs
  99729. */
  99730. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  99731. /**
  99732. * Checks if the window object exists
  99733. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99734. */
  99735. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  99736. // Performances
  99737. /**
  99738. * No performance log
  99739. */
  99740. Tools.PerformanceNoneLogLevel = 0;
  99741. /**
  99742. * Use user marks to log performance
  99743. */
  99744. Tools.PerformanceUserMarkLogLevel = 1;
  99745. /**
  99746. * Log performance to the console
  99747. */
  99748. Tools.PerformanceConsoleLogLevel = 2;
  99749. /**
  99750. * Starts a performance counter
  99751. */
  99752. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99753. /**
  99754. * Ends a specific performance coutner
  99755. */
  99756. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99757. return Tools;
  99758. }());
  99759. /**
  99760. * This class is used to track a performance counter which is number based.
  99761. * The user has access to many properties which give statistics of different nature.
  99762. *
  99763. * The implementer can track two kinds of Performance Counter: time and count.
  99764. * 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.
  99765. * 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.
  99766. */
  99767. var PerfCounter = /** @class */ (function () {
  99768. /**
  99769. * Creates a new counter
  99770. */
  99771. function PerfCounter() {
  99772. this._startMonitoringTime = 0;
  99773. this._min = 0;
  99774. this._max = 0;
  99775. this._average = 0;
  99776. this._lastSecAverage = 0;
  99777. this._current = 0;
  99778. this._totalValueCount = 0;
  99779. this._totalAccumulated = 0;
  99780. this._lastSecAccumulated = 0;
  99781. this._lastSecTime = 0;
  99782. this._lastSecValueCount = 0;
  99783. }
  99784. Object.defineProperty(PerfCounter.prototype, "min", {
  99785. /**
  99786. * Returns the smallest value ever
  99787. */
  99788. get: function () {
  99789. return this._min;
  99790. },
  99791. enumerable: true,
  99792. configurable: true
  99793. });
  99794. Object.defineProperty(PerfCounter.prototype, "max", {
  99795. /**
  99796. * Returns the biggest value ever
  99797. */
  99798. get: function () {
  99799. return this._max;
  99800. },
  99801. enumerable: true,
  99802. configurable: true
  99803. });
  99804. Object.defineProperty(PerfCounter.prototype, "average", {
  99805. /**
  99806. * Returns the average value since the performance counter is running
  99807. */
  99808. get: function () {
  99809. return this._average;
  99810. },
  99811. enumerable: true,
  99812. configurable: true
  99813. });
  99814. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  99815. /**
  99816. * Returns the average value of the last second the counter was monitored
  99817. */
  99818. get: function () {
  99819. return this._lastSecAverage;
  99820. },
  99821. enumerable: true,
  99822. configurable: true
  99823. });
  99824. Object.defineProperty(PerfCounter.prototype, "current", {
  99825. /**
  99826. * Returns the current value
  99827. */
  99828. get: function () {
  99829. return this._current;
  99830. },
  99831. enumerable: true,
  99832. configurable: true
  99833. });
  99834. Object.defineProperty(PerfCounter.prototype, "total", {
  99835. /**
  99836. * Gets the accumulated total
  99837. */
  99838. get: function () {
  99839. return this._totalAccumulated;
  99840. },
  99841. enumerable: true,
  99842. configurable: true
  99843. });
  99844. Object.defineProperty(PerfCounter.prototype, "count", {
  99845. /**
  99846. * Gets the total value count
  99847. */
  99848. get: function () {
  99849. return this._totalValueCount;
  99850. },
  99851. enumerable: true,
  99852. configurable: true
  99853. });
  99854. /**
  99855. * Call this method to start monitoring a new frame.
  99856. * 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.
  99857. */
  99858. PerfCounter.prototype.fetchNewFrame = function () {
  99859. this._totalValueCount++;
  99860. this._current = 0;
  99861. this._lastSecValueCount++;
  99862. };
  99863. /**
  99864. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99865. * @param newCount the count value to add to the monitored count
  99866. * @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.
  99867. */
  99868. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  99869. if (!PerfCounter.Enabled) {
  99870. return;
  99871. }
  99872. this._current += newCount;
  99873. if (fetchResult) {
  99874. this._fetchResult();
  99875. }
  99876. };
  99877. /**
  99878. * Start monitoring this performance counter
  99879. */
  99880. PerfCounter.prototype.beginMonitoring = function () {
  99881. if (!PerfCounter.Enabled) {
  99882. return;
  99883. }
  99884. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99885. };
  99886. /**
  99887. * Compute the time lapsed since the previous beginMonitoring() call.
  99888. * @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
  99889. */
  99890. PerfCounter.prototype.endMonitoring = function (newFrame) {
  99891. if (newFrame === void 0) { newFrame = true; }
  99892. if (!PerfCounter.Enabled) {
  99893. return;
  99894. }
  99895. if (newFrame) {
  99896. this.fetchNewFrame();
  99897. }
  99898. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99899. this._current = currentTime - this._startMonitoringTime;
  99900. if (newFrame) {
  99901. this._fetchResult();
  99902. }
  99903. };
  99904. PerfCounter.prototype._fetchResult = function () {
  99905. this._totalAccumulated += this._current;
  99906. this._lastSecAccumulated += this._current;
  99907. // Min/Max update
  99908. this._min = Math.min(this._min, this._current);
  99909. this._max = Math.max(this._max, this._current);
  99910. this._average = this._totalAccumulated / this._totalValueCount;
  99911. // Reset last sec?
  99912. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99913. if ((now - this._lastSecTime) > 1000) {
  99914. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  99915. this._lastSecTime = now;
  99916. this._lastSecAccumulated = 0;
  99917. this._lastSecValueCount = 0;
  99918. }
  99919. };
  99920. /**
  99921. * Gets or sets a global boolean to turn on and off all the counters
  99922. */
  99923. PerfCounter.Enabled = true;
  99924. return PerfCounter;
  99925. }());
  99926. /**
  99927. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99928. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99929. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99930. * @param name The name of the class, case should be preserved
  99931. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99932. */
  99933. function className(name, module) {
  99934. return function (target) {
  99935. target["__bjsclassName__"] = name;
  99936. target["__bjsmoduleName__"] = (module != null) ? module : null;
  99937. };
  99938. }
  99939. /**
  99940. * An implementation of a loop for asynchronous functions.
  99941. */
  99942. var AsyncLoop = /** @class */ (function () {
  99943. /**
  99944. * Constructor.
  99945. * @param iterations the number of iterations.
  99946. * @param func the function to run each iteration
  99947. * @param successCallback the callback that will be called upon succesful execution
  99948. * @param offset starting offset.
  99949. */
  99950. function AsyncLoop(
  99951. /**
  99952. * Defines the number of iterations for the loop
  99953. */
  99954. iterations, func, successCallback, offset) {
  99955. if (offset === void 0) { offset = 0; }
  99956. this.iterations = iterations;
  99957. this.index = offset - 1;
  99958. this._done = false;
  99959. this._fn = func;
  99960. this._successCallback = successCallback;
  99961. }
  99962. /**
  99963. * Execute the next iteration. Must be called after the last iteration was finished.
  99964. */
  99965. AsyncLoop.prototype.executeNext = function () {
  99966. if (!this._done) {
  99967. if (this.index + 1 < this.iterations) {
  99968. ++this.index;
  99969. this._fn(this);
  99970. }
  99971. else {
  99972. this.breakLoop();
  99973. }
  99974. }
  99975. };
  99976. /**
  99977. * Break the loop and run the success callback.
  99978. */
  99979. AsyncLoop.prototype.breakLoop = function () {
  99980. this._done = true;
  99981. this._successCallback();
  99982. };
  99983. /**
  99984. * Create and run an async loop.
  99985. * @param iterations the number of iterations.
  99986. * @param fn the function to run each iteration
  99987. * @param successCallback the callback that will be called upon succesful execution
  99988. * @param offset starting offset.
  99989. * @returns the created async loop object
  99990. */
  99991. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  99992. if (offset === void 0) { offset = 0; }
  99993. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  99994. loop.executeNext();
  99995. return loop;
  99996. };
  99997. /**
  99998. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99999. * @param iterations total number of iterations
  100000. * @param syncedIterations number of synchronous iterations in each async iteration.
  100001. * @param fn the function to call each iteration.
  100002. * @param callback a success call back that will be called when iterating stops.
  100003. * @param breakFunction a break condition (optional)
  100004. * @param timeout timeout settings for the setTimeout function. default - 0.
  100005. * @returns the created async loop object
  100006. */
  100007. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  100008. if (timeout === void 0) { timeout = 0; }
  100009. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  100010. if (breakFunction && breakFunction()) {
  100011. loop.breakLoop();
  100012. }
  100013. else {
  100014. setTimeout(function () {
  100015. for (var i = 0; i < syncedIterations; ++i) {
  100016. var iteration = (loop.index * syncedIterations) + i;
  100017. if (iteration >= iterations) {
  100018. break;
  100019. }
  100020. fn(iteration);
  100021. if (breakFunction && breakFunction()) {
  100022. loop.breakLoop();
  100023. break;
  100024. }
  100025. }
  100026. loop.executeNext();
  100027. }, timeout);
  100028. }
  100029. }, callback);
  100030. };
  100031. return AsyncLoop;
  100032. }());
  100033. /***/ }),
  100034. /***/ "./Misc/typeStore.ts":
  100035. /*!***************************!*\
  100036. !*** ./Misc/typeStore.ts ***!
  100037. \***************************/
  100038. /*! exports provided: _TypeStore */
  100039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100040. "use strict";
  100041. __webpack_require__.r(__webpack_exports__);
  100042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  100043. /** @hidden */
  100044. var _TypeStore = /** @class */ (function () {
  100045. function _TypeStore() {
  100046. }
  100047. /** @hidden */
  100048. _TypeStore.GetClass = function (fqdn) {
  100049. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  100050. return this.RegisteredTypes[fqdn];
  100051. }
  100052. return null;
  100053. };
  100054. /** @hidden */
  100055. _TypeStore.RegisteredTypes = {};
  100056. return _TypeStore;
  100057. }());
  100058. /***/ }),
  100059. /***/ "./Misc/videoRecorder.ts":
  100060. /*!*******************************!*\
  100061. !*** ./Misc/videoRecorder.ts ***!
  100062. \*******************************/
  100063. /*! exports provided: VideoRecorder */
  100064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100065. "use strict";
  100066. __webpack_require__.r(__webpack_exports__);
  100067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  100068. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100069. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100070. /**
  100071. * This can helps recording videos from BabylonJS.
  100072. * This is based on the available WebRTC functionalities of the browser.
  100073. *
  100074. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  100075. */
  100076. var VideoRecorder = /** @class */ (function () {
  100077. /**
  100078. * Create a new VideoCapture object which can help converting what you see in Babylon to
  100079. * a video file.
  100080. * @param engine Defines the BabylonJS Engine you wish to record
  100081. * @param options Defines options that can be used to customized the capture
  100082. */
  100083. function VideoRecorder(engine, options) {
  100084. if (options === void 0) { options = null; }
  100085. if (!VideoRecorder.IsSupported(engine)) {
  100086. throw "Your browser does not support recording so far.";
  100087. }
  100088. var canvas = engine.getRenderingCanvas();
  100089. if (!canvas) {
  100090. throw "The babylon engine must have a canvas to be recorded";
  100091. }
  100092. this._canvas = canvas;
  100093. this._canvas.isRecording = false;
  100094. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  100095. var stream = this._canvas.captureStream(this._options.fps);
  100096. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  100097. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  100098. this._mediaRecorder.onerror = this._handleError.bind(this);
  100099. this._mediaRecorder.onstop = this._handleStop.bind(this);
  100100. }
  100101. /**
  100102. * Returns wehther or not the VideoRecorder is available in your browser.
  100103. * @param engine Defines the Babylon Engine to check the support for
  100104. * @returns true if supported otherwise false
  100105. */
  100106. VideoRecorder.IsSupported = function (engine) {
  100107. var canvas = engine.getRenderingCanvas();
  100108. return (!!canvas && typeof canvas.captureStream === "function");
  100109. };
  100110. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  100111. /**
  100112. * True wether a recording is already in progress.
  100113. */
  100114. get: function () {
  100115. return !!this._canvas && this._canvas.isRecording;
  100116. },
  100117. enumerable: true,
  100118. configurable: true
  100119. });
  100120. /**
  100121. * Stops the current recording before the default capture timeout passed in the startRecording
  100122. * functions.
  100123. */
  100124. VideoRecorder.prototype.stopRecording = function () {
  100125. if (!this._canvas || !this._mediaRecorder) {
  100126. return;
  100127. }
  100128. if (!this.isRecording) {
  100129. return;
  100130. }
  100131. this._canvas.isRecording = false;
  100132. this._mediaRecorder.stop();
  100133. };
  100134. /**
  100135. * Starts recording the canvas for a max duration specified in parameters.
  100136. * @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.
  100137. * @param maxDuration Defines the maximum recording time in seconds.
  100138. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  100139. * @return a promise callback at the end of the recording with the video data in Blob.
  100140. */
  100141. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  100142. var _this = this;
  100143. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  100144. if (maxDuration === void 0) { maxDuration = 7; }
  100145. if (!this._canvas || !this._mediaRecorder) {
  100146. throw "Recorder has already been disposed";
  100147. }
  100148. if (this.isRecording) {
  100149. throw "Recording already in progress";
  100150. }
  100151. if (maxDuration > 0) {
  100152. setTimeout(function () {
  100153. _this.stopRecording();
  100154. }, maxDuration * 1000);
  100155. }
  100156. this._fileName = fileName;
  100157. this._recordedChunks = [];
  100158. this._resolve = null;
  100159. this._reject = null;
  100160. this._canvas.isRecording = true;
  100161. this._mediaRecorder.start(this._options.recordChunckSize);
  100162. return new Promise(function (resolve, reject) {
  100163. _this._resolve = resolve;
  100164. _this._reject = reject;
  100165. });
  100166. };
  100167. /**
  100168. * Releases internal resources used during the recording.
  100169. */
  100170. VideoRecorder.prototype.dispose = function () {
  100171. this._canvas = null;
  100172. this._mediaRecorder = null;
  100173. this._recordedChunks = [];
  100174. this._fileName = null;
  100175. this._resolve = null;
  100176. this._reject = null;
  100177. };
  100178. VideoRecorder.prototype._handleDataAvailable = function (event) {
  100179. if (event.data.size > 0) {
  100180. this._recordedChunks.push(event.data);
  100181. }
  100182. };
  100183. VideoRecorder.prototype._handleError = function (event) {
  100184. this.stopRecording();
  100185. if (this._reject) {
  100186. this._reject(event.error);
  100187. }
  100188. else {
  100189. throw new event.error();
  100190. }
  100191. };
  100192. VideoRecorder.prototype._handleStop = function () {
  100193. this.stopRecording();
  100194. var superBuffer = new Blob(this._recordedChunks);
  100195. if (this._resolve) {
  100196. this._resolve(superBuffer);
  100197. }
  100198. window.URL.createObjectURL(superBuffer);
  100199. if (this._fileName) {
  100200. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  100201. }
  100202. };
  100203. VideoRecorder._defaultOptions = {
  100204. mimeType: "video/webm",
  100205. fps: 25,
  100206. recordChunckSize: 3000
  100207. };
  100208. return VideoRecorder;
  100209. }());
  100210. /***/ }),
  100211. /***/ "./Misc/virtualJoystick.ts":
  100212. /*!*********************************!*\
  100213. !*** ./Misc/virtualJoystick.ts ***!
  100214. \*********************************/
  100215. /*! exports provided: JoystickAxis, VirtualJoystick */
  100216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100217. "use strict";
  100218. __webpack_require__.r(__webpack_exports__);
  100219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  100220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  100221. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100222. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  100223. // Mainly based on these 2 articles :
  100224. // 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
  100225. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  100226. /**
  100227. * Defines the potential axis of a Joystick
  100228. */
  100229. var JoystickAxis;
  100230. (function (JoystickAxis) {
  100231. /** X axis */
  100232. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  100233. /** Y axis */
  100234. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  100235. /** Z axis */
  100236. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  100237. })(JoystickAxis || (JoystickAxis = {}));
  100238. /**
  100239. * Class used to define virtual joystick (used in touch mode)
  100240. */
  100241. var VirtualJoystick = /** @class */ (function () {
  100242. /**
  100243. * Creates a new virtual joystick
  100244. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100245. */
  100246. function VirtualJoystick(leftJoystick) {
  100247. var _this = this;
  100248. if (leftJoystick) {
  100249. this._leftJoystick = true;
  100250. }
  100251. else {
  100252. this._leftJoystick = false;
  100253. }
  100254. VirtualJoystick._globalJoystickIndex++;
  100255. // By default left & right arrow keys are moving the X
  100256. // and up & down keys are moving the Y
  100257. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100258. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100259. this.reverseLeftRight = false;
  100260. this.reverseUpDown = false;
  100261. // collections of pointers
  100262. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  100263. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  100264. this._joystickSensibility = 25;
  100265. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100266. this._onResize = function (evt) {
  100267. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100268. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100269. if (VirtualJoystick.Canvas) {
  100270. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  100271. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  100272. }
  100273. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  100274. };
  100275. // injecting a canvas element on top of the canvas 3D game
  100276. if (!VirtualJoystick.Canvas) {
  100277. window.addEventListener("resize", this._onResize, false);
  100278. VirtualJoystick.Canvas = document.createElement("canvas");
  100279. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100280. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100281. VirtualJoystick.Canvas.width = window.innerWidth;
  100282. VirtualJoystick.Canvas.height = window.innerHeight;
  100283. VirtualJoystick.Canvas.style.width = "100%";
  100284. VirtualJoystick.Canvas.style.height = "100%";
  100285. VirtualJoystick.Canvas.style.position = "absolute";
  100286. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  100287. VirtualJoystick.Canvas.style.top = "0px";
  100288. VirtualJoystick.Canvas.style.left = "0px";
  100289. VirtualJoystick.Canvas.style.zIndex = "5";
  100290. VirtualJoystick.Canvas.style.msTouchAction = "none";
  100291. // Support for jQuery PEP polyfill
  100292. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  100293. var context = VirtualJoystick.Canvas.getContext('2d');
  100294. if (!context) {
  100295. throw new Error("Unable to create canvas for virtual joystick");
  100296. }
  100297. VirtualJoystick.vjCanvasContext = context;
  100298. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  100299. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100300. document.body.appendChild(VirtualJoystick.Canvas);
  100301. }
  100302. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  100303. this.pressed = false;
  100304. // default joystick color
  100305. this._joystickColor = "cyan";
  100306. this._joystickPointerID = -1;
  100307. // current joystick position
  100308. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100309. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100310. // origin joystick position
  100311. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100312. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100313. this._onPointerDownHandlerRef = function (evt) {
  100314. _this._onPointerDown(evt);
  100315. };
  100316. this._onPointerMoveHandlerRef = function (evt) {
  100317. _this._onPointerMove(evt);
  100318. };
  100319. this._onPointerUpHandlerRef = function (evt) {
  100320. _this._onPointerUp(evt);
  100321. };
  100322. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  100323. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  100324. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  100325. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  100326. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  100327. evt.preventDefault(); // Disables system menu
  100328. }, false);
  100329. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100330. }
  100331. /**
  100332. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100333. * @param newJoystickSensibility defines the new sensibility
  100334. */
  100335. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  100336. this._joystickSensibility = newJoystickSensibility;
  100337. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100338. };
  100339. VirtualJoystick.prototype._onPointerDown = function (e) {
  100340. var positionOnScreenCondition;
  100341. e.preventDefault();
  100342. if (this._leftJoystick === true) {
  100343. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  100344. }
  100345. else {
  100346. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  100347. }
  100348. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  100349. // First contact will be dedicated to the virtual joystick
  100350. this._joystickPointerID = e.pointerId;
  100351. this._joystickPointerStartPos.x = e.clientX;
  100352. this._joystickPointerStartPos.y = e.clientY;
  100353. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  100354. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  100355. this._deltaJoystickVector.x = 0;
  100356. this._deltaJoystickVector.y = 0;
  100357. this.pressed = true;
  100358. this._touches.add(e.pointerId.toString(), e);
  100359. }
  100360. else {
  100361. // You can only trigger the action buttons with a joystick declared
  100362. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  100363. this._action();
  100364. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  100365. }
  100366. }
  100367. };
  100368. VirtualJoystick.prototype._onPointerMove = function (e) {
  100369. // If the current pointer is the one associated to the joystick (first touch contact)
  100370. if (this._joystickPointerID == e.pointerId) {
  100371. this._joystickPointerPos.x = e.clientX;
  100372. this._joystickPointerPos.y = e.clientY;
  100373. this._deltaJoystickVector = this._joystickPointerPos.clone();
  100374. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  100375. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  100376. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  100377. switch (this._axisTargetedByLeftAndRight) {
  100378. case JoystickAxis.X:
  100379. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  100380. break;
  100381. case JoystickAxis.Y:
  100382. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  100383. break;
  100384. case JoystickAxis.Z:
  100385. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  100386. break;
  100387. }
  100388. var directionUpDown = this.reverseUpDown ? 1 : -1;
  100389. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  100390. switch (this._axisTargetedByUpAndDown) {
  100391. case JoystickAxis.X:
  100392. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  100393. break;
  100394. case JoystickAxis.Y:
  100395. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  100396. break;
  100397. case JoystickAxis.Z:
  100398. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  100399. break;
  100400. }
  100401. }
  100402. else {
  100403. var data = this._touches.get(e.pointerId.toString());
  100404. if (data) {
  100405. data.x = e.clientX;
  100406. data.y = e.clientY;
  100407. }
  100408. }
  100409. };
  100410. VirtualJoystick.prototype._onPointerUp = function (e) {
  100411. if (this._joystickPointerID == e.pointerId) {
  100412. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  100413. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  100414. this._joystickPointerID = -1;
  100415. this.pressed = false;
  100416. }
  100417. else {
  100418. var touch = this._touches.get(e.pointerId.toString());
  100419. if (touch) {
  100420. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100421. }
  100422. }
  100423. this._deltaJoystickVector.x = 0;
  100424. this._deltaJoystickVector.y = 0;
  100425. this._touches.remove(e.pointerId.toString());
  100426. };
  100427. /**
  100428. * Change the color of the virtual joystick
  100429. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100430. */
  100431. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  100432. this._joystickColor = newColor;
  100433. };
  100434. /**
  100435. * Defines a callback to call when the joystick is touched
  100436. * @param action defines the callback
  100437. */
  100438. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  100439. this._action = action;
  100440. };
  100441. /**
  100442. * Defines which axis you'd like to control for left & right
  100443. * @param axis defines the axis to use
  100444. */
  100445. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  100446. switch (axis) {
  100447. case JoystickAxis.X:
  100448. case JoystickAxis.Y:
  100449. case JoystickAxis.Z:
  100450. this._axisTargetedByLeftAndRight = axis;
  100451. break;
  100452. default:
  100453. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100454. break;
  100455. }
  100456. };
  100457. /**
  100458. * Defines which axis you'd like to control for up & down
  100459. * @param axis defines the axis to use
  100460. */
  100461. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  100462. switch (axis) {
  100463. case JoystickAxis.X:
  100464. case JoystickAxis.Y:
  100465. case JoystickAxis.Z:
  100466. this._axisTargetedByUpAndDown = axis;
  100467. break;
  100468. default:
  100469. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100470. break;
  100471. }
  100472. };
  100473. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  100474. var _this = this;
  100475. if (this.pressed) {
  100476. this._touches.forEach(function (key, touch) {
  100477. if (touch.pointerId === _this._joystickPointerID) {
  100478. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  100479. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  100480. VirtualJoystick.vjCanvasContext.beginPath();
  100481. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100482. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100483. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  100484. VirtualJoystick.vjCanvasContext.stroke();
  100485. VirtualJoystick.vjCanvasContext.closePath();
  100486. VirtualJoystick.vjCanvasContext.beginPath();
  100487. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100488. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100489. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  100490. VirtualJoystick.vjCanvasContext.stroke();
  100491. VirtualJoystick.vjCanvasContext.closePath();
  100492. VirtualJoystick.vjCanvasContext.beginPath();
  100493. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100494. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  100495. VirtualJoystick.vjCanvasContext.stroke();
  100496. VirtualJoystick.vjCanvasContext.closePath();
  100497. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  100498. }
  100499. else {
  100500. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100501. VirtualJoystick.vjCanvasContext.beginPath();
  100502. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  100503. VirtualJoystick.vjCanvasContext.beginPath();
  100504. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  100505. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100506. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  100507. VirtualJoystick.vjCanvasContext.stroke();
  100508. VirtualJoystick.vjCanvasContext.closePath();
  100509. touch.prevX = touch.x;
  100510. touch.prevY = touch.y;
  100511. }
  100512. });
  100513. }
  100514. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100515. };
  100516. /**
  100517. * Release internal HTML canvas
  100518. */
  100519. VirtualJoystick.prototype.releaseCanvas = function () {
  100520. if (VirtualJoystick.Canvas) {
  100521. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  100522. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  100523. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  100524. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  100525. window.removeEventListener("resize", this._onResize);
  100526. document.body.removeChild(VirtualJoystick.Canvas);
  100527. VirtualJoystick.Canvas = null;
  100528. }
  100529. };
  100530. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  100531. VirtualJoystick._globalJoystickIndex = 0;
  100532. return VirtualJoystick;
  100533. }());
  100534. /***/ }),
  100535. /***/ "./Misc/workerPool.ts":
  100536. /*!****************************!*\
  100537. !*** ./Misc/workerPool.ts ***!
  100538. \****************************/
  100539. /*! exports provided: WorkerPool */
  100540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100541. "use strict";
  100542. __webpack_require__.r(__webpack_exports__);
  100543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  100544. /**
  100545. * Helper class to push actions to a pool of workers.
  100546. */
  100547. var WorkerPool = /** @class */ (function () {
  100548. /**
  100549. * Constructor
  100550. * @param workers Array of workers to use for actions
  100551. */
  100552. function WorkerPool(workers) {
  100553. this._pendingActions = new Array();
  100554. this._workerInfos = workers.map(function (worker) { return ({
  100555. worker: worker,
  100556. active: false
  100557. }); });
  100558. }
  100559. /**
  100560. * Terminates all workers and clears any pending actions.
  100561. */
  100562. WorkerPool.prototype.dispose = function () {
  100563. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100564. var workerInfo = _a[_i];
  100565. workerInfo.worker.terminate();
  100566. }
  100567. delete this._workerInfos;
  100568. delete this._pendingActions;
  100569. };
  100570. /**
  100571. * Pushes an action to the worker pool. If all the workers are active, the action will be
  100572. * pended until a worker has completed its action.
  100573. * @param action The action to perform. Call onComplete when the action is complete.
  100574. */
  100575. WorkerPool.prototype.push = function (action) {
  100576. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100577. var workerInfo = _a[_i];
  100578. if (!workerInfo.active) {
  100579. this._execute(workerInfo, action);
  100580. return;
  100581. }
  100582. }
  100583. this._pendingActions.push(action);
  100584. };
  100585. WorkerPool.prototype._execute = function (workerInfo, action) {
  100586. var _this = this;
  100587. workerInfo.active = true;
  100588. action(workerInfo.worker, function () {
  100589. workerInfo.active = false;
  100590. var nextAction = _this._pendingActions.shift();
  100591. if (nextAction) {
  100592. _this._execute(workerInfo, nextAction);
  100593. }
  100594. });
  100595. };
  100596. return WorkerPool;
  100597. }());
  100598. /***/ }),
  100599. /***/ "./Morph/index.ts":
  100600. /*!************************!*\
  100601. !*** ./Morph/index.ts ***!
  100602. \************************/
  100603. /*! exports provided: MorphTarget, MorphTargetManager */
  100604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100605. "use strict";
  100606. __webpack_require__.r(__webpack_exports__);
  100607. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  100609. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  100610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  100611. /***/ }),
  100612. /***/ "./Morph/morphTarget.ts":
  100613. /*!******************************!*\
  100614. !*** ./Morph/morphTarget.ts ***!
  100615. \******************************/
  100616. /*! exports provided: MorphTarget */
  100617. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100618. "use strict";
  100619. __webpack_require__.r(__webpack_exports__);
  100620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  100621. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100622. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  100623. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100624. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  100625. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  100626. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  100627. /**
  100628. * Defines a target to use with MorphTargetManager
  100629. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100630. */
  100631. var MorphTarget = /** @class */ (function () {
  100632. /**
  100633. * Creates a new MorphTarget
  100634. * @param name defines the name of the target
  100635. * @param influence defines the influence to use
  100636. * @param scene defines the scene the morphtarget belongs to
  100637. */
  100638. function MorphTarget(
  100639. /** defines the name of the target */
  100640. name, influence, scene) {
  100641. if (influence === void 0) { influence = 0; }
  100642. if (scene === void 0) { scene = null; }
  100643. this.name = name;
  100644. /**
  100645. * Gets or sets the list of animations
  100646. */
  100647. this.animations = new Array();
  100648. this._positions = null;
  100649. this._normals = null;
  100650. this._tangents = null;
  100651. /**
  100652. * Observable raised when the influence changes
  100653. */
  100654. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100655. /** @hidden */
  100656. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100657. this._animationPropertiesOverride = null;
  100658. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100659. this.influence = influence;
  100660. }
  100661. Object.defineProperty(MorphTarget.prototype, "influence", {
  100662. /**
  100663. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  100664. */
  100665. get: function () {
  100666. return this._influence;
  100667. },
  100668. set: function (influence) {
  100669. if (this._influence === influence) {
  100670. return;
  100671. }
  100672. var previous = this._influence;
  100673. this._influence = influence;
  100674. if (this.onInfluenceChanged.hasObservers) {
  100675. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  100676. }
  100677. },
  100678. enumerable: true,
  100679. configurable: true
  100680. });
  100681. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  100682. /**
  100683. * Gets or sets the animation properties override
  100684. */
  100685. get: function () {
  100686. if (!this._animationPropertiesOverride && this._scene) {
  100687. return this._scene.animationPropertiesOverride;
  100688. }
  100689. return this._animationPropertiesOverride;
  100690. },
  100691. set: function (value) {
  100692. this._animationPropertiesOverride = value;
  100693. },
  100694. enumerable: true,
  100695. configurable: true
  100696. });
  100697. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  100698. /**
  100699. * Gets a boolean defining if the target contains position data
  100700. */
  100701. get: function () {
  100702. return !!this._positions;
  100703. },
  100704. enumerable: true,
  100705. configurable: true
  100706. });
  100707. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  100708. /**
  100709. * Gets a boolean defining if the target contains normal data
  100710. */
  100711. get: function () {
  100712. return !!this._normals;
  100713. },
  100714. enumerable: true,
  100715. configurable: true
  100716. });
  100717. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  100718. /**
  100719. * Gets a boolean defining if the target contains tangent data
  100720. */
  100721. get: function () {
  100722. return !!this._tangents;
  100723. },
  100724. enumerable: true,
  100725. configurable: true
  100726. });
  100727. /**
  100728. * Affects position data to this target
  100729. * @param data defines the position data to use
  100730. */
  100731. MorphTarget.prototype.setPositions = function (data) {
  100732. var hadPositions = this.hasPositions;
  100733. this._positions = data;
  100734. if (hadPositions !== this.hasPositions) {
  100735. this._onDataLayoutChanged.notifyObservers(undefined);
  100736. }
  100737. };
  100738. /**
  100739. * Gets the position data stored in this target
  100740. * @returns a FloatArray containing the position data (or null if not present)
  100741. */
  100742. MorphTarget.prototype.getPositions = function () {
  100743. return this._positions;
  100744. };
  100745. /**
  100746. * Affects normal data to this target
  100747. * @param data defines the normal data to use
  100748. */
  100749. MorphTarget.prototype.setNormals = function (data) {
  100750. var hadNormals = this.hasNormals;
  100751. this._normals = data;
  100752. if (hadNormals !== this.hasNormals) {
  100753. this._onDataLayoutChanged.notifyObservers(undefined);
  100754. }
  100755. };
  100756. /**
  100757. * Gets the normal data stored in this target
  100758. * @returns a FloatArray containing the normal data (or null if not present)
  100759. */
  100760. MorphTarget.prototype.getNormals = function () {
  100761. return this._normals;
  100762. };
  100763. /**
  100764. * Affects tangent data to this target
  100765. * @param data defines the tangent data to use
  100766. */
  100767. MorphTarget.prototype.setTangents = function (data) {
  100768. var hadTangents = this.hasTangents;
  100769. this._tangents = data;
  100770. if (hadTangents !== this.hasTangents) {
  100771. this._onDataLayoutChanged.notifyObservers(undefined);
  100772. }
  100773. };
  100774. /**
  100775. * Gets the tangent data stored in this target
  100776. * @returns a FloatArray containing the tangent data (or null if not present)
  100777. */
  100778. MorphTarget.prototype.getTangents = function () {
  100779. return this._tangents;
  100780. };
  100781. /**
  100782. * Serializes the current target into a Serialization object
  100783. * @returns the serialized object
  100784. */
  100785. MorphTarget.prototype.serialize = function () {
  100786. var serializationObject = {};
  100787. serializationObject.name = this.name;
  100788. serializationObject.influence = this.influence;
  100789. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  100790. if (this.id != null) {
  100791. serializationObject.id = this.id;
  100792. }
  100793. if (this.hasNormals) {
  100794. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  100795. }
  100796. if (this.hasTangents) {
  100797. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  100798. }
  100799. // Animations
  100800. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  100801. return serializationObject;
  100802. };
  100803. /**
  100804. * Returns the string "MorphTarget"
  100805. * @returns "MorphTarget"
  100806. */
  100807. MorphTarget.prototype.getClassName = function () {
  100808. return "MorphTarget";
  100809. };
  100810. // Statics
  100811. /**
  100812. * Creates a new target from serialized data
  100813. * @param serializationObject defines the serialized data to use
  100814. * @returns a new MorphTarget
  100815. */
  100816. MorphTarget.Parse = function (serializationObject) {
  100817. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  100818. result.setPositions(serializationObject.positions);
  100819. if (serializationObject.id != null) {
  100820. result.id = serializationObject.id;
  100821. }
  100822. if (serializationObject.normals) {
  100823. result.setNormals(serializationObject.normals);
  100824. }
  100825. if (serializationObject.tangents) {
  100826. result.setTangents(serializationObject.tangents);
  100827. }
  100828. // Animations
  100829. if (serializationObject.animations) {
  100830. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  100831. var parsedAnimation = serializationObject.animations[animationIndex];
  100832. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  100833. if (internalClass) {
  100834. result.animations.push(internalClass.Parse(parsedAnimation));
  100835. }
  100836. }
  100837. }
  100838. return result;
  100839. };
  100840. /**
  100841. * Creates a MorphTarget from mesh data
  100842. * @param mesh defines the source mesh
  100843. * @param name defines the name to use for the new target
  100844. * @param influence defines the influence to attach to the target
  100845. * @returns a new MorphTarget
  100846. */
  100847. MorphTarget.FromMesh = function (mesh, name, influence) {
  100848. if (!name) {
  100849. name = mesh.name;
  100850. }
  100851. var result = new MorphTarget(name, influence, mesh.getScene());
  100852. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  100853. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  100854. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  100855. }
  100856. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  100857. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  100858. }
  100859. return result;
  100860. };
  100861. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  100862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  100863. ], MorphTarget.prototype, "id", void 0);
  100864. return MorphTarget;
  100865. }());
  100866. /***/ }),
  100867. /***/ "./Morph/morphTargetManager.ts":
  100868. /*!*************************************!*\
  100869. !*** ./Morph/morphTargetManager.ts ***!
  100870. \*************************************/
  100871. /*! exports provided: MorphTargetManager */
  100872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100873. "use strict";
  100874. __webpack_require__.r(__webpack_exports__);
  100875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  100876. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  100877. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100878. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100879. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100880. /**
  100881. * This class is used to deform meshes using morphing between different targets
  100882. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100883. */
  100884. var MorphTargetManager = /** @class */ (function () {
  100885. /**
  100886. * Creates a new MorphTargetManager
  100887. * @param scene defines the current scene
  100888. */
  100889. function MorphTargetManager(scene) {
  100890. if (scene === void 0) { scene = null; }
  100891. this._targets = new Array();
  100892. this._targetInfluenceChangedObservers = new Array();
  100893. this._targetDataLayoutChangedObservers = new Array();
  100894. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  100895. this._supportsNormals = false;
  100896. this._supportsTangents = false;
  100897. this._vertexCount = 0;
  100898. this._uniqueId = 0;
  100899. this._tempInfluences = new Array();
  100900. if (!scene) {
  100901. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100902. }
  100903. this._scene = scene;
  100904. if (this._scene) {
  100905. this._scene.morphTargetManagers.push(this);
  100906. this._uniqueId = this._scene.getUniqueId();
  100907. }
  100908. }
  100909. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  100910. /**
  100911. * Gets the unique ID of this manager
  100912. */
  100913. get: function () {
  100914. return this._uniqueId;
  100915. },
  100916. enumerable: true,
  100917. configurable: true
  100918. });
  100919. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  100920. /**
  100921. * Gets the number of vertices handled by this manager
  100922. */
  100923. get: function () {
  100924. return this._vertexCount;
  100925. },
  100926. enumerable: true,
  100927. configurable: true
  100928. });
  100929. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  100930. /**
  100931. * Gets a boolean indicating if this manager supports morphing of normals
  100932. */
  100933. get: function () {
  100934. return this._supportsNormals;
  100935. },
  100936. enumerable: true,
  100937. configurable: true
  100938. });
  100939. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  100940. /**
  100941. * Gets a boolean indicating if this manager supports morphing of tangents
  100942. */
  100943. get: function () {
  100944. return this._supportsTangents;
  100945. },
  100946. enumerable: true,
  100947. configurable: true
  100948. });
  100949. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  100950. /**
  100951. * Gets the number of targets stored in this manager
  100952. */
  100953. get: function () {
  100954. return this._targets.length;
  100955. },
  100956. enumerable: true,
  100957. configurable: true
  100958. });
  100959. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  100960. /**
  100961. * Gets the number of influencers (ie. the number of targets with influences > 0)
  100962. */
  100963. get: function () {
  100964. return this._activeTargets.length;
  100965. },
  100966. enumerable: true,
  100967. configurable: true
  100968. });
  100969. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  100970. /**
  100971. * Gets the list of influences (one per target)
  100972. */
  100973. get: function () {
  100974. return this._influences;
  100975. },
  100976. enumerable: true,
  100977. configurable: true
  100978. });
  100979. /**
  100980. * Gets the active target at specified index. An active target is a target with an influence > 0
  100981. * @param index defines the index to check
  100982. * @returns the requested target
  100983. */
  100984. MorphTargetManager.prototype.getActiveTarget = function (index) {
  100985. return this._activeTargets.data[index];
  100986. };
  100987. /**
  100988. * Gets the target at specified index
  100989. * @param index defines the index to check
  100990. * @returns the requested target
  100991. */
  100992. MorphTargetManager.prototype.getTarget = function (index) {
  100993. return this._targets[index];
  100994. };
  100995. /**
  100996. * Add a new target to this manager
  100997. * @param target defines the target to add
  100998. */
  100999. MorphTargetManager.prototype.addTarget = function (target) {
  101000. var _this = this;
  101001. this._targets.push(target);
  101002. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  101003. _this._syncActiveTargets(needUpdate);
  101004. }));
  101005. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  101006. _this._syncActiveTargets(true);
  101007. }));
  101008. this._syncActiveTargets(true);
  101009. };
  101010. /**
  101011. * Removes a target from the manager
  101012. * @param target defines the target to remove
  101013. */
  101014. MorphTargetManager.prototype.removeTarget = function (target) {
  101015. var index = this._targets.indexOf(target);
  101016. if (index >= 0) {
  101017. this._targets.splice(index, 1);
  101018. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  101019. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  101020. this._syncActiveTargets(true);
  101021. }
  101022. };
  101023. /**
  101024. * Serializes the current manager into a Serialization object
  101025. * @returns the serialized object
  101026. */
  101027. MorphTargetManager.prototype.serialize = function () {
  101028. var serializationObject = {};
  101029. serializationObject.id = this.uniqueId;
  101030. serializationObject.targets = [];
  101031. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  101032. var target = _a[_i];
  101033. serializationObject.targets.push(target.serialize());
  101034. }
  101035. return serializationObject;
  101036. };
  101037. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  101038. var influenceCount = 0;
  101039. this._activeTargets.reset();
  101040. this._supportsNormals = true;
  101041. this._supportsTangents = true;
  101042. this._vertexCount = 0;
  101043. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  101044. var target = _a[_i];
  101045. if (target.influence === 0) {
  101046. continue;
  101047. }
  101048. this._activeTargets.push(target);
  101049. this._tempInfluences[influenceCount++] = target.influence;
  101050. this._supportsNormals = this._supportsNormals && target.hasNormals;
  101051. this._supportsTangents = this._supportsTangents && target.hasTangents;
  101052. var positions = target.getPositions();
  101053. if (positions) {
  101054. var vertexCount = positions.length / 3;
  101055. if (this._vertexCount === 0) {
  101056. this._vertexCount = vertexCount;
  101057. }
  101058. else if (this._vertexCount !== vertexCount) {
  101059. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  101060. return;
  101061. }
  101062. }
  101063. }
  101064. if (!this._influences || this._influences.length !== influenceCount) {
  101065. this._influences = new Float32Array(influenceCount);
  101066. }
  101067. for (var index = 0; index < influenceCount; index++) {
  101068. this._influences[index] = this._tempInfluences[index];
  101069. }
  101070. if (needUpdate) {
  101071. this.synchronize();
  101072. }
  101073. };
  101074. /**
  101075. * Syncrhonize the targets with all the meshes using this morph target manager
  101076. */
  101077. MorphTargetManager.prototype.synchronize = function () {
  101078. if (!this._scene) {
  101079. return;
  101080. }
  101081. // Flag meshes as dirty to resync with the active targets
  101082. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  101083. var mesh = _a[_i];
  101084. if (mesh.morphTargetManager === this) {
  101085. mesh._syncGeometryWithMorphTargetManager();
  101086. }
  101087. }
  101088. };
  101089. // Statics
  101090. /**
  101091. * Creates a new MorphTargetManager from serialized data
  101092. * @param serializationObject defines the serialized data
  101093. * @param scene defines the hosting scene
  101094. * @returns the new MorphTargetManager
  101095. */
  101096. MorphTargetManager.Parse = function (serializationObject, scene) {
  101097. var result = new MorphTargetManager(scene);
  101098. result._uniqueId = serializationObject.id;
  101099. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  101100. var targetData = _a[_i];
  101101. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  101102. }
  101103. return result;
  101104. };
  101105. return MorphTargetManager;
  101106. }());
  101107. /***/ }),
  101108. /***/ "./Offline/database.ts":
  101109. /*!*****************************!*\
  101110. !*** ./Offline/database.ts ***!
  101111. \*****************************/
  101112. /*! exports provided: Database */
  101113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101114. "use strict";
  101115. __webpack_require__.r(__webpack_exports__);
  101116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  101117. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  101118. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  101119. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  101120. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  101121. // Sets the default offline provider to Babylon.js
  101122. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  101123. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  101124. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  101125. };
  101126. /**
  101127. * Class used to enable access to IndexedDB
  101128. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101129. */
  101130. var Database = /** @class */ (function () {
  101131. /**
  101132. * Creates a new Database
  101133. * @param urlToScene defines the url to load the scene
  101134. * @param callbackManifestChecked defines the callback to use when manifest is checked
  101135. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  101136. */
  101137. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  101138. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  101139. var _this = this;
  101140. // Handling various flavors of prefixed version of IndexedDB
  101141. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  101142. this._callbackManifestChecked = callbackManifestChecked;
  101143. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  101144. this._db = null;
  101145. this._enableSceneOffline = false;
  101146. this._enableTexturesOffline = false;
  101147. this._manifestVersionFound = 0;
  101148. this._mustUpdateRessources = false;
  101149. this._hasReachedQuota = false;
  101150. if (!Database.IDBStorageEnabled) {
  101151. this._callbackManifestChecked(true);
  101152. }
  101153. else {
  101154. if (disableManifestCheck) {
  101155. this._enableSceneOffline = true;
  101156. this._enableTexturesOffline = true;
  101157. this._manifestVersionFound = 1;
  101158. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  101159. _this._callbackManifestChecked(true);
  101160. });
  101161. }
  101162. else {
  101163. this._checkManifestFile();
  101164. }
  101165. }
  101166. }
  101167. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  101168. /**
  101169. * Gets a boolean indicating if scene must be saved in the database
  101170. */
  101171. get: function () {
  101172. return this._enableSceneOffline;
  101173. },
  101174. enumerable: true,
  101175. configurable: true
  101176. });
  101177. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  101178. /**
  101179. * Gets a boolean indicating if textures must be saved in the database
  101180. */
  101181. get: function () {
  101182. return this._enableTexturesOffline;
  101183. },
  101184. enumerable: true,
  101185. configurable: true
  101186. });
  101187. Database.prototype._checkManifestFile = function () {
  101188. var _this = this;
  101189. var noManifestFile = function () {
  101190. _this._enableSceneOffline = false;
  101191. _this._enableTexturesOffline = false;
  101192. _this._callbackManifestChecked(false);
  101193. };
  101194. var timeStampUsed = false;
  101195. var manifestURL = this._currentSceneUrl + ".manifest";
  101196. var xhr = new XMLHttpRequest();
  101197. if (navigator.onLine) {
  101198. // Adding a timestamp to by-pass browsers' cache
  101199. timeStampUsed = true;
  101200. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  101201. }
  101202. xhr.open("GET", manifestURL, true);
  101203. xhr.addEventListener("load", function () {
  101204. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  101205. try {
  101206. var manifestFile = JSON.parse(xhr.response);
  101207. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  101208. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  101209. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  101210. _this._manifestVersionFound = manifestFile.version;
  101211. }
  101212. if (_this._callbackManifestChecked) {
  101213. _this._callbackManifestChecked(true);
  101214. }
  101215. }
  101216. catch (ex) {
  101217. noManifestFile();
  101218. }
  101219. }
  101220. else {
  101221. noManifestFile();
  101222. }
  101223. }, false);
  101224. xhr.addEventListener("error", function () {
  101225. if (timeStampUsed) {
  101226. timeStampUsed = false;
  101227. // Let's retry without the timeStamp
  101228. // It could fail when coupled with HTML5 Offline API
  101229. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  101230. xhr.open("GET", retryManifestURL, true);
  101231. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101232. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101233. }
  101234. xhr.send();
  101235. }
  101236. else {
  101237. noManifestFile();
  101238. }
  101239. }, false);
  101240. try {
  101241. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101242. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101243. }
  101244. xhr.send();
  101245. }
  101246. catch (ex) {
  101247. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  101248. this._callbackManifestChecked(false);
  101249. }
  101250. };
  101251. /**
  101252. * Open the database and make it available
  101253. * @param successCallback defines the callback to call on success
  101254. * @param errorCallback defines the callback to call on error
  101255. */
  101256. Database.prototype.open = function (successCallback, errorCallback) {
  101257. var _this = this;
  101258. var handleError = function () {
  101259. _this._isSupported = false;
  101260. if (errorCallback) {
  101261. errorCallback();
  101262. }
  101263. };
  101264. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  101265. // Your browser doesn't support IndexedDB
  101266. this._isSupported = false;
  101267. if (errorCallback) {
  101268. errorCallback();
  101269. }
  101270. }
  101271. else {
  101272. // If the DB hasn't been opened or created yet
  101273. if (!this._db) {
  101274. this._hasReachedQuota = false;
  101275. this._isSupported = true;
  101276. var request = this._idbFactory.open("babylonjs", 1);
  101277. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  101278. request.onerror = function () {
  101279. handleError();
  101280. };
  101281. // executes when a version change transaction cannot complete due to other active transactions
  101282. request.onblocked = function () {
  101283. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  101284. handleError();
  101285. };
  101286. // DB has been opened successfully
  101287. request.onsuccess = function () {
  101288. _this._db = request.result;
  101289. successCallback();
  101290. };
  101291. // Initialization of the DB. Creating Scenes & Textures stores
  101292. request.onupgradeneeded = function (event) {
  101293. _this._db = (event.target).result;
  101294. if (_this._db) {
  101295. try {
  101296. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  101297. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  101298. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  101299. }
  101300. catch (ex) {
  101301. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  101302. handleError();
  101303. }
  101304. }
  101305. };
  101306. }
  101307. // DB has already been created and opened
  101308. else {
  101309. if (successCallback) {
  101310. successCallback();
  101311. }
  101312. }
  101313. }
  101314. };
  101315. /**
  101316. * Loads an image from the database
  101317. * @param url defines the url to load from
  101318. * @param image defines the target DOM image
  101319. */
  101320. Database.prototype.loadImage = function (url, image) {
  101321. var _this = this;
  101322. var completeURL = Database._ReturnFullUrlLocation(url);
  101323. var saveAndLoadImage = function () {
  101324. if (!_this._hasReachedQuota && _this._db !== null) {
  101325. // the texture is not yet in the DB, let's try to save it
  101326. _this._saveImageIntoDBAsync(completeURL, image);
  101327. }
  101328. // If the texture is not in the DB and we've reached the DB quota limit
  101329. // let's load it directly from the web
  101330. else {
  101331. image.src = url;
  101332. }
  101333. };
  101334. if (!this._mustUpdateRessources) {
  101335. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  101336. }
  101337. // First time we're download the images or update requested in the manifest file by a version change
  101338. else {
  101339. saveAndLoadImage();
  101340. }
  101341. };
  101342. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  101343. if (this._isSupported && this._db !== null) {
  101344. var texture;
  101345. var transaction = this._db.transaction(["textures"]);
  101346. transaction.onabort = function () {
  101347. image.src = url;
  101348. };
  101349. transaction.oncomplete = function () {
  101350. var blobTextureURL;
  101351. if (texture) {
  101352. var URL = window.URL || window.webkitURL;
  101353. blobTextureURL = URL.createObjectURL(texture.data);
  101354. image.onerror = function () {
  101355. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  101356. image.src = url;
  101357. };
  101358. image.src = blobTextureURL;
  101359. }
  101360. else {
  101361. notInDBCallback();
  101362. }
  101363. };
  101364. var getRequest = transaction.objectStore("textures").get(url);
  101365. getRequest.onsuccess = function (event) {
  101366. texture = (event.target).result;
  101367. };
  101368. getRequest.onerror = function () {
  101369. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  101370. image.src = url;
  101371. };
  101372. }
  101373. else {
  101374. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101375. image.src = url;
  101376. }
  101377. };
  101378. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  101379. var _this = this;
  101380. if (this._isSupported) {
  101381. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  101382. var generateBlobUrl = function () {
  101383. var blobTextureURL;
  101384. if (blob) {
  101385. var URL = window.URL || window.webkitURL;
  101386. try {
  101387. blobTextureURL = URL.createObjectURL(blob);
  101388. }
  101389. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  101390. catch (ex) {
  101391. blobTextureURL = URL.createObjectURL(blob);
  101392. }
  101393. }
  101394. if (blobTextureURL) {
  101395. image.src = blobTextureURL;
  101396. }
  101397. };
  101398. if (Database.IsUASupportingBlobStorage) { // Create XHR
  101399. var xhr = new XMLHttpRequest(), blob;
  101400. xhr.open("GET", url, true);
  101401. xhr.responseType = "blob";
  101402. xhr.addEventListener("load", function () {
  101403. if (xhr.status === 200 && _this._db) {
  101404. // Blob as response (XHR2)
  101405. blob = xhr.response;
  101406. var transaction = _this._db.transaction(["textures"], "readwrite");
  101407. // the transaction could abort because of a QuotaExceededError error
  101408. transaction.onabort = function (event) {
  101409. try {
  101410. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101411. var srcElement = (event.srcElement || event.target);
  101412. var error = srcElement.error;
  101413. if (error && error.name === "QuotaExceededError") {
  101414. _this._hasReachedQuota = true;
  101415. }
  101416. }
  101417. catch (ex) { }
  101418. generateBlobUrl();
  101419. };
  101420. transaction.oncomplete = function () {
  101421. generateBlobUrl();
  101422. };
  101423. var newTexture = { textureUrl: url, data: blob };
  101424. try {
  101425. // Put the blob into the dabase
  101426. var addRequest = transaction.objectStore("textures").put(newTexture);
  101427. addRequest.onsuccess = function () {
  101428. };
  101429. addRequest.onerror = function () {
  101430. generateBlobUrl();
  101431. };
  101432. }
  101433. catch (ex) {
  101434. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  101435. if (ex.code === 25) {
  101436. Database.IsUASupportingBlobStorage = false;
  101437. _this._enableTexturesOffline = false;
  101438. }
  101439. image.src = url;
  101440. }
  101441. }
  101442. else {
  101443. image.src = url;
  101444. }
  101445. }, false);
  101446. xhr.addEventListener("error", function () {
  101447. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  101448. image.src = url;
  101449. }, false);
  101450. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  101451. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101452. }
  101453. xhr.send();
  101454. }
  101455. else {
  101456. image.src = url;
  101457. }
  101458. }
  101459. else {
  101460. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101461. image.src = url;
  101462. }
  101463. };
  101464. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  101465. var _this = this;
  101466. var updateVersion = function () {
  101467. // the version is not yet in the DB or we need to update it
  101468. _this._saveVersionIntoDBAsync(url, versionLoaded);
  101469. };
  101470. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  101471. };
  101472. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  101473. var _this = this;
  101474. if (this._isSupported && this._db) {
  101475. var version;
  101476. try {
  101477. var transaction = this._db.transaction(["versions"]);
  101478. transaction.oncomplete = function () {
  101479. if (version) {
  101480. // If the version in the JSON file is different from the version in DB
  101481. if (_this._manifestVersionFound !== version.data) {
  101482. _this._mustUpdateRessources = true;
  101483. updateInDBCallback();
  101484. }
  101485. else {
  101486. callback(version.data);
  101487. }
  101488. }
  101489. // version was not found in DB
  101490. else {
  101491. _this._mustUpdateRessources = true;
  101492. updateInDBCallback();
  101493. }
  101494. };
  101495. transaction.onabort = function () {
  101496. callback(-1);
  101497. };
  101498. var getRequest = transaction.objectStore("versions").get(url);
  101499. getRequest.onsuccess = function (event) {
  101500. version = (event.target).result;
  101501. };
  101502. getRequest.onerror = function () {
  101503. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  101504. callback(-1);
  101505. };
  101506. }
  101507. catch (ex) {
  101508. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  101509. callback(-1);
  101510. }
  101511. }
  101512. else {
  101513. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101514. callback(-1);
  101515. }
  101516. };
  101517. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  101518. var _this = this;
  101519. if (this._isSupported && !this._hasReachedQuota && this._db) {
  101520. try {
  101521. // Open a transaction to the database
  101522. var transaction = this._db.transaction(["versions"], "readwrite");
  101523. // the transaction could abort because of a QuotaExceededError error
  101524. transaction.onabort = function (event) {
  101525. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101526. var error = event.srcElement['error'];
  101527. if (error && error.name === "QuotaExceededError") {
  101528. _this._hasReachedQuota = true;
  101529. }
  101530. }
  101531. catch (ex) { }
  101532. callback(-1);
  101533. };
  101534. transaction.oncomplete = function () {
  101535. callback(_this._manifestVersionFound);
  101536. };
  101537. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  101538. // Put the scene into the database
  101539. var addRequest = transaction.objectStore("versions").put(newVersion);
  101540. addRequest.onsuccess = function () {
  101541. };
  101542. addRequest.onerror = function () {
  101543. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  101544. };
  101545. }
  101546. catch (ex) {
  101547. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  101548. callback(-1);
  101549. }
  101550. }
  101551. else {
  101552. callback(-1);
  101553. }
  101554. };
  101555. /**
  101556. * Loads a file from database
  101557. * @param url defines the URL to load from
  101558. * @param sceneLoaded defines a callback to call on success
  101559. * @param progressCallBack defines a callback to call when progress changed
  101560. * @param errorCallback defines a callback to call on error
  101561. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  101562. */
  101563. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  101564. var _this = this;
  101565. var completeUrl = Database._ReturnFullUrlLocation(url);
  101566. var saveAndLoadFile = function () {
  101567. // the scene is not yet in the DB, let's try to save it
  101568. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101569. };
  101570. this._checkVersionFromDB(completeUrl, function (version) {
  101571. if (version !== -1) {
  101572. if (!_this._mustUpdateRessources) {
  101573. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  101574. }
  101575. else {
  101576. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101577. }
  101578. }
  101579. else {
  101580. if (errorCallback) {
  101581. errorCallback();
  101582. }
  101583. }
  101584. });
  101585. };
  101586. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  101587. if (this._isSupported && this._db) {
  101588. var targetStore;
  101589. if (url.indexOf(".babylon") !== -1) {
  101590. targetStore = "scenes";
  101591. }
  101592. else {
  101593. targetStore = "textures";
  101594. }
  101595. var file;
  101596. var transaction = this._db.transaction([targetStore]);
  101597. transaction.oncomplete = function () {
  101598. if (file) {
  101599. callback(file.data);
  101600. }
  101601. // file was not found in DB
  101602. else {
  101603. notInDBCallback();
  101604. }
  101605. };
  101606. transaction.onabort = function () {
  101607. notInDBCallback();
  101608. };
  101609. var getRequest = transaction.objectStore(targetStore).get(url);
  101610. getRequest.onsuccess = function (event) {
  101611. file = (event.target).result;
  101612. };
  101613. getRequest.onerror = function () {
  101614. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  101615. notInDBCallback();
  101616. };
  101617. }
  101618. else {
  101619. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101620. callback();
  101621. }
  101622. };
  101623. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  101624. var _this = this;
  101625. if (this._isSupported) {
  101626. var targetStore;
  101627. if (url.indexOf(".babylon") !== -1) {
  101628. targetStore = "scenes";
  101629. }
  101630. else {
  101631. targetStore = "textures";
  101632. }
  101633. // Create XHR
  101634. var xhr = new XMLHttpRequest();
  101635. var fileData;
  101636. xhr.open("GET", url + "?" + Date.now(), true);
  101637. if (useArrayBuffer) {
  101638. xhr.responseType = "arraybuffer";
  101639. }
  101640. if (progressCallback) {
  101641. xhr.onprogress = progressCallback;
  101642. }
  101643. xhr.addEventListener("load", function () {
  101644. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  101645. // Blob as response (XHR2)
  101646. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  101647. if (!_this._hasReachedQuota && _this._db) {
  101648. // Open a transaction to the database
  101649. var transaction = _this._db.transaction([targetStore], "readwrite");
  101650. // the transaction could abort because of a QuotaExceededError error
  101651. transaction.onabort = function (event) {
  101652. try {
  101653. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101654. var error = event.srcElement['error'];
  101655. if (error && error.name === "QuotaExceededError") {
  101656. _this._hasReachedQuota = true;
  101657. }
  101658. }
  101659. catch (ex) { }
  101660. callback(fileData);
  101661. };
  101662. transaction.oncomplete = function () {
  101663. callback(fileData);
  101664. };
  101665. var newFile;
  101666. if (targetStore === "scenes") {
  101667. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  101668. }
  101669. else {
  101670. newFile = { textureUrl: url, data: fileData };
  101671. }
  101672. try {
  101673. // Put the scene into the database
  101674. var addRequest = transaction.objectStore(targetStore).put(newFile);
  101675. addRequest.onsuccess = function () {
  101676. };
  101677. addRequest.onerror = function () {
  101678. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  101679. };
  101680. }
  101681. catch (ex) {
  101682. callback(fileData);
  101683. }
  101684. }
  101685. else {
  101686. callback(fileData);
  101687. }
  101688. }
  101689. else {
  101690. if (xhr.status >= 400 && errorCallback) {
  101691. errorCallback(xhr);
  101692. }
  101693. else {
  101694. callback();
  101695. }
  101696. }
  101697. }, false);
  101698. xhr.addEventListener("error", function () {
  101699. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  101700. callback();
  101701. }, false);
  101702. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101703. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101704. }
  101705. xhr.send();
  101706. }
  101707. else {
  101708. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  101709. callback();
  101710. }
  101711. };
  101712. /**
  101713. * Validates if xhr data is correct
  101714. * @param xhr defines the request to validate
  101715. * @param dataType defines the expected data type
  101716. * @returns true if data is correct
  101717. */
  101718. Database._ValidateXHRData = function (xhr, dataType) {
  101719. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  101720. if (dataType === void 0) { dataType = 7; }
  101721. try {
  101722. if (dataType & 1) {
  101723. if (xhr.responseText && xhr.responseText.length > 0) {
  101724. return true;
  101725. }
  101726. else if (dataType === 1) {
  101727. return false;
  101728. }
  101729. }
  101730. if (dataType & 2) {
  101731. // Check header width and height since there is no "TGA" magic number
  101732. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  101733. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  101734. return true;
  101735. }
  101736. else if (dataType === 2) {
  101737. return false;
  101738. }
  101739. }
  101740. if (dataType & 4) {
  101741. // Check for the "DDS" magic number
  101742. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  101743. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  101744. return true;
  101745. }
  101746. else {
  101747. return false;
  101748. }
  101749. }
  101750. }
  101751. catch (e) {
  101752. // Global protection
  101753. }
  101754. return false;
  101755. };
  101756. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  101757. Database.IsUASupportingBlobStorage = true;
  101758. /**
  101759. * Gets a boolean indicating if Database storate is enabled (off by default)
  101760. */
  101761. Database.IDBStorageEnabled = false;
  101762. Database._ParseURL = function (url) {
  101763. var a = document.createElement('a');
  101764. a.href = url;
  101765. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  101766. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  101767. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  101768. return absLocation;
  101769. };
  101770. Database._ReturnFullUrlLocation = function (url) {
  101771. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  101772. return (Database._ParseURL(window.location.href) + url);
  101773. }
  101774. else {
  101775. return url;
  101776. }
  101777. };
  101778. return Database;
  101779. }());
  101780. /***/ }),
  101781. /***/ "./Offline/index.ts":
  101782. /*!**************************!*\
  101783. !*** ./Offline/index.ts ***!
  101784. \**************************/
  101785. /*! exports provided: Database */
  101786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101787. "use strict";
  101788. __webpack_require__.r(__webpack_exports__);
  101789. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  101790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  101791. /***/ }),
  101792. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  101793. /*!******************************************************!*\
  101794. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  101795. \******************************************************/
  101796. /*! exports provided: BoxParticleEmitter */
  101797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101798. "use strict";
  101799. __webpack_require__.r(__webpack_exports__);
  101800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  101801. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101802. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101803. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101804. /**
  101805. * Particle emitter emitting particles from the inside of a box.
  101806. * It emits the particles randomly between 2 given directions.
  101807. */
  101808. var BoxParticleEmitter = /** @class */ (function () {
  101809. /**
  101810. * Creates a new instance BoxParticleEmitter
  101811. */
  101812. function BoxParticleEmitter() {
  101813. /**
  101814. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101815. */
  101816. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101817. /**
  101818. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101819. */
  101820. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101821. /**
  101822. * 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.
  101823. */
  101824. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  101825. /**
  101826. * 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.
  101827. */
  101828. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  101829. }
  101830. /**
  101831. * Called by the particle System when the direction is computed for the created particle.
  101832. * @param worldMatrix is the world matrix of the particle system
  101833. * @param directionToUpdate is the direction vector to update with the result
  101834. * @param particle is the particle we are computed the direction for
  101835. */
  101836. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101837. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101838. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101839. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101840. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101841. };
  101842. /**
  101843. * Called by the particle System when the position is computed for the created particle.
  101844. * @param worldMatrix is the world matrix of the particle system
  101845. * @param positionToUpdate is the position vector to update with the result
  101846. * @param particle is the particle we are computed the position for
  101847. */
  101848. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101849. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  101850. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  101851. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  101852. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101853. };
  101854. /**
  101855. * Clones the current emitter and returns a copy of it
  101856. * @returns the new emitter
  101857. */
  101858. BoxParticleEmitter.prototype.clone = function () {
  101859. var newOne = new BoxParticleEmitter();
  101860. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101861. return newOne;
  101862. };
  101863. /**
  101864. * Called by the GPUParticleSystem to setup the update shader
  101865. * @param effect defines the update shader
  101866. */
  101867. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  101868. effect.setVector3("direction1", this.direction1);
  101869. effect.setVector3("direction2", this.direction2);
  101870. effect.setVector3("minEmitBox", this.minEmitBox);
  101871. effect.setVector3("maxEmitBox", this.maxEmitBox);
  101872. };
  101873. /**
  101874. * Returns a string to use to update the GPU particles update shader
  101875. * @returns a string containng the defines string
  101876. */
  101877. BoxParticleEmitter.prototype.getEffectDefines = function () {
  101878. return "#define BOXEMITTER";
  101879. };
  101880. /**
  101881. * Returns the string "BoxParticleEmitter"
  101882. * @returns a string containing the class name
  101883. */
  101884. BoxParticleEmitter.prototype.getClassName = function () {
  101885. return "BoxParticleEmitter";
  101886. };
  101887. /**
  101888. * Serializes the particle system to a JSON object.
  101889. * @returns the JSON object
  101890. */
  101891. BoxParticleEmitter.prototype.serialize = function () {
  101892. var serializationObject = {};
  101893. serializationObject.type = this.getClassName();
  101894. serializationObject.direction1 = this.direction1.asArray();
  101895. serializationObject.direction2 = this.direction2.asArray();
  101896. serializationObject.minEmitBox = this.minEmitBox.asArray();
  101897. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  101898. return serializationObject;
  101899. };
  101900. /**
  101901. * Parse properties from a JSON object
  101902. * @param serializationObject defines the JSON object
  101903. */
  101904. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  101905. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  101906. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  101907. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  101908. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  101909. };
  101910. return BoxParticleEmitter;
  101911. }());
  101912. /***/ }),
  101913. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  101914. /*!*******************************************************!*\
  101915. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  101916. \*******************************************************/
  101917. /*! exports provided: ConeParticleEmitter */
  101918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101919. "use strict";
  101920. __webpack_require__.r(__webpack_exports__);
  101921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  101922. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101923. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101924. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101925. /**
  101926. * Particle emitter emitting particles from the inside of a cone.
  101927. * It emits the particles alongside the cone volume from the base to the particle.
  101928. * The emission direction might be randomized.
  101929. */
  101930. var ConeParticleEmitter = /** @class */ (function () {
  101931. /**
  101932. * Creates a new instance ConeParticleEmitter
  101933. * @param radius the radius of the emission cone (1 by default)
  101934. * @param angle the cone base angle (PI by default)
  101935. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  101936. */
  101937. function ConeParticleEmitter(radius, angle,
  101938. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101939. directionRandomizer) {
  101940. if (radius === void 0) { radius = 1; }
  101941. if (angle === void 0) { angle = Math.PI; }
  101942. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101943. this.directionRandomizer = directionRandomizer;
  101944. /**
  101945. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  101946. */
  101947. this.radiusRange = 1;
  101948. /**
  101949. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  101950. */
  101951. this.heightRange = 1;
  101952. /**
  101953. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  101954. */
  101955. this.emitFromSpawnPointOnly = false;
  101956. this.angle = angle;
  101957. this.radius = radius;
  101958. }
  101959. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  101960. /**
  101961. * Gets or sets the radius of the emission cone
  101962. */
  101963. get: function () {
  101964. return this._radius;
  101965. },
  101966. set: function (value) {
  101967. this._radius = value;
  101968. this._buildHeight();
  101969. },
  101970. enumerable: true,
  101971. configurable: true
  101972. });
  101973. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  101974. /**
  101975. * Gets or sets the angle of the emission cone
  101976. */
  101977. get: function () {
  101978. return this._angle;
  101979. },
  101980. set: function (value) {
  101981. this._angle = value;
  101982. this._buildHeight();
  101983. },
  101984. enumerable: true,
  101985. configurable: true
  101986. });
  101987. ConeParticleEmitter.prototype._buildHeight = function () {
  101988. if (this._angle !== 0) {
  101989. this._height = this._radius / Math.tan(this._angle / 2);
  101990. }
  101991. else {
  101992. this._height = 1;
  101993. }
  101994. };
  101995. /**
  101996. * Called by the particle System when the direction is computed for the created particle.
  101997. * @param worldMatrix is the world matrix of the particle system
  101998. * @param directionToUpdate is the direction vector to update with the result
  101999. * @param particle is the particle we are computed the direction for
  102000. */
  102001. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102002. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  102003. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  102004. }
  102005. else {
  102006. // measure the direction Vector from the emitter to the particle.
  102007. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102008. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102009. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102010. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102011. direction.x += randX;
  102012. direction.y += randY;
  102013. direction.z += randZ;
  102014. direction.normalize();
  102015. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102016. }
  102017. };
  102018. /**
  102019. * Called by the particle System when the position is computed for the created particle.
  102020. * @param worldMatrix is the world matrix of the particle system
  102021. * @param positionToUpdate is the position vector to update with the result
  102022. * @param particle is the particle we are computed the position for
  102023. */
  102024. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102025. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  102026. var h;
  102027. if (!this.emitFromSpawnPointOnly) {
  102028. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  102029. // Better distribution in a cone at normal angles.
  102030. h = 1 - h * h;
  102031. }
  102032. else {
  102033. h = 0.0001;
  102034. }
  102035. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  102036. radius = radius * h;
  102037. var randX = radius * Math.sin(s);
  102038. var randZ = radius * Math.cos(s);
  102039. var randY = h * this._height;
  102040. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102041. };
  102042. /**
  102043. * Clones the current emitter and returns a copy of it
  102044. * @returns the new emitter
  102045. */
  102046. ConeParticleEmitter.prototype.clone = function () {
  102047. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  102048. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102049. return newOne;
  102050. };
  102051. /**
  102052. * Called by the GPUParticleSystem to setup the update shader
  102053. * @param effect defines the update shader
  102054. */
  102055. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  102056. effect.setFloat2("radius", this._radius, this.radiusRange);
  102057. effect.setFloat("coneAngle", this._angle);
  102058. effect.setFloat2("height", this._height, this.heightRange);
  102059. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102060. };
  102061. /**
  102062. * Returns a string to use to update the GPU particles update shader
  102063. * @returns a string containng the defines string
  102064. */
  102065. ConeParticleEmitter.prototype.getEffectDefines = function () {
  102066. var defines = "#define CONEEMITTER";
  102067. if (this.emitFromSpawnPointOnly) {
  102068. defines += "\n#define CONEEMITTERSPAWNPOINT";
  102069. }
  102070. return defines;
  102071. };
  102072. /**
  102073. * Returns the string "ConeParticleEmitter"
  102074. * @returns a string containing the class name
  102075. */
  102076. ConeParticleEmitter.prototype.getClassName = function () {
  102077. return "ConeParticleEmitter";
  102078. };
  102079. /**
  102080. * Serializes the particle system to a JSON object.
  102081. * @returns the JSON object
  102082. */
  102083. ConeParticleEmitter.prototype.serialize = function () {
  102084. var serializationObject = {};
  102085. serializationObject.type = this.getClassName();
  102086. serializationObject.radius = this._radius;
  102087. serializationObject.angle = this._angle;
  102088. serializationObject.directionRandomizer = this.directionRandomizer;
  102089. return serializationObject;
  102090. };
  102091. /**
  102092. * Parse properties from a JSON object
  102093. * @param serializationObject defines the JSON object
  102094. */
  102095. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  102096. this.radius = serializationObject.radius;
  102097. this.angle = serializationObject.angle;
  102098. this.directionRandomizer = serializationObject.directionRandomizer;
  102099. };
  102100. return ConeParticleEmitter;
  102101. }());
  102102. /***/ }),
  102103. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  102104. /*!***********************************************************!*\
  102105. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  102106. \***********************************************************/
  102107. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  102108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102109. "use strict";
  102110. __webpack_require__.r(__webpack_exports__);
  102111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  102112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  102113. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102114. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102115. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102116. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102117. /**
  102118. * Particle emitter emitting particles from the inside of a cylinder.
  102119. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  102120. */
  102121. var CylinderParticleEmitter = /** @class */ (function () {
  102122. /**
  102123. * Creates a new instance CylinderParticleEmitter
  102124. * @param radius the radius of the emission cylinder (1 by default)
  102125. * @param height the height of the emission cylinder (1 by default)
  102126. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102127. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102128. */
  102129. function CylinderParticleEmitter(
  102130. /**
  102131. * The radius of the emission cylinder.
  102132. */
  102133. radius,
  102134. /**
  102135. * The height of the emission cylinder.
  102136. */
  102137. height,
  102138. /**
  102139. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102140. */
  102141. radiusRange,
  102142. /**
  102143. * How much to randomize the particle direction [0-1].
  102144. */
  102145. directionRandomizer) {
  102146. if (radius === void 0) { radius = 1; }
  102147. if (height === void 0) { height = 1; }
  102148. if (radiusRange === void 0) { radiusRange = 1; }
  102149. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102150. this.radius = radius;
  102151. this.height = height;
  102152. this.radiusRange = radiusRange;
  102153. this.directionRandomizer = directionRandomizer;
  102154. }
  102155. /**
  102156. * Called by the particle System when the direction is computed for the created particle.
  102157. * @param worldMatrix is the world matrix of the particle system
  102158. * @param directionToUpdate is the direction vector to update with the result
  102159. * @param particle is the particle we are computed the direction for
  102160. */
  102161. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102162. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102163. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  102164. var angle = Math.atan2(direction.x, direction.z);
  102165. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  102166. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  102167. direction.x = Math.sin(angle);
  102168. direction.z = Math.cos(angle);
  102169. direction.normalize();
  102170. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102171. };
  102172. /**
  102173. * Called by the particle System when the position is computed for the created particle.
  102174. * @param worldMatrix is the world matrix of the particle system
  102175. * @param positionToUpdate is the position vector to update with the result
  102176. * @param particle is the particle we are computed the position for
  102177. */
  102178. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102179. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  102180. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102181. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  102182. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  102183. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  102184. var xPos = positionRadius * Math.cos(angle);
  102185. var zPos = positionRadius * Math.sin(angle);
  102186. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  102187. };
  102188. /**
  102189. * Clones the current emitter and returns a copy of it
  102190. * @returns the new emitter
  102191. */
  102192. CylinderParticleEmitter.prototype.clone = function () {
  102193. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  102194. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102195. return newOne;
  102196. };
  102197. /**
  102198. * Called by the GPUParticleSystem to setup the update shader
  102199. * @param effect defines the update shader
  102200. */
  102201. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  102202. effect.setFloat("radius", this.radius);
  102203. effect.setFloat("height", this.height);
  102204. effect.setFloat("radiusRange", this.radiusRange);
  102205. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102206. };
  102207. /**
  102208. * Returns a string to use to update the GPU particles update shader
  102209. * @returns a string containng the defines string
  102210. */
  102211. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  102212. return "#define CYLINDEREMITTER";
  102213. };
  102214. /**
  102215. * Returns the string "CylinderParticleEmitter"
  102216. * @returns a string containing the class name
  102217. */
  102218. CylinderParticleEmitter.prototype.getClassName = function () {
  102219. return "CylinderParticleEmitter";
  102220. };
  102221. /**
  102222. * Serializes the particle system to a JSON object.
  102223. * @returns the JSON object
  102224. */
  102225. CylinderParticleEmitter.prototype.serialize = function () {
  102226. var serializationObject = {};
  102227. serializationObject.type = this.getClassName();
  102228. serializationObject.radius = this.radius;
  102229. serializationObject.height = this.height;
  102230. serializationObject.radiusRange = this.radiusRange;
  102231. serializationObject.directionRandomizer = this.directionRandomizer;
  102232. return serializationObject;
  102233. };
  102234. /**
  102235. * Parse properties from a JSON object
  102236. * @param serializationObject defines the JSON object
  102237. */
  102238. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  102239. this.radius = serializationObject.radius;
  102240. this.height = serializationObject.height;
  102241. this.radiusRange = serializationObject.radiusRange;
  102242. this.directionRandomizer = serializationObject.directionRandomizer;
  102243. };
  102244. return CylinderParticleEmitter;
  102245. }());
  102246. /**
  102247. * Particle emitter emitting particles from the inside of a cylinder.
  102248. * It emits the particles randomly between two vectors.
  102249. */
  102250. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  102251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  102252. /**
  102253. * Creates a new instance CylinderDirectedParticleEmitter
  102254. * @param radius the radius of the emission cylinder (1 by default)
  102255. * @param height the height of the emission cylinder (1 by default)
  102256. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102257. * @param direction1 the min limit of the emission direction (up vector by default)
  102258. * @param direction2 the max limit of the emission direction (up vector by default)
  102259. */
  102260. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  102261. /**
  102262. * The min limit of the emission direction.
  102263. */
  102264. direction1,
  102265. /**
  102266. * The max limit of the emission direction.
  102267. */
  102268. direction2) {
  102269. if (radius === void 0) { radius = 1; }
  102270. if (height === void 0) { height = 1; }
  102271. if (radiusRange === void 0) { radiusRange = 1; }
  102272. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102273. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102274. var _this = _super.call(this, radius, height, radiusRange) || this;
  102275. _this.direction1 = direction1;
  102276. _this.direction2 = direction2;
  102277. return _this;
  102278. }
  102279. /**
  102280. * Called by the particle System when the direction is computed for the created particle.
  102281. * @param worldMatrix is the world matrix of the particle system
  102282. * @param directionToUpdate is the direction vector to update with the result
  102283. * @param particle is the particle we are computed the direction for
  102284. */
  102285. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102286. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102287. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102288. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102289. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102290. };
  102291. /**
  102292. * Clones the current emitter and returns a copy of it
  102293. * @returns the new emitter
  102294. */
  102295. CylinderDirectedParticleEmitter.prototype.clone = function () {
  102296. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  102297. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102298. return newOne;
  102299. };
  102300. /**
  102301. * Called by the GPUParticleSystem to setup the update shader
  102302. * @param effect defines the update shader
  102303. */
  102304. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102305. effect.setFloat("radius", this.radius);
  102306. effect.setFloat("height", this.height);
  102307. effect.setFloat("radiusRange", this.radiusRange);
  102308. effect.setVector3("direction1", this.direction1);
  102309. effect.setVector3("direction2", this.direction2);
  102310. };
  102311. /**
  102312. * Returns a string to use to update the GPU particles update shader
  102313. * @returns a string containng the defines string
  102314. */
  102315. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102316. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  102317. };
  102318. /**
  102319. * Returns the string "CylinderDirectedParticleEmitter"
  102320. * @returns a string containing the class name
  102321. */
  102322. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  102323. return "CylinderDirectedParticleEmitter";
  102324. };
  102325. /**
  102326. * Serializes the particle system to a JSON object.
  102327. * @returns the JSON object
  102328. */
  102329. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  102330. var serializationObject = _super.prototype.serialize.call(this);
  102331. serializationObject.direction1 = this.direction1.asArray();
  102332. serializationObject.direction2 = this.direction2.asArray();
  102333. return serializationObject;
  102334. };
  102335. /**
  102336. * Parse properties from a JSON object
  102337. * @param serializationObject defines the JSON object
  102338. */
  102339. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102340. _super.prototype.parse.call(this, serializationObject);
  102341. this.direction1.copyFrom(serializationObject.direction1);
  102342. this.direction2.copyFrom(serializationObject.direction2);
  102343. };
  102344. return CylinderDirectedParticleEmitter;
  102345. }(CylinderParticleEmitter));
  102346. /***/ }),
  102347. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  102348. /*!**************************************************************!*\
  102349. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  102350. \**************************************************************/
  102351. /*! exports provided: HemisphericParticleEmitter */
  102352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102353. "use strict";
  102354. __webpack_require__.r(__webpack_exports__);
  102355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  102356. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102357. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102358. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102359. /**
  102360. * Particle emitter emitting particles from the inside of a hemisphere.
  102361. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  102362. */
  102363. var HemisphericParticleEmitter = /** @class */ (function () {
  102364. /**
  102365. * Creates a new instance HemisphericParticleEmitter
  102366. * @param radius the radius of the emission hemisphere (1 by default)
  102367. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102368. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102369. */
  102370. function HemisphericParticleEmitter(
  102371. /**
  102372. * The radius of the emission hemisphere.
  102373. */
  102374. radius,
  102375. /**
  102376. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102377. */
  102378. radiusRange,
  102379. /**
  102380. * How much to randomize the particle direction [0-1].
  102381. */
  102382. directionRandomizer) {
  102383. if (radius === void 0) { radius = 1; }
  102384. if (radiusRange === void 0) { radiusRange = 1; }
  102385. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102386. this.radius = radius;
  102387. this.radiusRange = radiusRange;
  102388. this.directionRandomizer = directionRandomizer;
  102389. }
  102390. /**
  102391. * Called by the particle System when the direction is computed for the created particle.
  102392. * @param worldMatrix is the world matrix of the particle system
  102393. * @param directionToUpdate is the direction vector to update with the result
  102394. * @param particle is the particle we are computed the direction for
  102395. */
  102396. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102397. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102398. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102399. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102400. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102401. direction.x += randX;
  102402. direction.y += randY;
  102403. direction.z += randZ;
  102404. direction.normalize();
  102405. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102406. };
  102407. /**
  102408. * Called by the particle System when the position is computed for the created particle.
  102409. * @param worldMatrix is the world matrix of the particle system
  102410. * @param positionToUpdate is the position vector to update with the result
  102411. * @param particle is the particle we are computed the position for
  102412. */
  102413. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102414. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102415. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102416. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102417. var theta = Math.acos(2 * v - 1);
  102418. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102419. var randY = randRadius * Math.cos(theta);
  102420. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102421. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  102422. };
  102423. /**
  102424. * Clones the current emitter and returns a copy of it
  102425. * @returns the new emitter
  102426. */
  102427. HemisphericParticleEmitter.prototype.clone = function () {
  102428. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  102429. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102430. return newOne;
  102431. };
  102432. /**
  102433. * Called by the GPUParticleSystem to setup the update shader
  102434. * @param effect defines the update shader
  102435. */
  102436. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  102437. effect.setFloat("radius", this.radius);
  102438. effect.setFloat("radiusRange", this.radiusRange);
  102439. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102440. };
  102441. /**
  102442. * Returns a string to use to update the GPU particles update shader
  102443. * @returns a string containng the defines string
  102444. */
  102445. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  102446. return "#define HEMISPHERICEMITTER";
  102447. };
  102448. /**
  102449. * Returns the string "HemisphericParticleEmitter"
  102450. * @returns a string containing the class name
  102451. */
  102452. HemisphericParticleEmitter.prototype.getClassName = function () {
  102453. return "HemisphericParticleEmitter";
  102454. };
  102455. /**
  102456. * Serializes the particle system to a JSON object.
  102457. * @returns the JSON object
  102458. */
  102459. HemisphericParticleEmitter.prototype.serialize = function () {
  102460. var serializationObject = {};
  102461. serializationObject.type = this.getClassName();
  102462. serializationObject.radius = this.radius;
  102463. serializationObject.radiusRange = this.radiusRange;
  102464. serializationObject.directionRandomizer = this.directionRandomizer;
  102465. return serializationObject;
  102466. };
  102467. /**
  102468. * Parse properties from a JSON object
  102469. * @param serializationObject defines the JSON object
  102470. */
  102471. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  102472. this.radius = serializationObject.radius;
  102473. this.radiusRange = serializationObject.radiusRange;
  102474. this.directionRandomizer = serializationObject.directionRandomizer;
  102475. };
  102476. return HemisphericParticleEmitter;
  102477. }());
  102478. /***/ }),
  102479. /***/ "./Particles/EmitterTypes/index.ts":
  102480. /*!*****************************************!*\
  102481. !*** ./Particles/EmitterTypes/index.ts ***!
  102482. \*****************************************/
  102483. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  102484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102485. "use strict";
  102486. __webpack_require__.r(__webpack_exports__);
  102487. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  102488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  102489. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  102490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  102491. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  102492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  102493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  102494. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  102495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  102496. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  102497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  102498. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  102499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  102500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  102501. /***/ }),
  102502. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  102503. /*!********************************************************!*\
  102504. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  102505. \********************************************************/
  102506. /*! exports provided: PointParticleEmitter */
  102507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102508. "use strict";
  102509. __webpack_require__.r(__webpack_exports__);
  102510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  102511. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102512. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102513. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102514. /**
  102515. * Particle emitter emitting particles from a point.
  102516. * It emits the particles randomly between 2 given directions.
  102517. */
  102518. var PointParticleEmitter = /** @class */ (function () {
  102519. /**
  102520. * Creates a new instance PointParticleEmitter
  102521. */
  102522. function PointParticleEmitter() {
  102523. /**
  102524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102525. */
  102526. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102527. /**
  102528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102529. */
  102530. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102531. }
  102532. /**
  102533. * Called by the particle System when the direction is computed for the created particle.
  102534. * @param worldMatrix is the world matrix of the particle system
  102535. * @param directionToUpdate is the direction vector to update with the result
  102536. * @param particle is the particle we are computed the direction for
  102537. */
  102538. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102539. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102540. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102541. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102542. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102543. };
  102544. /**
  102545. * Called by the particle System when the position is computed for the created particle.
  102546. * @param worldMatrix is the world matrix of the particle system
  102547. * @param positionToUpdate is the position vector to update with the result
  102548. * @param particle is the particle we are computed the position for
  102549. */
  102550. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102551. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  102552. };
  102553. /**
  102554. * Clones the current emitter and returns a copy of it
  102555. * @returns the new emitter
  102556. */
  102557. PointParticleEmitter.prototype.clone = function () {
  102558. var newOne = new PointParticleEmitter();
  102559. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102560. return newOne;
  102561. };
  102562. /**
  102563. * Called by the GPUParticleSystem to setup the update shader
  102564. * @param effect defines the update shader
  102565. */
  102566. PointParticleEmitter.prototype.applyToShader = function (effect) {
  102567. effect.setVector3("direction1", this.direction1);
  102568. effect.setVector3("direction2", this.direction2);
  102569. };
  102570. /**
  102571. * Returns a string to use to update the GPU particles update shader
  102572. * @returns a string containng the defines string
  102573. */
  102574. PointParticleEmitter.prototype.getEffectDefines = function () {
  102575. return "#define POINTEMITTER";
  102576. };
  102577. /**
  102578. * Returns the string "PointParticleEmitter"
  102579. * @returns a string containing the class name
  102580. */
  102581. PointParticleEmitter.prototype.getClassName = function () {
  102582. return "PointParticleEmitter";
  102583. };
  102584. /**
  102585. * Serializes the particle system to a JSON object.
  102586. * @returns the JSON object
  102587. */
  102588. PointParticleEmitter.prototype.serialize = function () {
  102589. var serializationObject = {};
  102590. serializationObject.type = this.getClassName();
  102591. serializationObject.direction1 = this.direction1.asArray();
  102592. serializationObject.direction2 = this.direction2.asArray();
  102593. return serializationObject;
  102594. };
  102595. /**
  102596. * Parse properties from a JSON object
  102597. * @param serializationObject defines the JSON object
  102598. */
  102599. PointParticleEmitter.prototype.parse = function (serializationObject) {
  102600. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  102601. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  102602. };
  102603. return PointParticleEmitter;
  102604. }());
  102605. /***/ }),
  102606. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  102607. /*!*********************************************************!*\
  102608. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  102609. \*********************************************************/
  102610. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  102611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102612. "use strict";
  102613. __webpack_require__.r(__webpack_exports__);
  102614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  102615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  102616. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102617. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102618. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102619. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102620. /**
  102621. * Particle emitter emitting particles from the inside of a sphere.
  102622. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  102623. */
  102624. var SphereParticleEmitter = /** @class */ (function () {
  102625. /**
  102626. * Creates a new instance SphereParticleEmitter
  102627. * @param radius the radius of the emission sphere (1 by default)
  102628. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102629. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102630. */
  102631. function SphereParticleEmitter(
  102632. /**
  102633. * The radius of the emission sphere.
  102634. */
  102635. radius,
  102636. /**
  102637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102638. */
  102639. radiusRange,
  102640. /**
  102641. * How much to randomize the particle direction [0-1].
  102642. */
  102643. directionRandomizer) {
  102644. if (radius === void 0) { radius = 1; }
  102645. if (radiusRange === void 0) { radiusRange = 1; }
  102646. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102647. this.radius = radius;
  102648. this.radiusRange = radiusRange;
  102649. this.directionRandomizer = directionRandomizer;
  102650. }
  102651. /**
  102652. * Called by the particle System when the direction is computed for the created particle.
  102653. * @param worldMatrix is the world matrix of the particle system
  102654. * @param directionToUpdate is the direction vector to update with the result
  102655. * @param particle is the particle we are computed the direction for
  102656. */
  102657. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102658. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102659. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102660. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102661. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102662. direction.x += randX;
  102663. direction.y += randY;
  102664. direction.z += randZ;
  102665. direction.normalize();
  102666. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102667. };
  102668. /**
  102669. * Called by the particle System when the position is computed for the created particle.
  102670. * @param worldMatrix is the world matrix of the particle system
  102671. * @param positionToUpdate is the position vector to update with the result
  102672. * @param particle is the particle we are computed the position for
  102673. */
  102674. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102675. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102676. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102677. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102678. var theta = Math.acos(2 * v - 1);
  102679. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102680. var randY = randRadius * Math.cos(theta);
  102681. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102682. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102683. };
  102684. /**
  102685. * Clones the current emitter and returns a copy of it
  102686. * @returns the new emitter
  102687. */
  102688. SphereParticleEmitter.prototype.clone = function () {
  102689. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  102690. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102691. return newOne;
  102692. };
  102693. /**
  102694. * Called by the GPUParticleSystem to setup the update shader
  102695. * @param effect defines the update shader
  102696. */
  102697. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  102698. effect.setFloat("radius", this.radius);
  102699. effect.setFloat("radiusRange", this.radiusRange);
  102700. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102701. };
  102702. /**
  102703. * Returns a string to use to update the GPU particles update shader
  102704. * @returns a string containng the defines string
  102705. */
  102706. SphereParticleEmitter.prototype.getEffectDefines = function () {
  102707. return "#define SPHEREEMITTER";
  102708. };
  102709. /**
  102710. * Returns the string "SphereParticleEmitter"
  102711. * @returns a string containing the class name
  102712. */
  102713. SphereParticleEmitter.prototype.getClassName = function () {
  102714. return "SphereParticleEmitter";
  102715. };
  102716. /**
  102717. * Serializes the particle system to a JSON object.
  102718. * @returns the JSON object
  102719. */
  102720. SphereParticleEmitter.prototype.serialize = function () {
  102721. var serializationObject = {};
  102722. serializationObject.type = this.getClassName();
  102723. serializationObject.radius = this.radius;
  102724. serializationObject.radiusRange = this.radiusRange;
  102725. serializationObject.directionRandomizer = this.directionRandomizer;
  102726. return serializationObject;
  102727. };
  102728. /**
  102729. * Parse properties from a JSON object
  102730. * @param serializationObject defines the JSON object
  102731. */
  102732. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  102733. this.radius = serializationObject.radius;
  102734. this.radiusRange = serializationObject.radiusRange;
  102735. this.directionRandomizer = serializationObject.directionRandomizer;
  102736. };
  102737. return SphereParticleEmitter;
  102738. }());
  102739. /**
  102740. * Particle emitter emitting particles from the inside of a sphere.
  102741. * It emits the particles randomly between two vectors.
  102742. */
  102743. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  102744. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  102745. /**
  102746. * Creates a new instance SphereDirectedParticleEmitter
  102747. * @param radius the radius of the emission sphere (1 by default)
  102748. * @param direction1 the min limit of the emission direction (up vector by default)
  102749. * @param direction2 the max limit of the emission direction (up vector by default)
  102750. */
  102751. function SphereDirectedParticleEmitter(radius,
  102752. /**
  102753. * The min limit of the emission direction.
  102754. */
  102755. direction1,
  102756. /**
  102757. * The max limit of the emission direction.
  102758. */
  102759. direction2) {
  102760. if (radius === void 0) { radius = 1; }
  102761. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102762. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102763. var _this = _super.call(this, radius) || this;
  102764. _this.direction1 = direction1;
  102765. _this.direction2 = direction2;
  102766. return _this;
  102767. }
  102768. /**
  102769. * Called by the particle System when the direction is computed for the created particle.
  102770. * @param worldMatrix is the world matrix of the particle system
  102771. * @param directionToUpdate is the direction vector to update with the result
  102772. * @param particle is the particle we are computed the direction for
  102773. */
  102774. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102775. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102776. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102777. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102778. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102779. };
  102780. /**
  102781. * Clones the current emitter and returns a copy of it
  102782. * @returns the new emitter
  102783. */
  102784. SphereDirectedParticleEmitter.prototype.clone = function () {
  102785. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  102786. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102787. return newOne;
  102788. };
  102789. /**
  102790. * Called by the GPUParticleSystem to setup the update shader
  102791. * @param effect defines the update shader
  102792. */
  102793. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102794. effect.setFloat("radius", this.radius);
  102795. effect.setFloat("radiusRange", this.radiusRange);
  102796. effect.setVector3("direction1", this.direction1);
  102797. effect.setVector3("direction2", this.direction2);
  102798. };
  102799. /**
  102800. * Returns a string to use to update the GPU particles update shader
  102801. * @returns a string containng the defines string
  102802. */
  102803. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102804. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  102805. };
  102806. /**
  102807. * Returns the string "SphereDirectedParticleEmitter"
  102808. * @returns a string containing the class name
  102809. */
  102810. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  102811. return "SphereDirectedParticleEmitter";
  102812. };
  102813. /**
  102814. * Serializes the particle system to a JSON object.
  102815. * @returns the JSON object
  102816. */
  102817. SphereDirectedParticleEmitter.prototype.serialize = function () {
  102818. var serializationObject = _super.prototype.serialize.call(this);
  102819. serializationObject.direction1 = this.direction1.asArray();
  102820. serializationObject.direction2 = this.direction2.asArray();
  102821. return serializationObject;
  102822. };
  102823. /**
  102824. * Parse properties from a JSON object
  102825. * @param serializationObject defines the JSON object
  102826. */
  102827. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102828. _super.prototype.parse.call(this, serializationObject);
  102829. this.direction1.copyFrom(serializationObject.direction1);
  102830. this.direction2.copyFrom(serializationObject.direction2);
  102831. };
  102832. return SphereDirectedParticleEmitter;
  102833. }(SphereParticleEmitter));
  102834. /***/ }),
  102835. /***/ "./Particles/baseParticleSystem.ts":
  102836. /*!*****************************************!*\
  102837. !*** ./Particles/baseParticleSystem.ts ***!
  102838. \*****************************************/
  102839. /*! exports provided: BaseParticleSystem */
  102840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102841. "use strict";
  102842. __webpack_require__.r(__webpack_exports__);
  102843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  102844. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102845. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  102846. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  102847. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102848. /**
  102849. * This represents the base class for particle system in Babylon.
  102850. * 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.
  102851. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  102852. * @example https://doc.babylonjs.com/babylon101/particles
  102853. */
  102854. var BaseParticleSystem = /** @class */ (function () {
  102855. /**
  102856. * Instantiates a particle system.
  102857. * 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.
  102858. * @param name The name of the particle system
  102859. */
  102860. function BaseParticleSystem(name) {
  102861. /**
  102862. * List of animations used by the particle system.
  102863. */
  102864. this.animations = [];
  102865. /**
  102866. * The rendering group used by the Particle system to chose when to render.
  102867. */
  102868. this.renderingGroupId = 0;
  102869. /**
  102870. * The emitter represents the Mesh or position we are attaching the particle system to.
  102871. */
  102872. this.emitter = null;
  102873. /**
  102874. * The maximum number of particles to emit per frame
  102875. */
  102876. this.emitRate = 10;
  102877. /**
  102878. * If you want to launch only a few particles at once, that can be done, as well.
  102879. */
  102880. this.manualEmitCount = -1;
  102881. /**
  102882. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  102883. */
  102884. this.updateSpeed = 0.01;
  102885. /**
  102886. * The amount of time the particle system is running (depends of the overall update speed).
  102887. */
  102888. this.targetStopDuration = 0;
  102889. /**
  102890. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  102891. */
  102892. this.disposeOnStop = false;
  102893. /**
  102894. * Minimum power of emitting particles.
  102895. */
  102896. this.minEmitPower = 1;
  102897. /**
  102898. * Maximum power of emitting particles.
  102899. */
  102900. this.maxEmitPower = 1;
  102901. /**
  102902. * Minimum life time of emitting particles.
  102903. */
  102904. this.minLifeTime = 1;
  102905. /**
  102906. * Maximum life time of emitting particles.
  102907. */
  102908. this.maxLifeTime = 1;
  102909. /**
  102910. * Minimum Size of emitting particles.
  102911. */
  102912. this.minSize = 1;
  102913. /**
  102914. * Maximum Size of emitting particles.
  102915. */
  102916. this.maxSize = 1;
  102917. /**
  102918. * Minimum scale of emitting particles on X axis.
  102919. */
  102920. this.minScaleX = 1;
  102921. /**
  102922. * Maximum scale of emitting particles on X axis.
  102923. */
  102924. this.maxScaleX = 1;
  102925. /**
  102926. * Minimum scale of emitting particles on Y axis.
  102927. */
  102928. this.minScaleY = 1;
  102929. /**
  102930. * Maximum scale of emitting particles on Y axis.
  102931. */
  102932. this.maxScaleY = 1;
  102933. /**
  102934. * Gets or sets the minimal initial rotation in radians.
  102935. */
  102936. this.minInitialRotation = 0;
  102937. /**
  102938. * Gets or sets the maximal initial rotation in radians.
  102939. */
  102940. this.maxInitialRotation = 0;
  102941. /**
  102942. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  102943. */
  102944. this.minAngularSpeed = 0;
  102945. /**
  102946. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  102947. */
  102948. this.maxAngularSpeed = 0;
  102949. /**
  102950. * The layer mask we are rendering the particles through.
  102951. */
  102952. this.layerMask = 0x0FFFFFFF;
  102953. /**
  102954. * This can help using your own shader to render the particle system.
  102955. * The according effect will be created
  102956. */
  102957. this.customShader = null;
  102958. /**
  102959. * By default particle system starts as soon as they are created. This prevents the
  102960. * automatic start to happen and let you decide when to start emitting particles.
  102961. */
  102962. this.preventAutoStart = false;
  102963. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102964. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  102965. /**
  102966. * Callback triggered when the particle animation is ending.
  102967. */
  102968. this.onAnimationEnd = null;
  102969. /**
  102970. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  102971. */
  102972. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  102973. /**
  102974. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102975. * to override the particles.
  102976. */
  102977. this.forceDepthWrite = false;
  102978. /** 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 */
  102979. this.preWarmCycles = 0;
  102980. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  102981. this.preWarmStepOffset = 1;
  102982. /**
  102983. * 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)
  102984. */
  102985. this.spriteCellChangeSpeed = 1;
  102986. /**
  102987. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102988. */
  102989. this.startSpriteCellID = 0;
  102990. /**
  102991. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102992. */
  102993. this.endSpriteCellID = 0;
  102994. /**
  102995. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102996. */
  102997. this.spriteCellWidth = 0;
  102998. /**
  102999. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  103000. */
  103001. this.spriteCellHeight = 0;
  103002. /**
  103003. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  103004. */
  103005. this.spriteRandomStartCell = false;
  103006. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  103007. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103008. /**
  103009. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  103010. */
  103011. this.beginAnimationOnStart = false;
  103012. /**
  103013. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  103014. */
  103015. this.beginAnimationFrom = 0;
  103016. /**
  103017. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  103018. */
  103019. this.beginAnimationTo = 60;
  103020. /**
  103021. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  103022. */
  103023. this.beginAnimationLoop = false;
  103024. /**
  103025. * You can use gravity if you want to give an orientation to your particles.
  103026. */
  103027. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103028. this._colorGradients = null;
  103029. this._sizeGradients = null;
  103030. this._lifeTimeGradients = null;
  103031. this._angularSpeedGradients = null;
  103032. this._velocityGradients = null;
  103033. this._limitVelocityGradients = null;
  103034. this._dragGradients = null;
  103035. this._emitRateGradients = null;
  103036. this._startSizeGradients = null;
  103037. this._rampGradients = null;
  103038. this._colorRemapGradients = null;
  103039. this._alphaRemapGradients = null;
  103040. /**
  103041. * Defines the delay in milliseconds before starting the system (0 by default)
  103042. */
  103043. this.startDelay = 0;
  103044. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  103045. this.limitVelocityDamping = 0.4;
  103046. /**
  103047. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  103048. */
  103049. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103050. /**
  103051. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  103052. */
  103053. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103054. /**
  103055. * Color the particle will have at the end of its lifetime
  103056. */
  103057. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  103058. /**
  103059. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  103060. */
  103061. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103062. /** @hidden */
  103063. this._isSubEmitter = false;
  103064. /**
  103065. * Gets or sets the billboard mode to use when isBillboardBased = true.
  103066. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  103067. */
  103068. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  103069. this._isBillboardBased = true;
  103070. /**
  103071. * Local cache of defines for image processing.
  103072. */
  103073. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  103074. this.id = name;
  103075. this.name = name;
  103076. }
  103077. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  103078. /**
  103079. * Gets or sets a texture used to add random noise to particle positions
  103080. */
  103081. get: function () {
  103082. return this._noiseTexture;
  103083. },
  103084. set: function (value) {
  103085. if (this._noiseTexture === value) {
  103086. return;
  103087. }
  103088. this._noiseTexture = value;
  103089. this._reset();
  103090. },
  103091. enumerable: true,
  103092. configurable: true
  103093. });
  103094. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  103095. /**
  103096. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  103097. */
  103098. get: function () {
  103099. return this._isAnimationSheetEnabled;
  103100. },
  103101. set: function (value) {
  103102. if (this._isAnimationSheetEnabled == value) {
  103103. return;
  103104. }
  103105. this._isAnimationSheetEnabled = value;
  103106. this._reset();
  103107. },
  103108. enumerable: true,
  103109. configurable: true
  103110. });
  103111. /**
  103112. * Get hosting scene
  103113. * @returns the scene
  103114. */
  103115. BaseParticleSystem.prototype.getScene = function () {
  103116. return this._scene;
  103117. };
  103118. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  103119. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  103120. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  103121. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  103122. };
  103123. /**
  103124. * Gets the current list of drag gradients.
  103125. * You must use addDragGradient and removeDragGradient to udpate this list
  103126. * @returns the list of drag gradients
  103127. */
  103128. BaseParticleSystem.prototype.getDragGradients = function () {
  103129. return this._dragGradients;
  103130. };
  103131. /**
  103132. * Gets the current list of limit velocity gradients.
  103133. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  103134. * @returns the list of limit velocity gradients
  103135. */
  103136. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  103137. return this._limitVelocityGradients;
  103138. };
  103139. /**
  103140. * Gets the current list of color gradients.
  103141. * You must use addColorGradient and removeColorGradient to udpate this list
  103142. * @returns the list of color gradients
  103143. */
  103144. BaseParticleSystem.prototype.getColorGradients = function () {
  103145. return this._colorGradients;
  103146. };
  103147. /**
  103148. * Gets the current list of size gradients.
  103149. * You must use addSizeGradient and removeSizeGradient to udpate this list
  103150. * @returns the list of size gradients
  103151. */
  103152. BaseParticleSystem.prototype.getSizeGradients = function () {
  103153. return this._sizeGradients;
  103154. };
  103155. /**
  103156. * Gets the current list of color remap gradients.
  103157. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  103158. * @returns the list of color remap gradients
  103159. */
  103160. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  103161. return this._colorRemapGradients;
  103162. };
  103163. /**
  103164. * Gets the current list of alpha remap gradients.
  103165. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  103166. * @returns the list of alpha remap gradients
  103167. */
  103168. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  103169. return this._alphaRemapGradients;
  103170. };
  103171. /**
  103172. * Gets the current list of life time gradients.
  103173. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  103174. * @returns the list of life time gradients
  103175. */
  103176. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  103177. return this._lifeTimeGradients;
  103178. };
  103179. /**
  103180. * Gets the current list of angular speed gradients.
  103181. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  103182. * @returns the list of angular speed gradients
  103183. */
  103184. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  103185. return this._angularSpeedGradients;
  103186. };
  103187. /**
  103188. * Gets the current list of velocity gradients.
  103189. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  103190. * @returns the list of velocity gradients
  103191. */
  103192. BaseParticleSystem.prototype.getVelocityGradients = function () {
  103193. return this._velocityGradients;
  103194. };
  103195. /**
  103196. * Gets the current list of start size gradients.
  103197. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  103198. * @returns the list of start size gradients
  103199. */
  103200. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  103201. return this._startSizeGradients;
  103202. };
  103203. /**
  103204. * Gets the current list of emit rate gradients.
  103205. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  103206. * @returns the list of emit rate gradients
  103207. */
  103208. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  103209. return this._emitRateGradients;
  103210. };
  103211. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  103212. /**
  103213. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103214. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103215. */
  103216. get: function () {
  103217. if (this.particleEmitterType.direction1) {
  103218. return this.particleEmitterType.direction1;
  103219. }
  103220. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103221. },
  103222. set: function (value) {
  103223. if (this.particleEmitterType.direction1) {
  103224. this.particleEmitterType.direction1 = value;
  103225. }
  103226. },
  103227. enumerable: true,
  103228. configurable: true
  103229. });
  103230. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  103231. /**
  103232. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103233. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103234. */
  103235. get: function () {
  103236. if (this.particleEmitterType.direction2) {
  103237. return this.particleEmitterType.direction2;
  103238. }
  103239. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103240. },
  103241. set: function (value) {
  103242. if (this.particleEmitterType.direction2) {
  103243. this.particleEmitterType.direction2 = value;
  103244. }
  103245. },
  103246. enumerable: true,
  103247. configurable: true
  103248. });
  103249. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  103250. /**
  103251. * 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.
  103252. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103253. */
  103254. get: function () {
  103255. if (this.particleEmitterType.minEmitBox) {
  103256. return this.particleEmitterType.minEmitBox;
  103257. }
  103258. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103259. },
  103260. set: function (value) {
  103261. if (this.particleEmitterType.minEmitBox) {
  103262. this.particleEmitterType.minEmitBox = value;
  103263. }
  103264. },
  103265. enumerable: true,
  103266. configurable: true
  103267. });
  103268. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  103269. /**
  103270. * 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.
  103271. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103272. */
  103273. get: function () {
  103274. if (this.particleEmitterType.maxEmitBox) {
  103275. return this.particleEmitterType.maxEmitBox;
  103276. }
  103277. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103278. },
  103279. set: function (value) {
  103280. if (this.particleEmitterType.maxEmitBox) {
  103281. this.particleEmitterType.maxEmitBox = value;
  103282. }
  103283. },
  103284. enumerable: true,
  103285. configurable: true
  103286. });
  103287. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  103288. /**
  103289. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  103290. */
  103291. get: function () {
  103292. return this._isBillboardBased;
  103293. },
  103294. set: function (value) {
  103295. if (this._isBillboardBased === value) {
  103296. return;
  103297. }
  103298. this._isBillboardBased = value;
  103299. this._reset();
  103300. },
  103301. enumerable: true,
  103302. configurable: true
  103303. });
  103304. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  103305. /**
  103306. * Gets the image processing configuration used either in this material.
  103307. */
  103308. get: function () {
  103309. return this._imageProcessingConfiguration;
  103310. },
  103311. /**
  103312. * Sets the Default image processing configuration used either in the this material.
  103313. *
  103314. * If sets to null, the scene one is in use.
  103315. */
  103316. set: function (value) {
  103317. this._attachImageProcessingConfiguration(value);
  103318. },
  103319. enumerable: true,
  103320. configurable: true
  103321. });
  103322. /**
  103323. * Attaches a new image processing configuration to the Standard Material.
  103324. * @param configuration
  103325. */
  103326. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  103327. if (configuration === this._imageProcessingConfiguration) {
  103328. return;
  103329. }
  103330. // Pick the scene configuration if needed.
  103331. if (!configuration) {
  103332. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  103333. }
  103334. else {
  103335. this._imageProcessingConfiguration = configuration;
  103336. }
  103337. };
  103338. /** @hidden */
  103339. BaseParticleSystem.prototype._reset = function () {
  103340. };
  103341. /** @hidden */
  103342. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103343. if (!gradients) {
  103344. return this;
  103345. }
  103346. var index = 0;
  103347. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  103348. var valueGradient = gradients_1[_i];
  103349. if (valueGradient.gradient === gradient) {
  103350. gradients.splice(index, 1);
  103351. break;
  103352. }
  103353. index++;
  103354. }
  103355. if (texture) {
  103356. texture.dispose();
  103357. }
  103358. return this;
  103359. };
  103360. /**
  103361. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  103362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103364. * @returns the emitter
  103365. */
  103366. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  103367. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  103368. particleEmitter.direction1 = direction1;
  103369. particleEmitter.direction2 = direction2;
  103370. this.particleEmitterType = particleEmitter;
  103371. return particleEmitter;
  103372. };
  103373. /**
  103374. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  103375. * @param radius The radius of the hemisphere to emit from
  103376. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103377. * @returns the emitter
  103378. */
  103379. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  103380. if (radius === void 0) { radius = 1; }
  103381. if (radiusRange === void 0) { radiusRange = 1; }
  103382. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  103383. this.particleEmitterType = particleEmitter;
  103384. return particleEmitter;
  103385. };
  103386. /**
  103387. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  103388. * @param radius The radius of the sphere to emit from
  103389. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103390. * @returns the emitter
  103391. */
  103392. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  103393. if (radius === void 0) { radius = 1; }
  103394. if (radiusRange === void 0) { radiusRange = 1; }
  103395. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  103396. this.particleEmitterType = particleEmitter;
  103397. return particleEmitter;
  103398. };
  103399. /**
  103400. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  103401. * @param radius The radius of the sphere to emit from
  103402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  103403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  103404. * @returns the emitter
  103405. */
  103406. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  103407. if (radius === void 0) { radius = 1; }
  103408. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103409. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103410. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  103411. this.particleEmitterType = particleEmitter;
  103412. return particleEmitter;
  103413. };
  103414. /**
  103415. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  103416. * @param radius The radius of the emission cylinder
  103417. * @param height The height of the emission cylinder
  103418. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  103419. * @param directionRandomizer How much to randomize the particle direction [0-1]
  103420. * @returns the emitter
  103421. */
  103422. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  103423. if (radius === void 0) { radius = 1; }
  103424. if (height === void 0) { height = 1; }
  103425. if (radiusRange === void 0) { radiusRange = 1; }
  103426. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103427. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  103428. this.particleEmitterType = particleEmitter;
  103429. return particleEmitter;
  103430. };
  103431. /**
  103432. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  103433. * @param radius The radius of the cylinder to emit from
  103434. * @param height The height of the emission cylinder
  103435. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  103437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  103438. * @returns the emitter
  103439. */
  103440. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  103441. if (radius === void 0) { radius = 1; }
  103442. if (height === void 0) { height = 1; }
  103443. if (radiusRange === void 0) { radiusRange = 1; }
  103444. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103445. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103446. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  103447. this.particleEmitterType = particleEmitter;
  103448. return particleEmitter;
  103449. };
  103450. /**
  103451. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  103452. * @param radius The radius of the cone to emit from
  103453. * @param angle The base angle of the cone
  103454. * @returns the emitter
  103455. */
  103456. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  103457. if (radius === void 0) { radius = 1; }
  103458. if (angle === void 0) { angle = Math.PI / 4; }
  103459. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  103460. this.particleEmitterType = particleEmitter;
  103461. return particleEmitter;
  103462. };
  103463. /**
  103464. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  103465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103467. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103468. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103469. * @returns the emitter
  103470. */
  103471. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  103472. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  103473. this.particleEmitterType = particleEmitter;
  103474. this.direction1 = direction1;
  103475. this.direction2 = direction2;
  103476. this.minEmitBox = minEmitBox;
  103477. this.maxEmitBox = maxEmitBox;
  103478. return particleEmitter;
  103479. };
  103480. /**
  103481. * Source color is added to the destination color without alpha affecting the result
  103482. */
  103483. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  103484. /**
  103485. * Blend current color and particle color using particle’s alpha
  103486. */
  103487. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  103488. /**
  103489. * Add current color and particle color multiplied by particle’s alpha
  103490. */
  103491. BaseParticleSystem.BLENDMODE_ADD = 2;
  103492. /**
  103493. * Multiply current color with particle color
  103494. */
  103495. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  103496. /**
  103497. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  103498. */
  103499. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  103500. return BaseParticleSystem;
  103501. }());
  103502. /***/ }),
  103503. /***/ "./Particles/gpuParticleSystem.ts":
  103504. /*!****************************************!*\
  103505. !*** ./Particles/gpuParticleSystem.ts ***!
  103506. \****************************************/
  103507. /*! exports provided: GPUParticleSystem */
  103508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103509. "use strict";
  103510. __webpack_require__.r(__webpack_exports__);
  103511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  103512. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103513. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103514. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  103515. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103516. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103517. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103518. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103519. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103520. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  103521. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  103522. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  103523. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  103524. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  103525. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103526. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  103527. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103528. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103529. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103530. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  103531. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  103532. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  103533. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  103534. /**
  103535. * This represents a GPU particle system in Babylon
  103536. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  103537. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  103538. */
  103539. var GPUParticleSystem = /** @class */ (function (_super) {
  103540. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  103541. /**
  103542. * Instantiates a GPU particle system.
  103543. * 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.
  103544. * @param name The name of the particle system
  103545. * @param options The options used to create the system
  103546. * @param scene The scene the particle system belongs to
  103547. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  103548. */
  103549. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  103550. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  103551. var _this = _super.call(this, name) || this;
  103552. /**
  103553. * The layer mask we are rendering the particles through.
  103554. */
  103555. _this.layerMask = 0x0FFFFFFF;
  103556. _this._accumulatedCount = 0;
  103557. _this._targetIndex = 0;
  103558. _this._currentRenderId = -1;
  103559. _this._started = false;
  103560. _this._stopped = false;
  103561. _this._timeDelta = 0;
  103562. _this._actualFrame = 0;
  103563. _this._rawTextureWidth = 256;
  103564. /**
  103565. * An event triggered when the system is disposed.
  103566. */
  103567. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  103568. /**
  103569. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  103570. * to override the particles.
  103571. */
  103572. _this.forceDepthWrite = false;
  103573. _this._preWarmDone = false;
  103574. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  103575. // Setup the default processing configuration to the scene.
  103576. _this._attachImageProcessingConfiguration(null);
  103577. _this._engine = _this._scene.getEngine();
  103578. if (!options.randomTextureSize) {
  103579. delete options.randomTextureSize;
  103580. }
  103581. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  103582. var optionsAsNumber = options;
  103583. if (isFinite(optionsAsNumber)) {
  103584. fullOptions.capacity = optionsAsNumber;
  103585. }
  103586. _this._capacity = fullOptions.capacity;
  103587. _this._activeCount = fullOptions.capacity;
  103588. _this._currentActiveCount = 0;
  103589. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  103590. _this._scene.particleSystems.push(_this);
  103591. _this._updateEffectOptions = {
  103592. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  103593. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  103594. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  103595. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  103596. uniformBuffersNames: [],
  103597. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  103598. defines: "",
  103599. fallbacks: null,
  103600. onCompiled: null,
  103601. onError: null,
  103602. indexParameters: null,
  103603. maxSimultaneousLights: 0,
  103604. transformFeedbackVaryings: []
  103605. };
  103606. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  103607. // Random data
  103608. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  103609. var d = [];
  103610. for (var i = 0; i < maxTextureSize; ++i) {
  103611. d.push(Math.random());
  103612. d.push(Math.random());
  103613. d.push(Math.random());
  103614. d.push(Math.random());
  103615. }
  103616. _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);
  103617. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103618. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103619. d = [];
  103620. for (var i = 0; i < maxTextureSize; ++i) {
  103621. d.push(Math.random());
  103622. d.push(Math.random());
  103623. d.push(Math.random());
  103624. d.push(Math.random());
  103625. }
  103626. _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);
  103627. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103628. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103629. _this._randomTextureSize = maxTextureSize;
  103630. return _this;
  103631. }
  103632. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  103633. /**
  103634. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  103635. */
  103636. get: function () {
  103637. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  103638. return false;
  103639. }
  103640. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  103641. },
  103642. enumerable: true,
  103643. configurable: true
  103644. });
  103645. /**
  103646. * Gets the maximum number of particles active at the same time.
  103647. * @returns The max number of active particles.
  103648. */
  103649. GPUParticleSystem.prototype.getCapacity = function () {
  103650. return this._capacity;
  103651. };
  103652. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  103653. /**
  103654. * Gets or set the number of active particles
  103655. */
  103656. get: function () {
  103657. return this._activeCount;
  103658. },
  103659. set: function (value) {
  103660. this._activeCount = Math.min(value, this._capacity);
  103661. },
  103662. enumerable: true,
  103663. configurable: true
  103664. });
  103665. /**
  103666. * Is this system ready to be used/rendered
  103667. * @return true if the system is ready
  103668. */
  103669. GPUParticleSystem.prototype.isReady = function () {
  103670. if (!this._updateEffect) {
  103671. this._recreateUpdateEffect();
  103672. this._recreateRenderEffect();
  103673. return false;
  103674. }
  103675. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  103676. return false;
  103677. }
  103678. return true;
  103679. };
  103680. /**
  103681. * Gets if the system has been started. (Note: this will still be true after stop is called)
  103682. * @returns True if it has been started, otherwise false.
  103683. */
  103684. GPUParticleSystem.prototype.isStarted = function () {
  103685. return this._started;
  103686. };
  103687. /**
  103688. * Starts the particle system and begins to emit
  103689. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  103690. */
  103691. GPUParticleSystem.prototype.start = function (delay) {
  103692. var _this = this;
  103693. if (delay === void 0) { delay = this.startDelay; }
  103694. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  103695. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  103696. }
  103697. if (delay) {
  103698. setTimeout(function () {
  103699. _this.start(0);
  103700. }, delay);
  103701. return;
  103702. }
  103703. this._started = true;
  103704. this._stopped = false;
  103705. this._preWarmDone = false;
  103706. // Animations
  103707. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  103708. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  103709. }
  103710. };
  103711. /**
  103712. * Stops the particle system.
  103713. */
  103714. GPUParticleSystem.prototype.stop = function () {
  103715. this._stopped = true;
  103716. };
  103717. /**
  103718. * Remove all active particles
  103719. */
  103720. GPUParticleSystem.prototype.reset = function () {
  103721. this._releaseBuffers();
  103722. this._releaseVAOs();
  103723. this._currentActiveCount = 0;
  103724. this._targetIndex = 0;
  103725. };
  103726. /**
  103727. * Returns the string "GPUParticleSystem"
  103728. * @returns a string containing the class name
  103729. */
  103730. GPUParticleSystem.prototype.getClassName = function () {
  103731. return "GPUParticleSystem";
  103732. };
  103733. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103734. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  103735. this._releaseBuffers();
  103736. return this;
  103737. };
  103738. /**
  103739. * Adds a new color gradient
  103740. * @param gradient defines the gradient to use (between 0 and 1)
  103741. * @param color1 defines the color to affect to the specified gradient
  103742. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  103743. * @returns the current particle system
  103744. */
  103745. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  103746. if (!this._colorGradients) {
  103747. this._colorGradients = [];
  103748. }
  103749. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  103750. colorGradient.gradient = gradient;
  103751. colorGradient.color1 = color1;
  103752. this._colorGradients.push(colorGradient);
  103753. this._colorGradients.sort(function (a, b) {
  103754. if (a.gradient < b.gradient) {
  103755. return -1;
  103756. }
  103757. else if (a.gradient > b.gradient) {
  103758. return 1;
  103759. }
  103760. return 0;
  103761. });
  103762. if (this._colorGradientsTexture) {
  103763. this._colorGradientsTexture.dispose();
  103764. this._colorGradientsTexture = null;
  103765. }
  103766. this._releaseBuffers();
  103767. return this;
  103768. };
  103769. /**
  103770. * Remove a specific color gradient
  103771. * @param gradient defines the gradient to remove
  103772. * @returns the current particle system
  103773. */
  103774. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  103775. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  103776. this._colorGradientsTexture = null;
  103777. return this;
  103778. };
  103779. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  103780. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  103781. valueGradient.gradient = gradient;
  103782. valueGradient.factor1 = factor;
  103783. factorGradients.push(valueGradient);
  103784. factorGradients.sort(function (a, b) {
  103785. if (a.gradient < b.gradient) {
  103786. return -1;
  103787. }
  103788. else if (a.gradient > b.gradient) {
  103789. return 1;
  103790. }
  103791. return 0;
  103792. });
  103793. this._releaseBuffers();
  103794. };
  103795. /**
  103796. * Adds a new size gradient
  103797. * @param gradient defines the gradient to use (between 0 and 1)
  103798. * @param factor defines the size factor to affect to the specified gradient
  103799. * @returns the current particle system
  103800. */
  103801. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  103802. if (!this._sizeGradients) {
  103803. this._sizeGradients = [];
  103804. }
  103805. this._addFactorGradient(this._sizeGradients, gradient, factor);
  103806. if (this._sizeGradientsTexture) {
  103807. this._sizeGradientsTexture.dispose();
  103808. this._sizeGradientsTexture = null;
  103809. }
  103810. this._releaseBuffers();
  103811. return this;
  103812. };
  103813. /**
  103814. * Remove a specific size gradient
  103815. * @param gradient defines the gradient to remove
  103816. * @returns the current particle system
  103817. */
  103818. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  103819. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  103820. this._sizeGradientsTexture = null;
  103821. return this;
  103822. };
  103823. /**
  103824. * Adds a new angular speed gradient
  103825. * @param gradient defines the gradient to use (between 0 and 1)
  103826. * @param factor defines the angular speed to affect to the specified gradient
  103827. * @returns the current particle system
  103828. */
  103829. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  103830. if (!this._angularSpeedGradients) {
  103831. this._angularSpeedGradients = [];
  103832. }
  103833. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  103834. if (this._angularSpeedGradientsTexture) {
  103835. this._angularSpeedGradientsTexture.dispose();
  103836. this._angularSpeedGradientsTexture = null;
  103837. }
  103838. this._releaseBuffers();
  103839. return this;
  103840. };
  103841. /**
  103842. * Remove a specific angular speed gradient
  103843. * @param gradient defines the gradient to remove
  103844. * @returns the current particle system
  103845. */
  103846. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  103847. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  103848. this._angularSpeedGradientsTexture = null;
  103849. return this;
  103850. };
  103851. /**
  103852. * Adds a new velocity gradient
  103853. * @param gradient defines the gradient to use (between 0 and 1)
  103854. * @param factor defines the velocity to affect to the specified gradient
  103855. * @returns the current particle system
  103856. */
  103857. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  103858. if (!this._velocityGradients) {
  103859. this._velocityGradients = [];
  103860. }
  103861. this._addFactorGradient(this._velocityGradients, gradient, factor);
  103862. if (this._velocityGradientsTexture) {
  103863. this._velocityGradientsTexture.dispose();
  103864. this._velocityGradientsTexture = null;
  103865. }
  103866. this._releaseBuffers();
  103867. return this;
  103868. };
  103869. /**
  103870. * Remove a specific velocity gradient
  103871. * @param gradient defines the gradient to remove
  103872. * @returns the current particle system
  103873. */
  103874. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  103875. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  103876. this._velocityGradientsTexture = null;
  103877. return this;
  103878. };
  103879. /**
  103880. * Adds a new limit velocity gradient
  103881. * @param gradient defines the gradient to use (between 0 and 1)
  103882. * @param factor defines the limit velocity value to affect to the specified gradient
  103883. * @returns the current particle system
  103884. */
  103885. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  103886. if (!this._limitVelocityGradients) {
  103887. this._limitVelocityGradients = [];
  103888. }
  103889. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  103890. if (this._limitVelocityGradientsTexture) {
  103891. this._limitVelocityGradientsTexture.dispose();
  103892. this._limitVelocityGradientsTexture = null;
  103893. }
  103894. this._releaseBuffers();
  103895. return this;
  103896. };
  103897. /**
  103898. * Remove a specific limit velocity gradient
  103899. * @param gradient defines the gradient to remove
  103900. * @returns the current particle system
  103901. */
  103902. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  103903. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  103904. this._limitVelocityGradientsTexture = null;
  103905. return this;
  103906. };
  103907. /**
  103908. * Adds a new drag gradient
  103909. * @param gradient defines the gradient to use (between 0 and 1)
  103910. * @param factor defines the drag value to affect to the specified gradient
  103911. * @returns the current particle system
  103912. */
  103913. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  103914. if (!this._dragGradients) {
  103915. this._dragGradients = [];
  103916. }
  103917. this._addFactorGradient(this._dragGradients, gradient, factor);
  103918. if (this._dragGradientsTexture) {
  103919. this._dragGradientsTexture.dispose();
  103920. this._dragGradientsTexture = null;
  103921. }
  103922. this._releaseBuffers();
  103923. return this;
  103924. };
  103925. /**
  103926. * Remove a specific drag gradient
  103927. * @param gradient defines the gradient to remove
  103928. * @returns the current particle system
  103929. */
  103930. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  103931. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  103932. this._dragGradientsTexture = null;
  103933. return this;
  103934. };
  103935. /**
  103936. * Not supported by GPUParticleSystem
  103937. * @param gradient defines the gradient to use (between 0 and 1)
  103938. * @param factor defines the emit rate value to affect to the specified gradient
  103939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103940. * @returns the current particle system
  103941. */
  103942. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  103943. // Do nothing as emit rate is not supported by GPUParticleSystem
  103944. return this;
  103945. };
  103946. /**
  103947. * Not supported by GPUParticleSystem
  103948. * @param gradient defines the gradient to remove
  103949. * @returns the current particle system
  103950. */
  103951. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  103952. // Do nothing as emit rate is not supported by GPUParticleSystem
  103953. return this;
  103954. };
  103955. /**
  103956. * Not supported by GPUParticleSystem
  103957. * @param gradient defines the gradient to use (between 0 and 1)
  103958. * @param factor defines the start size value to affect to the specified gradient
  103959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103960. * @returns the current particle system
  103961. */
  103962. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  103963. // Do nothing as start size is not supported by GPUParticleSystem
  103964. return this;
  103965. };
  103966. /**
  103967. * Not supported by GPUParticleSystem
  103968. * @param gradient defines the gradient to remove
  103969. * @returns the current particle system
  103970. */
  103971. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  103972. // Do nothing as start size is not supported by GPUParticleSystem
  103973. return this;
  103974. };
  103975. /**
  103976. * Not supported by GPUParticleSystem
  103977. * @param gradient defines the gradient to use (between 0 and 1)
  103978. * @param min defines the color remap minimal range
  103979. * @param max defines the color remap maximal range
  103980. * @returns the current particle system
  103981. */
  103982. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  103983. // Do nothing as start size is not supported by GPUParticleSystem
  103984. return this;
  103985. };
  103986. /**
  103987. * Not supported by GPUParticleSystem
  103988. * @param gradient defines the gradient to remove
  103989. * @returns the current particle system
  103990. */
  103991. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  103992. // Do nothing as start size is not supported by GPUParticleSystem
  103993. return this;
  103994. };
  103995. /**
  103996. * Not supported by GPUParticleSystem
  103997. * @param gradient defines the gradient to use (between 0 and 1)
  103998. * @param min defines the alpha remap minimal range
  103999. * @param max defines the alpha remap maximal range
  104000. * @returns the current particle system
  104001. */
  104002. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  104003. // Do nothing as start size is not supported by GPUParticleSystem
  104004. return this;
  104005. };
  104006. /**
  104007. * Not supported by GPUParticleSystem
  104008. * @param gradient defines the gradient to remove
  104009. * @returns the current particle system
  104010. */
  104011. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  104012. // Do nothing as start size is not supported by GPUParticleSystem
  104013. return this;
  104014. };
  104015. /**
  104016. * Not supported by GPUParticleSystem
  104017. * @param gradient defines the gradient to use (between 0 and 1)
  104018. * @param color defines the color to affect to the specified gradient
  104019. * @returns the current particle system
  104020. */
  104021. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  104022. //Not supported by GPUParticleSystem
  104023. return this;
  104024. };
  104025. /**
  104026. * Not supported by GPUParticleSystem
  104027. * @param gradient defines the gradient to remove
  104028. * @returns the current particle system
  104029. */
  104030. GPUParticleSystem.prototype.removeRampGradient = function () {
  104031. //Not supported by GPUParticleSystem
  104032. return this;
  104033. };
  104034. /**
  104035. * Not supported by GPUParticleSystem
  104036. * @returns the list of ramp gradients
  104037. */
  104038. GPUParticleSystem.prototype.getRampGradients = function () {
  104039. return null;
  104040. };
  104041. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  104042. /**
  104043. * Not supported by GPUParticleSystem
  104044. * Gets or sets a boolean indicating that ramp gradients must be used
  104045. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104046. */
  104047. get: function () {
  104048. //Not supported by GPUParticleSystem
  104049. return false;
  104050. },
  104051. set: function (value) {
  104052. //Not supported by GPUParticleSystem
  104053. },
  104054. enumerable: true,
  104055. configurable: true
  104056. });
  104057. /**
  104058. * Not supported by GPUParticleSystem
  104059. * @param gradient defines the gradient to use (between 0 and 1)
  104060. * @param factor defines the life time factor to affect to the specified gradient
  104061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104062. * @returns the current particle system
  104063. */
  104064. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  104065. //Not supported by GPUParticleSystem
  104066. return this;
  104067. };
  104068. /**
  104069. * Not supported by GPUParticleSystem
  104070. * @param gradient defines the gradient to remove
  104071. * @returns the current particle system
  104072. */
  104073. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  104074. //Not supported by GPUParticleSystem
  104075. return this;
  104076. };
  104077. GPUParticleSystem.prototype._reset = function () {
  104078. this._releaseBuffers();
  104079. };
  104080. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  104081. var updateVertexBuffers = {};
  104082. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  104083. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  104084. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  104085. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  104086. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  104087. var offset = 12;
  104088. if (!this._colorGradientsTexture) {
  104089. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  104090. offset += 4;
  104091. }
  104092. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  104093. offset += 3;
  104094. if (!this._isBillboardBased) {
  104095. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  104096. offset += 3;
  104097. }
  104098. if (this._angularSpeedGradientsTexture) {
  104099. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  104100. offset += 1;
  104101. }
  104102. else {
  104103. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  104104. offset += 2;
  104105. }
  104106. if (this._isAnimationSheetEnabled) {
  104107. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  104108. offset += 1;
  104109. if (this.spriteRandomStartCell) {
  104110. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  104111. offset += 1;
  104112. }
  104113. }
  104114. if (this.noiseTexture) {
  104115. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  104116. offset += 3;
  104117. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  104118. offset += 3;
  104119. }
  104120. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  104121. this._engine.bindArrayBuffer(null);
  104122. return vao;
  104123. };
  104124. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  104125. var renderVertexBuffers = {};
  104126. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  104127. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  104128. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  104129. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  104130. var offset = 12;
  104131. if (!this._colorGradientsTexture) {
  104132. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  104133. offset += 4;
  104134. }
  104135. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  104136. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  104137. }
  104138. offset += 3; // Direction
  104139. if (!this._isBillboardBased) {
  104140. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  104141. offset += 3;
  104142. }
  104143. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  104144. if (this._angularSpeedGradientsTexture) {
  104145. offset++;
  104146. }
  104147. else {
  104148. offset += 2;
  104149. }
  104150. if (this._isAnimationSheetEnabled) {
  104151. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  104152. offset += 1;
  104153. if (this.spriteRandomStartCell) {
  104154. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  104155. offset += 1;
  104156. }
  104157. }
  104158. if (this.noiseTexture) {
  104159. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  104160. offset += 3;
  104161. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  104162. offset += 3;
  104163. }
  104164. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  104165. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  104166. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  104167. this._engine.bindArrayBuffer(null);
  104168. return vao;
  104169. };
  104170. GPUParticleSystem.prototype._initialize = function (force) {
  104171. if (force === void 0) { force = false; }
  104172. if (this._buffer0 && !force) {
  104173. return;
  104174. }
  104175. var engine = this._scene.getEngine();
  104176. var data = new Array();
  104177. this._attributesStrideSize = 21;
  104178. this._targetIndex = 0;
  104179. if (!this.isBillboardBased) {
  104180. this._attributesStrideSize += 3;
  104181. }
  104182. if (this._colorGradientsTexture) {
  104183. this._attributesStrideSize -= 4;
  104184. }
  104185. if (this._angularSpeedGradientsTexture) {
  104186. this._attributesStrideSize -= 1;
  104187. }
  104188. if (this._isAnimationSheetEnabled) {
  104189. this._attributesStrideSize += 1;
  104190. if (this.spriteRandomStartCell) {
  104191. this._attributesStrideSize += 1;
  104192. }
  104193. }
  104194. if (this.noiseTexture) {
  104195. this._attributesStrideSize += 6;
  104196. }
  104197. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  104198. // position
  104199. data.push(0.0);
  104200. data.push(0.0);
  104201. data.push(0.0);
  104202. // Age and life
  104203. data.push(0.0); // create the particle as a dead one to create a new one at start
  104204. data.push(0.0);
  104205. // Seed
  104206. data.push(Math.random());
  104207. data.push(Math.random());
  104208. data.push(Math.random());
  104209. data.push(Math.random());
  104210. // Size
  104211. data.push(0.0);
  104212. data.push(0.0);
  104213. data.push(0.0);
  104214. if (!this._colorGradientsTexture) {
  104215. // color
  104216. data.push(0.0);
  104217. data.push(0.0);
  104218. data.push(0.0);
  104219. data.push(0.0);
  104220. }
  104221. // direction
  104222. data.push(0.0);
  104223. data.push(0.0);
  104224. data.push(0.0);
  104225. if (!this.isBillboardBased) {
  104226. // initialDirection
  104227. data.push(0.0);
  104228. data.push(0.0);
  104229. data.push(0.0);
  104230. }
  104231. // angle
  104232. data.push(0.0);
  104233. if (!this._angularSpeedGradientsTexture) {
  104234. data.push(0.0);
  104235. }
  104236. if (this._isAnimationSheetEnabled) {
  104237. data.push(0.0);
  104238. if (this.spriteRandomStartCell) {
  104239. data.push(0.0);
  104240. }
  104241. }
  104242. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  104243. data.push(Math.random());
  104244. data.push(Math.random());
  104245. data.push(Math.random());
  104246. data.push(Math.random());
  104247. data.push(Math.random());
  104248. data.push(Math.random());
  104249. }
  104250. }
  104251. // Sprite data
  104252. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  104253. -0.5, 0.5, 0, 1,
  104254. -0.5, -0.5, 0, 0,
  104255. 0.5, -0.5, 1, 0]);
  104256. // Buffers
  104257. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104258. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104259. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  104260. // Update VAO
  104261. this._updateVAO = [];
  104262. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  104263. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  104264. // Render VAO
  104265. this._renderVAO = [];
  104266. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  104267. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  104268. // Links
  104269. this._sourceBuffer = this._buffer0;
  104270. this._targetBuffer = this._buffer1;
  104271. };
  104272. /** @hidden */
  104273. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  104274. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  104275. if (this._isBillboardBased) {
  104276. defines += "\n#define BILLBOARD";
  104277. }
  104278. if (this._colorGradientsTexture) {
  104279. defines += "\n#define COLORGRADIENTS";
  104280. }
  104281. if (this._sizeGradientsTexture) {
  104282. defines += "\n#define SIZEGRADIENTS";
  104283. }
  104284. if (this._angularSpeedGradientsTexture) {
  104285. defines += "\n#define ANGULARSPEEDGRADIENTS";
  104286. }
  104287. if (this._velocityGradientsTexture) {
  104288. defines += "\n#define VELOCITYGRADIENTS";
  104289. }
  104290. if (this._limitVelocityGradientsTexture) {
  104291. defines += "\n#define LIMITVELOCITYGRADIENTS";
  104292. }
  104293. if (this._dragGradientsTexture) {
  104294. defines += "\n#define DRAGGRADIENTS";
  104295. }
  104296. if (this.isAnimationSheetEnabled) {
  104297. defines += "\n#define ANIMATESHEET";
  104298. if (this.spriteRandomStartCell) {
  104299. defines += "\n#define ANIMATESHEETRANDOMSTART";
  104300. }
  104301. }
  104302. if (this.noiseTexture) {
  104303. defines += "\n#define NOISE";
  104304. }
  104305. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  104306. return;
  104307. }
  104308. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  104309. if (!this._colorGradientsTexture) {
  104310. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  104311. }
  104312. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  104313. if (!this._isBillboardBased) {
  104314. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  104315. }
  104316. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  104317. if (this.isAnimationSheetEnabled) {
  104318. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  104319. if (this.spriteRandomStartCell) {
  104320. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  104321. }
  104322. }
  104323. if (this.noiseTexture) {
  104324. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  104325. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  104326. }
  104327. this._updateEffectOptions.defines = defines;
  104328. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  104329. };
  104330. /** @hidden */
  104331. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  104332. var defines = "";
  104333. if (this._scene.clipPlane) {
  104334. defines = "\n#define CLIPPLANE";
  104335. }
  104336. if (this._scene.clipPlane2) {
  104337. defines = "\n#define CLIPPLANE2";
  104338. }
  104339. if (this._scene.clipPlane3) {
  104340. defines = "\n#define CLIPPLANE3";
  104341. }
  104342. if (this._scene.clipPlane4) {
  104343. defines = "\n#define CLIPPLANE4";
  104344. }
  104345. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  104346. defines = "\n#define BLENDMULTIPLYMODE";
  104347. }
  104348. if (this._isBillboardBased) {
  104349. defines += "\n#define BILLBOARD";
  104350. switch (this.billboardMode) {
  104351. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  104352. defines += "\n#define BILLBOARDY";
  104353. break;
  104354. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  104355. defines += "\n#define BILLBOARDSTRETCHED";
  104356. break;
  104357. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  104358. default:
  104359. break;
  104360. }
  104361. }
  104362. if (this._colorGradientsTexture) {
  104363. defines += "\n#define COLORGRADIENTS";
  104364. }
  104365. if (this.isAnimationSheetEnabled) {
  104366. defines += "\n#define ANIMATESHEET";
  104367. }
  104368. if (this._imageProcessingConfiguration) {
  104369. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  104370. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  104371. }
  104372. if (this._renderEffect && this._renderEffect.defines === defines) {
  104373. return;
  104374. }
  104375. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  104376. var samplers = ["textureSampler", "colorGradientSampler"];
  104377. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  104378. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  104379. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  104380. }
  104381. 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);
  104382. };
  104383. /**
  104384. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104385. * @param preWarm defines if we are in the pre-warmimg phase
  104386. */
  104387. GPUParticleSystem.prototype.animate = function (preWarm) {
  104388. if (preWarm === void 0) { preWarm = false; }
  104389. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  104390. this._actualFrame += this._timeDelta;
  104391. if (!this._stopped) {
  104392. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  104393. this.stop();
  104394. }
  104395. }
  104396. };
  104397. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  104398. var texture = this[textureName];
  104399. if (!factorGradients || !factorGradients.length || texture) {
  104400. return;
  104401. }
  104402. var data = new Float32Array(this._rawTextureWidth);
  104403. for (var x = 0; x < this._rawTextureWidth; x++) {
  104404. var ratio = x / this._rawTextureWidth;
  104405. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  104406. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104407. });
  104408. }
  104409. 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);
  104410. };
  104411. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  104412. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  104413. };
  104414. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  104415. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  104416. };
  104417. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  104418. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  104419. };
  104420. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  104421. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  104422. };
  104423. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  104424. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  104425. };
  104426. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  104427. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  104428. return;
  104429. }
  104430. var data = new Uint8Array(this._rawTextureWidth * 4);
  104431. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  104432. for (var x = 0; x < this._rawTextureWidth; x++) {
  104433. var ratio = x / this._rawTextureWidth;
  104434. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  104435. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  104436. data[x * 4] = tmpColor.r * 255;
  104437. data[x * 4 + 1] = tmpColor.g * 255;
  104438. data[x * 4 + 2] = tmpColor.b * 255;
  104439. data[x * 4 + 3] = tmpColor.a * 255;
  104440. });
  104441. }
  104442. 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);
  104443. };
  104444. /**
  104445. * Renders the particle system in its current state
  104446. * @param preWarm defines if the system should only update the particles but not render them
  104447. * @returns the current number of particles
  104448. */
  104449. GPUParticleSystem.prototype.render = function (preWarm) {
  104450. if (preWarm === void 0) { preWarm = false; }
  104451. if (!this._started) {
  104452. return 0;
  104453. }
  104454. this._createColorGradientTexture();
  104455. this._createSizeGradientTexture();
  104456. this._createAngularSpeedGradientTexture();
  104457. this._createVelocityGradientTexture();
  104458. this._createLimitVelocityGradientTexture();
  104459. this._createDragGradientTexture();
  104460. this._recreateUpdateEffect();
  104461. this._recreateRenderEffect();
  104462. if (!this.isReady()) {
  104463. return 0;
  104464. }
  104465. if (!preWarm) {
  104466. if (!this._preWarmDone && this.preWarmCycles) {
  104467. for (var index = 0; index < this.preWarmCycles; index++) {
  104468. this.animate(true);
  104469. this.render(true);
  104470. }
  104471. this._preWarmDone = true;
  104472. }
  104473. if (this._currentRenderId === this._scene.getFrameId()) {
  104474. return 0;
  104475. }
  104476. this._currentRenderId = this._scene.getFrameId();
  104477. }
  104478. // Get everything ready to render
  104479. this._initialize();
  104480. this._accumulatedCount += this.emitRate * this._timeDelta;
  104481. if (this._accumulatedCount > 1) {
  104482. var intPart = this._accumulatedCount | 0;
  104483. this._accumulatedCount -= intPart;
  104484. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  104485. }
  104486. if (!this._currentActiveCount) {
  104487. return 0;
  104488. }
  104489. // Enable update effect
  104490. this._engine.enableEffect(this._updateEffect);
  104491. this._engine.setState(false);
  104492. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  104493. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  104494. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  104495. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  104496. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  104497. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  104498. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  104499. if (!this._colorGradientsTexture) {
  104500. this._updateEffect.setDirectColor4("color1", this.color1);
  104501. this._updateEffect.setDirectColor4("color2", this.color2);
  104502. }
  104503. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  104504. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  104505. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  104506. this._updateEffect.setVector3("gravity", this.gravity);
  104507. if (this._sizeGradientsTexture) {
  104508. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  104509. }
  104510. if (this._angularSpeedGradientsTexture) {
  104511. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  104512. }
  104513. if (this._velocityGradientsTexture) {
  104514. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  104515. }
  104516. if (this._limitVelocityGradientsTexture) {
  104517. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  104518. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  104519. }
  104520. if (this._dragGradientsTexture) {
  104521. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  104522. }
  104523. if (this.particleEmitterType) {
  104524. this.particleEmitterType.applyToShader(this._updateEffect);
  104525. }
  104526. if (this._isAnimationSheetEnabled) {
  104527. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  104528. }
  104529. if (this.noiseTexture) {
  104530. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  104531. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  104532. }
  104533. var emitterWM;
  104534. if (this.emitter.position) {
  104535. var emitterMesh = this.emitter;
  104536. emitterWM = emitterMesh.getWorldMatrix();
  104537. }
  104538. else {
  104539. var emitterPosition = this.emitter;
  104540. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  104541. }
  104542. this._updateEffect.setMatrix("emitterWM", emitterWM);
  104543. // Bind source VAO
  104544. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  104545. // Update
  104546. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  104547. this._engine.setRasterizerState(false);
  104548. this._engine.beginTransformFeedback(true);
  104549. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  104550. this._engine.endTransformFeedback();
  104551. this._engine.setRasterizerState(true);
  104552. this._engine.bindTransformFeedbackBuffer(null);
  104553. if (!preWarm) {
  104554. // Enable render effect
  104555. this._engine.enableEffect(this._renderEffect);
  104556. var viewMatrix = this._scene.getViewMatrix();
  104557. this._renderEffect.setMatrix("view", viewMatrix);
  104558. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  104559. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  104560. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  104561. if (this._colorGradientsTexture) {
  104562. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  104563. }
  104564. else {
  104565. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  104566. }
  104567. if (this._isAnimationSheetEnabled && this.particleTexture) {
  104568. var baseSize = this.particleTexture.getBaseSize();
  104569. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  104570. }
  104571. if (this._isBillboardBased) {
  104572. var camera = this._scene.activeCamera;
  104573. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  104574. }
  104575. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  104576. var invView = viewMatrix.clone();
  104577. invView.invert();
  104578. this._renderEffect.setMatrix("invView", invView);
  104579. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  104580. }
  104581. // image processing
  104582. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  104583. this._imageProcessingConfiguration.bind(this._renderEffect);
  104584. }
  104585. // Draw order
  104586. switch (this.blendMode) {
  104587. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  104588. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  104589. break;
  104590. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  104591. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  104592. break;
  104593. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  104594. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  104595. break;
  104596. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  104597. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  104598. break;
  104599. }
  104600. if (this.forceDepthWrite) {
  104601. this._engine.setDepthWrite(true);
  104602. }
  104603. // Bind source VAO
  104604. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  104605. // Render
  104606. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  104607. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  104608. }
  104609. // Switch VAOs
  104610. this._targetIndex++;
  104611. if (this._targetIndex === 2) {
  104612. this._targetIndex = 0;
  104613. }
  104614. // Switch buffers
  104615. var tmpBuffer = this._sourceBuffer;
  104616. this._sourceBuffer = this._targetBuffer;
  104617. this._targetBuffer = tmpBuffer;
  104618. return this._currentActiveCount;
  104619. };
  104620. /**
  104621. * Rebuilds the particle system
  104622. */
  104623. GPUParticleSystem.prototype.rebuild = function () {
  104624. this._initialize(true);
  104625. };
  104626. GPUParticleSystem.prototype._releaseBuffers = function () {
  104627. if (this._buffer0) {
  104628. this._buffer0.dispose();
  104629. this._buffer0 = null;
  104630. }
  104631. if (this._buffer1) {
  104632. this._buffer1.dispose();
  104633. this._buffer1 = null;
  104634. }
  104635. if (this._spriteBuffer) {
  104636. this._spriteBuffer.dispose();
  104637. this._spriteBuffer = null;
  104638. }
  104639. };
  104640. GPUParticleSystem.prototype._releaseVAOs = function () {
  104641. if (!this._updateVAO) {
  104642. return;
  104643. }
  104644. for (var index = 0; index < this._updateVAO.length; index++) {
  104645. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  104646. }
  104647. this._updateVAO = [];
  104648. for (var index = 0; index < this._renderVAO.length; index++) {
  104649. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  104650. }
  104651. this._renderVAO = [];
  104652. };
  104653. /**
  104654. * Disposes the particle system and free the associated resources
  104655. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104656. */
  104657. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  104658. if (disposeTexture === void 0) { disposeTexture = true; }
  104659. var index = this._scene.particleSystems.indexOf(this);
  104660. if (index > -1) {
  104661. this._scene.particleSystems.splice(index, 1);
  104662. }
  104663. this._releaseBuffers();
  104664. this._releaseVAOs();
  104665. if (this._colorGradientsTexture) {
  104666. this._colorGradientsTexture.dispose();
  104667. this._colorGradientsTexture = null;
  104668. }
  104669. if (this._sizeGradientsTexture) {
  104670. this._sizeGradientsTexture.dispose();
  104671. this._sizeGradientsTexture = null;
  104672. }
  104673. if (this._angularSpeedGradientsTexture) {
  104674. this._angularSpeedGradientsTexture.dispose();
  104675. this._angularSpeedGradientsTexture = null;
  104676. }
  104677. if (this._velocityGradientsTexture) {
  104678. this._velocityGradientsTexture.dispose();
  104679. this._velocityGradientsTexture = null;
  104680. }
  104681. if (this._limitVelocityGradientsTexture) {
  104682. this._limitVelocityGradientsTexture.dispose();
  104683. this._limitVelocityGradientsTexture = null;
  104684. }
  104685. if (this._dragGradientsTexture) {
  104686. this._dragGradientsTexture.dispose();
  104687. this._dragGradientsTexture = null;
  104688. }
  104689. if (this._randomTexture) {
  104690. this._randomTexture.dispose();
  104691. this._randomTexture = null;
  104692. }
  104693. if (this._randomTexture2) {
  104694. this._randomTexture2.dispose();
  104695. this._randomTexture2 = null;
  104696. }
  104697. if (disposeTexture && this.particleTexture) {
  104698. this.particleTexture.dispose();
  104699. this.particleTexture = null;
  104700. }
  104701. if (disposeTexture && this.noiseTexture) {
  104702. this.noiseTexture.dispose();
  104703. this.noiseTexture = null;
  104704. }
  104705. // Callback
  104706. this.onDisposeObservable.notifyObservers(this);
  104707. this.onDisposeObservable.clear();
  104708. };
  104709. /**
  104710. * Clones the particle system.
  104711. * @param name The name of the cloned object
  104712. * @param newEmitter The new emitter to use
  104713. * @returns the cloned particle system
  104714. */
  104715. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  104716. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  104717. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  104718. if (newEmitter === undefined) {
  104719. newEmitter = this.emitter;
  104720. }
  104721. result.emitter = newEmitter;
  104722. if (this.particleTexture) {
  104723. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  104724. }
  104725. return result;
  104726. };
  104727. /**
  104728. * Serializes the particle system to a JSON object.
  104729. * @returns the JSON object
  104730. */
  104731. GPUParticleSystem.prototype.serialize = function () {
  104732. var serializationObject = {};
  104733. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  104734. serializationObject.activeParticleCount = this.activeParticleCount;
  104735. return serializationObject;
  104736. };
  104737. /**
  104738. * Parses a JSON object to create a GPU particle system.
  104739. * @param parsedParticleSystem The JSON object to parse
  104740. * @param scene The scene to create the particle system in
  104741. * @param rootUrl The root url to use to load external dependencies like texture
  104742. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104743. * @returns the parsed GPU particle system
  104744. */
  104745. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  104746. if (doNotStart === void 0) { doNotStart = false; }
  104747. var name = parsedParticleSystem.name;
  104748. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  104749. if (parsedParticleSystem.activeParticleCount) {
  104750. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  104751. }
  104752. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  104753. // Auto start
  104754. if (parsedParticleSystem.preventAutoStart) {
  104755. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  104756. }
  104757. if (!doNotStart && !particleSystem.preventAutoStart) {
  104758. particleSystem.start();
  104759. }
  104760. return particleSystem;
  104761. };
  104762. return GPUParticleSystem;
  104763. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  104764. /***/ }),
  104765. /***/ "./Particles/index.ts":
  104766. /*!****************************!*\
  104767. !*** ./Particles/index.ts ***!
  104768. \****************************/
  104769. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  104770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104771. "use strict";
  104772. __webpack_require__.r(__webpack_exports__);
  104773. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  104775. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  104777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  104778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  104779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  104780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  104781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  104782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  104783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  104784. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  104785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  104786. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  104787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  104788. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  104789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  104790. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  104792. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  104793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  104794. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  104795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  104796. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  104797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  104798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  104799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  104800. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  104801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  104802. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  104803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  104804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  104805. /***/ }),
  104806. /***/ "./Particles/particle.ts":
  104807. /*!*******************************!*\
  104808. !*** ./Particles/particle.ts ***!
  104809. \*******************************/
  104810. /*! exports provided: Particle */
  104811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104812. "use strict";
  104813. __webpack_require__.r(__webpack_exports__);
  104814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  104815. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104816. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104817. /**
  104818. * A particle represents one of the element emitted by a particle system.
  104819. * This is mainly define by its coordinates, direction, velocity and age.
  104820. */
  104821. var Particle = /** @class */ (function () {
  104822. /**
  104823. * Creates a new instance Particle
  104824. * @param particleSystem the particle system the particle belongs to
  104825. */
  104826. function Particle(
  104827. /**
  104828. * The particle system the particle belongs to.
  104829. */
  104830. particleSystem) {
  104831. this.particleSystem = particleSystem;
  104832. /**
  104833. * The world position of the particle in the scene.
  104834. */
  104835. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104836. /**
  104837. * The world direction of the particle in the scene.
  104838. */
  104839. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104840. /**
  104841. * The color of the particle.
  104842. */
  104843. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104844. /**
  104845. * The color change of the particle per step.
  104846. */
  104847. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104848. /**
  104849. * Defines how long will the life of the particle be.
  104850. */
  104851. this.lifeTime = 1.0;
  104852. /**
  104853. * The current age of the particle.
  104854. */
  104855. this.age = 0;
  104856. /**
  104857. * The current size of the particle.
  104858. */
  104859. this.size = 0;
  104860. /**
  104861. * The current scale of the particle.
  104862. */
  104863. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  104864. /**
  104865. * The current angle of the particle.
  104866. */
  104867. this.angle = 0;
  104868. /**
  104869. * Defines how fast is the angle changing.
  104870. */
  104871. this.angularSpeed = 0;
  104872. /**
  104873. * Defines the cell index used by the particle to be rendered from a sprite.
  104874. */
  104875. this.cellIndex = 0;
  104876. /** @hidden */
  104877. this._attachedSubEmitters = null;
  104878. /** @hidden */
  104879. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104880. /** @hidden */
  104881. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104882. /** @hidden */
  104883. this._currentSize1 = 0;
  104884. /** @hidden */
  104885. this._currentSize2 = 0;
  104886. /** @hidden */
  104887. this._currentAngularSpeed1 = 0;
  104888. /** @hidden */
  104889. this._currentAngularSpeed2 = 0;
  104890. /** @hidden */
  104891. this._currentVelocity1 = 0;
  104892. /** @hidden */
  104893. this._currentVelocity2 = 0;
  104894. /** @hidden */
  104895. this._currentLimitVelocity1 = 0;
  104896. /** @hidden */
  104897. this._currentLimitVelocity2 = 0;
  104898. /** @hidden */
  104899. this._currentDrag1 = 0;
  104900. /** @hidden */
  104901. this._currentDrag2 = 0;
  104902. this.id = Particle._Count++;
  104903. if (!this.particleSystem.isAnimationSheetEnabled) {
  104904. return;
  104905. }
  104906. this.updateCellInfoFromSystem();
  104907. }
  104908. Particle.prototype.updateCellInfoFromSystem = function () {
  104909. this.cellIndex = this.particleSystem.startSpriteCellID;
  104910. };
  104911. /**
  104912. * Defines how the sprite cell index is updated for the particle
  104913. */
  104914. Particle.prototype.updateCellIndex = function () {
  104915. var offsetAge = this.age;
  104916. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  104917. if (this.particleSystem.spriteRandomStartCell) {
  104918. if (this._randomCellOffset === undefined) {
  104919. this._randomCellOffset = Math.random() * this.lifeTime;
  104920. }
  104921. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  104922. changeSpeed = 1;
  104923. offsetAge = this._randomCellOffset;
  104924. }
  104925. else {
  104926. offsetAge += this._randomCellOffset;
  104927. }
  104928. }
  104929. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  104930. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  104931. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  104932. };
  104933. /** @hidden */
  104934. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  104935. if (subEmitter.particleSystem.emitter.position) {
  104936. var emitterMesh = subEmitter.particleSystem.emitter;
  104937. emitterMesh.position.copyFrom(this.position);
  104938. if (subEmitter.inheritDirection) {
  104939. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104940. // Look at using Y as forward
  104941. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  104942. }
  104943. }
  104944. else {
  104945. var emitterPosition = subEmitter.particleSystem.emitter;
  104946. emitterPosition.copyFrom(this.position);
  104947. }
  104948. // Set inheritedVelocityOffset to be used when new particles are created
  104949. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104950. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104951. };
  104952. /** @hidden */
  104953. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  104954. var _this = this;
  104955. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  104956. this._attachedSubEmitters.forEach(function (subEmitter) {
  104957. _this._inheritParticleInfoToSubEmitter(subEmitter);
  104958. });
  104959. }
  104960. };
  104961. /** @hidden */
  104962. Particle.prototype._reset = function () {
  104963. this.age = 0;
  104964. this._currentColorGradient = null;
  104965. this._currentSizeGradient = null;
  104966. this._currentAngularSpeedGradient = null;
  104967. this._currentVelocityGradient = null;
  104968. this._currentLimitVelocityGradient = null;
  104969. this._currentDragGradient = null;
  104970. this.cellIndex = this.particleSystem.startSpriteCellID;
  104971. this._randomCellOffset = undefined;
  104972. };
  104973. /**
  104974. * Copy the properties of particle to another one.
  104975. * @param other the particle to copy the information to.
  104976. */
  104977. Particle.prototype.copyTo = function (other) {
  104978. other.position.copyFrom(this.position);
  104979. if (this._initialDirection) {
  104980. if (other._initialDirection) {
  104981. other._initialDirection.copyFrom(this._initialDirection);
  104982. }
  104983. else {
  104984. other._initialDirection = this._initialDirection.clone();
  104985. }
  104986. }
  104987. else {
  104988. other._initialDirection = null;
  104989. }
  104990. other.direction.copyFrom(this.direction);
  104991. other.color.copyFrom(this.color);
  104992. other.colorStep.copyFrom(this.colorStep);
  104993. other.lifeTime = this.lifeTime;
  104994. other.age = this.age;
  104995. other._randomCellOffset = this._randomCellOffset;
  104996. other.size = this.size;
  104997. other.scale.copyFrom(this.scale);
  104998. other.angle = this.angle;
  104999. other.angularSpeed = this.angularSpeed;
  105000. other.particleSystem = this.particleSystem;
  105001. other.cellIndex = this.cellIndex;
  105002. other.id = this.id;
  105003. other._attachedSubEmitters = this._attachedSubEmitters;
  105004. if (this._currentColorGradient) {
  105005. other._currentColorGradient = this._currentColorGradient;
  105006. other._currentColor1.copyFrom(this._currentColor1);
  105007. other._currentColor2.copyFrom(this._currentColor2);
  105008. }
  105009. if (this._currentSizeGradient) {
  105010. other._currentSizeGradient = this._currentSizeGradient;
  105011. other._currentSize1 = this._currentSize1;
  105012. other._currentSize2 = this._currentSize2;
  105013. }
  105014. if (this._currentAngularSpeedGradient) {
  105015. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  105016. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  105017. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  105018. }
  105019. if (this._currentVelocityGradient) {
  105020. other._currentVelocityGradient = this._currentVelocityGradient;
  105021. other._currentVelocity1 = this._currentVelocity1;
  105022. other._currentVelocity2 = this._currentVelocity2;
  105023. }
  105024. if (this._currentLimitVelocityGradient) {
  105025. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  105026. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  105027. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  105028. }
  105029. if (this._currentDragGradient) {
  105030. other._currentDragGradient = this._currentDragGradient;
  105031. other._currentDrag1 = this._currentDrag1;
  105032. other._currentDrag2 = this._currentDrag2;
  105033. }
  105034. if (this.particleSystem.isAnimationSheetEnabled) {
  105035. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  105036. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  105037. }
  105038. if (this.particleSystem.useRampGradients) {
  105039. other.remapData.copyFrom(this.remapData);
  105040. }
  105041. if (this._randomNoiseCoordinates1) {
  105042. if (other._randomNoiseCoordinates1) {
  105043. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  105044. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  105045. }
  105046. else {
  105047. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  105048. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  105049. }
  105050. }
  105051. };
  105052. Particle._Count = 0;
  105053. return Particle;
  105054. }());
  105055. /***/ }),
  105056. /***/ "./Particles/particleHelper.ts":
  105057. /*!*************************************!*\
  105058. !*** ./Particles/particleHelper.ts ***!
  105059. \*************************************/
  105060. /*! exports provided: ParticleHelper */
  105061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105062. "use strict";
  105063. __webpack_require__.r(__webpack_exports__);
  105064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  105065. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105066. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105067. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105068. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105069. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  105070. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  105071. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  105072. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105073. /**
  105074. * This class is made for on one-liner static method to help creating particle system set.
  105075. */
  105076. var ParticleHelper = /** @class */ (function () {
  105077. function ParticleHelper() {
  105078. }
  105079. /**
  105080. * Create a default particle system that you can tweak
  105081. * @param emitter defines the emitter to use
  105082. * @param capacity defines the system capacity (default is 500 particles)
  105083. * @param scene defines the hosting scene
  105084. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105085. * @returns the new Particle system
  105086. */
  105087. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  105088. if (capacity === void 0) { capacity = 500; }
  105089. if (useGPU === void 0) { useGPU = false; }
  105090. var system;
  105091. if (useGPU) {
  105092. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  105093. }
  105094. else {
  105095. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  105096. }
  105097. system.emitter = emitter;
  105098. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  105099. system.createConeEmitter(0.1, Math.PI / 4);
  105100. // Particle color
  105101. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  105102. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  105103. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  105104. // Particle Size
  105105. system.minSize = 0.1;
  105106. system.maxSize = 0.1;
  105107. // Emission speed
  105108. system.minEmitPower = 2;
  105109. system.maxEmitPower = 2;
  105110. // Update speed
  105111. system.updateSpeed = 1 / 60;
  105112. system.emitRate = 30;
  105113. return system;
  105114. };
  105115. /**
  105116. * This is the main static method (one-liner) of this helper to create different particle systems
  105117. * @param type This string represents the type to the particle system to create
  105118. * @param scene The scene where the particle system should live
  105119. * @param gpu If the system will use gpu
  105120. * @returns the ParticleSystemSet created
  105121. */
  105122. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  105123. if (gpu === void 0) { gpu = false; }
  105124. if (!scene) {
  105125. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  105126. }
  105127. var token = {};
  105128. scene._addPendingData(token);
  105129. return new Promise(function (resolve, reject) {
  105130. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  105131. scene._removePendingData(token);
  105132. return reject("Particle system with GPU is not supported.");
  105133. }
  105134. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  105135. scene._removePendingData(token);
  105136. var newData = JSON.parse(data.toString());
  105137. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  105138. }, undefined, undefined, undefined, function () {
  105139. scene._removePendingData(token);
  105140. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  105141. });
  105142. });
  105143. };
  105144. /**
  105145. * Static function used to export a particle system to a ParticleSystemSet variable.
  105146. * Please note that the emitter shape is not exported
  105147. * @param systems defines the particle systems to export
  105148. * @returns the created particle system set
  105149. */
  105150. ParticleHelper.ExportSet = function (systems) {
  105151. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  105152. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  105153. var system = systems_1[_i];
  105154. set.systems.push(system);
  105155. }
  105156. return set;
  105157. };
  105158. /**
  105159. * Gets or sets base Assets URL
  105160. */
  105161. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  105162. return ParticleHelper;
  105163. }());
  105164. /***/ }),
  105165. /***/ "./Particles/particleSystem.ts":
  105166. /*!*************************************!*\
  105167. !*** ./Particles/particleSystem.ts ***!
  105168. \*************************************/
  105169. /*! exports provided: ParticleSystem */
  105170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105171. "use strict";
  105172. __webpack_require__.r(__webpack_exports__);
  105173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  105174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105175. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105176. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105177. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105178. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105179. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105180. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  105181. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  105182. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  105183. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  105184. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105185. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  105186. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  105187. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105188. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  105189. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  105190. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  105191. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  105192. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105193. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105194. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105195. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  105196. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  105197. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  105198. /**
  105199. * This represents a particle system in Babylon.
  105200. * 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.
  105201. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  105202. * @example https://doc.babylonjs.com/babylon101/particles
  105203. */
  105204. var ParticleSystem = /** @class */ (function (_super) {
  105205. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  105206. /**
  105207. * Instantiates a particle system.
  105208. * 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.
  105209. * @param name The name of the particle system
  105210. * @param capacity The max number of particles alive at the same time
  105211. * @param scene The scene the particle system belongs to
  105212. * @param customEffect a custom effect used to change the way particles are rendered by default
  105213. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105214. * @param epsilon Offset used to render the particles
  105215. */
  105216. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  105217. if (customEffect === void 0) { customEffect = null; }
  105218. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105219. if (epsilon === void 0) { epsilon = 0.01; }
  105220. var _this = _super.call(this, name) || this;
  105221. /**
  105222. * @hidden
  105223. */
  105224. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  105225. /**
  105226. * An event triggered when the system is disposed
  105227. */
  105228. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  105229. _this._particles = new Array();
  105230. _this._stockParticles = new Array();
  105231. _this._newPartsExcess = 0;
  105232. _this._vertexBuffers = {};
  105233. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105234. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105235. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105236. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105237. _this._currentRenderId = -1;
  105238. _this._useInstancing = false;
  105239. _this._started = false;
  105240. _this._stopped = false;
  105241. _this._actualFrame = 0;
  105242. /** @hidden */
  105243. _this._currentEmitRate1 = 0;
  105244. /** @hidden */
  105245. _this._currentEmitRate2 = 0;
  105246. /** @hidden */
  105247. _this._currentStartSize1 = 0;
  105248. /** @hidden */
  105249. _this._currentStartSize2 = 0;
  105250. _this._rawTextureWidth = 256;
  105251. _this._useRampGradients = false;
  105252. /**
  105253. * @hidden
  105254. * If the particle systems emitter should be disposed when the particle system is disposed
  105255. */
  105256. _this._disposeEmitterOnDispose = false;
  105257. // start of sub system methods
  105258. /**
  105259. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  105260. * Its lifetime will start back at 0.
  105261. */
  105262. _this.recycleParticle = function (particle) {
  105263. // move particle from activeParticle list to stock particles
  105264. var lastParticle = _this._particles.pop();
  105265. if (lastParticle !== particle) {
  105266. lastParticle.copyTo(particle);
  105267. }
  105268. _this._stockParticles.push(lastParticle);
  105269. };
  105270. _this._createParticle = function () {
  105271. var particle;
  105272. if (_this._stockParticles.length !== 0) {
  105273. particle = _this._stockParticles.pop();
  105274. particle._reset();
  105275. }
  105276. else {
  105277. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  105278. }
  105279. // Attach emitters
  105280. if (_this._subEmitters && _this._subEmitters.length > 0) {
  105281. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  105282. particle._attachedSubEmitters = [];
  105283. subEmitters.forEach(function (subEmitter) {
  105284. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  105285. var newEmitter = subEmitter.clone();
  105286. particle._attachedSubEmitters.push(newEmitter);
  105287. newEmitter.particleSystem.start();
  105288. }
  105289. });
  105290. }
  105291. return particle;
  105292. };
  105293. _this._emitFromParticle = function (particle) {
  105294. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  105295. return;
  105296. }
  105297. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  105298. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  105299. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  105300. var subSystem = subEmitter.clone();
  105301. particle._inheritParticleInfoToSubEmitter(subSystem);
  105302. subSystem.particleSystem._rootParticleSystem = _this;
  105303. _this.activeSubSystems.push(subSystem.particleSystem);
  105304. subSystem.particleSystem.start();
  105305. }
  105306. });
  105307. };
  105308. _this._capacity = capacity;
  105309. _this._epsilon = epsilon;
  105310. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  105311. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  105312. // Setup the default processing configuration to the scene.
  105313. _this._attachImageProcessingConfiguration(null);
  105314. _this._customEffect = customEffect;
  105315. _this._scene.particleSystems.push(_this);
  105316. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  105317. _this._createIndexBuffer();
  105318. _this._createVertexBuffers();
  105319. // Default emitter type
  105320. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  105321. // Update
  105322. _this.updateFunction = function (particles) {
  105323. var noiseTextureSize = null;
  105324. var noiseTextureData = null;
  105325. if (_this.noiseTexture) { // We need to get texture data back to CPU
  105326. noiseTextureSize = _this.noiseTexture.getSize();
  105327. noiseTextureData = (_this.noiseTexture.getContent());
  105328. }
  105329. var _loop_1 = function () {
  105330. particle = particles[index];
  105331. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  105332. var previousAge = particle.age;
  105333. particle.age += scaledUpdateSpeed;
  105334. // Evaluate step to death
  105335. if (particle.age > particle.lifeTime) {
  105336. var diff = particle.age - previousAge;
  105337. var oldDiff = particle.lifeTime - previousAge;
  105338. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  105339. particle.age = particle.lifeTime;
  105340. }
  105341. var ratio = particle.age / particle.lifeTime;
  105342. // Color
  105343. if (_this._colorGradients && _this._colorGradients.length > 0) {
  105344. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  105345. if (currentGradient !== particle._currentColorGradient) {
  105346. particle._currentColor1.copyFrom(particle._currentColor2);
  105347. nextGradient.getColorToRef(particle._currentColor2);
  105348. particle._currentColorGradient = currentGradient;
  105349. }
  105350. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  105351. });
  105352. }
  105353. else {
  105354. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  105355. particle.color.addInPlace(_this._scaledColorStep);
  105356. if (particle.color.a < 0) {
  105357. particle.color.a = 0;
  105358. }
  105359. }
  105360. // Angular speed
  105361. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  105362. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  105363. if (currentGradient !== particle._currentAngularSpeedGradient) {
  105364. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  105365. particle._currentAngularSpeed2 = nextGradient.getFactor();
  105366. particle._currentAngularSpeedGradient = currentGradient;
  105367. }
  105368. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  105369. });
  105370. }
  105371. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  105372. // Direction
  105373. var directionScale = scaledUpdateSpeed;
  105374. /// Velocity
  105375. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  105376. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  105377. if (currentGradient !== particle._currentVelocityGradient) {
  105378. particle._currentVelocity1 = particle._currentVelocity2;
  105379. particle._currentVelocity2 = nextGradient.getFactor();
  105380. particle._currentVelocityGradient = currentGradient;
  105381. }
  105382. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  105383. });
  105384. }
  105385. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  105386. /// Limit velocity
  105387. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  105388. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  105389. if (currentGradient !== particle._currentLimitVelocityGradient) {
  105390. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  105391. particle._currentLimitVelocity2 = nextGradient.getFactor();
  105392. particle._currentLimitVelocityGradient = currentGradient;
  105393. }
  105394. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  105395. var currentVelocity = particle.direction.length();
  105396. if (currentVelocity > limitVelocity) {
  105397. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  105398. }
  105399. });
  105400. }
  105401. /// Drag
  105402. if (_this._dragGradients && _this._dragGradients.length > 0) {
  105403. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  105404. if (currentGradient !== particle._currentDragGradient) {
  105405. particle._currentDrag1 = particle._currentDrag2;
  105406. particle._currentDrag2 = nextGradient.getFactor();
  105407. particle._currentDragGradient = currentGradient;
  105408. }
  105409. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  105410. _this._scaledDirection.scaleInPlace(1.0 - drag);
  105411. });
  105412. }
  105413. particle.position.addInPlace(_this._scaledDirection);
  105414. // Noise
  105415. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  105416. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105417. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105418. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105419. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  105420. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  105421. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  105422. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  105423. particle.direction.addInPlace(scaledForce);
  105424. }
  105425. // Gravity
  105426. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  105427. particle.direction.addInPlace(_this._scaledGravity);
  105428. // Size
  105429. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  105430. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  105431. if (currentGradient !== particle._currentSizeGradient) {
  105432. particle._currentSize1 = particle._currentSize2;
  105433. particle._currentSize2 = nextGradient.getFactor();
  105434. particle._currentSizeGradient = currentGradient;
  105435. }
  105436. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  105437. });
  105438. }
  105439. // Remap data
  105440. if (_this._useRampGradients) {
  105441. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  105442. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  105443. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105444. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105445. particle.remapData.x = min;
  105446. particle.remapData.y = max - min;
  105447. });
  105448. }
  105449. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  105450. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  105451. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105452. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105453. particle.remapData.z = min;
  105454. particle.remapData.w = max - min;
  105455. });
  105456. }
  105457. }
  105458. if (_this._isAnimationSheetEnabled) {
  105459. particle.updateCellIndex();
  105460. }
  105461. // Update the position of the attached sub-emitters to match their attached particle
  105462. particle._inheritParticleInfoToSubEmitters();
  105463. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  105464. _this._emitFromParticle(particle);
  105465. if (particle._attachedSubEmitters) {
  105466. particle._attachedSubEmitters.forEach(function (subEmitter) {
  105467. subEmitter.particleSystem.disposeOnStop = true;
  105468. subEmitter.particleSystem.stop();
  105469. });
  105470. particle._attachedSubEmitters = null;
  105471. }
  105472. _this.recycleParticle(particle);
  105473. index--;
  105474. return "continue";
  105475. }
  105476. };
  105477. var particle;
  105478. for (var index = 0; index < particles.length; index++) {
  105479. _loop_1();
  105480. }
  105481. };
  105482. return _this;
  105483. }
  105484. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  105485. /**
  105486. * Sets a callback that will be triggered when the system is disposed
  105487. */
  105488. set: function (callback) {
  105489. if (this._onDisposeObserver) {
  105490. this.onDisposeObservable.remove(this._onDisposeObserver);
  105491. }
  105492. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  105493. },
  105494. enumerable: true,
  105495. configurable: true
  105496. });
  105497. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  105498. /** Gets or sets a boolean indicating that ramp gradients must be used
  105499. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105500. */
  105501. get: function () {
  105502. return this._useRampGradients;
  105503. },
  105504. set: function (value) {
  105505. if (this._useRampGradients === value) {
  105506. return;
  105507. }
  105508. this._useRampGradients = value;
  105509. this._resetEffect();
  105510. },
  105511. enumerable: true,
  105512. configurable: true
  105513. });
  105514. Object.defineProperty(ParticleSystem.prototype, "particles", {
  105515. //end of Sub-emitter
  105516. /**
  105517. * Gets the current list of active particles
  105518. */
  105519. get: function () {
  105520. return this._particles;
  105521. },
  105522. enumerable: true,
  105523. configurable: true
  105524. });
  105525. /**
  105526. * Returns the string "ParticleSystem"
  105527. * @returns a string containing the class name
  105528. */
  105529. ParticleSystem.prototype.getClassName = function () {
  105530. return "ParticleSystem";
  105531. };
  105532. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  105533. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  105534. newGradient.gradient = gradient;
  105535. newGradient.factor1 = factor;
  105536. newGradient.factor2 = factor2;
  105537. factorGradients.push(newGradient);
  105538. factorGradients.sort(function (a, b) {
  105539. if (a.gradient < b.gradient) {
  105540. return -1;
  105541. }
  105542. else if (a.gradient > b.gradient) {
  105543. return 1;
  105544. }
  105545. return 0;
  105546. });
  105547. };
  105548. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  105549. if (!factorGradients) {
  105550. return;
  105551. }
  105552. var index = 0;
  105553. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  105554. var factorGradient = factorGradients_1[_i];
  105555. if (factorGradient.gradient === gradient) {
  105556. factorGradients.splice(index, 1);
  105557. break;
  105558. }
  105559. index++;
  105560. }
  105561. };
  105562. /**
  105563. * Adds a new life time gradient
  105564. * @param gradient defines the gradient to use (between 0 and 1)
  105565. * @param factor defines the life time factor to affect to the specified gradient
  105566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105567. * @returns the current particle system
  105568. */
  105569. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  105570. if (!this._lifeTimeGradients) {
  105571. this._lifeTimeGradients = [];
  105572. }
  105573. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  105574. return this;
  105575. };
  105576. /**
  105577. * Remove a specific life time gradient
  105578. * @param gradient defines the gradient to remove
  105579. * @returns the current particle system
  105580. */
  105581. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  105582. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  105583. return this;
  105584. };
  105585. /**
  105586. * Adds a new size gradient
  105587. * @param gradient defines the gradient to use (between 0 and 1)
  105588. * @param factor defines the size factor to affect to the specified gradient
  105589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105590. * @returns the current particle system
  105591. */
  105592. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  105593. if (!this._sizeGradients) {
  105594. this._sizeGradients = [];
  105595. }
  105596. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  105597. return this;
  105598. };
  105599. /**
  105600. * Remove a specific size gradient
  105601. * @param gradient defines the gradient to remove
  105602. * @returns the current particle system
  105603. */
  105604. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  105605. this._removeFactorGradient(this._sizeGradients, gradient);
  105606. return this;
  105607. };
  105608. /**
  105609. * Adds a new color remap gradient
  105610. * @param gradient defines the gradient to use (between 0 and 1)
  105611. * @param min defines the color remap minimal range
  105612. * @param max defines the color remap maximal range
  105613. * @returns the current particle system
  105614. */
  105615. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  105616. if (!this._colorRemapGradients) {
  105617. this._colorRemapGradients = [];
  105618. }
  105619. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  105620. return this;
  105621. };
  105622. /**
  105623. * Remove a specific color remap gradient
  105624. * @param gradient defines the gradient to remove
  105625. * @returns the current particle system
  105626. */
  105627. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  105628. this._removeFactorGradient(this._colorRemapGradients, gradient);
  105629. return this;
  105630. };
  105631. /**
  105632. * Adds a new alpha remap gradient
  105633. * @param gradient defines the gradient to use (between 0 and 1)
  105634. * @param min defines the alpha remap minimal range
  105635. * @param max defines the alpha remap maximal range
  105636. * @returns the current particle system
  105637. */
  105638. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  105639. if (!this._alphaRemapGradients) {
  105640. this._alphaRemapGradients = [];
  105641. }
  105642. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  105643. return this;
  105644. };
  105645. /**
  105646. * Remove a specific alpha remap gradient
  105647. * @param gradient defines the gradient to remove
  105648. * @returns the current particle system
  105649. */
  105650. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  105651. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  105652. return this;
  105653. };
  105654. /**
  105655. * Adds a new angular speed gradient
  105656. * @param gradient defines the gradient to use (between 0 and 1)
  105657. * @param factor defines the angular speed to affect to the specified gradient
  105658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105659. * @returns the current particle system
  105660. */
  105661. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  105662. if (!this._angularSpeedGradients) {
  105663. this._angularSpeedGradients = [];
  105664. }
  105665. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  105666. return this;
  105667. };
  105668. /**
  105669. * Remove a specific angular speed gradient
  105670. * @param gradient defines the gradient to remove
  105671. * @returns the current particle system
  105672. */
  105673. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  105674. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  105675. return this;
  105676. };
  105677. /**
  105678. * Adds a new velocity gradient
  105679. * @param gradient defines the gradient to use (between 0 and 1)
  105680. * @param factor defines the velocity to affect to the specified gradient
  105681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105682. * @returns the current particle system
  105683. */
  105684. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  105685. if (!this._velocityGradients) {
  105686. this._velocityGradients = [];
  105687. }
  105688. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  105689. return this;
  105690. };
  105691. /**
  105692. * Remove a specific velocity gradient
  105693. * @param gradient defines the gradient to remove
  105694. * @returns the current particle system
  105695. */
  105696. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  105697. this._removeFactorGradient(this._velocityGradients, gradient);
  105698. return this;
  105699. };
  105700. /**
  105701. * Adds a new limit velocity gradient
  105702. * @param gradient defines the gradient to use (between 0 and 1)
  105703. * @param factor defines the limit velocity value to affect to the specified gradient
  105704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105705. * @returns the current particle system
  105706. */
  105707. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  105708. if (!this._limitVelocityGradients) {
  105709. this._limitVelocityGradients = [];
  105710. }
  105711. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  105712. return this;
  105713. };
  105714. /**
  105715. * Remove a specific limit velocity gradient
  105716. * @param gradient defines the gradient to remove
  105717. * @returns the current particle system
  105718. */
  105719. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  105720. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  105721. return this;
  105722. };
  105723. /**
  105724. * Adds a new drag gradient
  105725. * @param gradient defines the gradient to use (between 0 and 1)
  105726. * @param factor defines the drag value to affect to the specified gradient
  105727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105728. * @returns the current particle system
  105729. */
  105730. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  105731. if (!this._dragGradients) {
  105732. this._dragGradients = [];
  105733. }
  105734. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  105735. return this;
  105736. };
  105737. /**
  105738. * Remove a specific drag gradient
  105739. * @param gradient defines the gradient to remove
  105740. * @returns the current particle system
  105741. */
  105742. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  105743. this._removeFactorGradient(this._dragGradients, gradient);
  105744. return this;
  105745. };
  105746. /**
  105747. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  105748. * @param gradient defines the gradient to use (between 0 and 1)
  105749. * @param factor defines the emit rate value to affect to the specified gradient
  105750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105751. * @returns the current particle system
  105752. */
  105753. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  105754. if (!this._emitRateGradients) {
  105755. this._emitRateGradients = [];
  105756. }
  105757. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  105758. return this;
  105759. };
  105760. /**
  105761. * Remove a specific emit rate gradient
  105762. * @param gradient defines the gradient to remove
  105763. * @returns the current particle system
  105764. */
  105765. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  105766. this._removeFactorGradient(this._emitRateGradients, gradient);
  105767. return this;
  105768. };
  105769. /**
  105770. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  105771. * @param gradient defines the gradient to use (between 0 and 1)
  105772. * @param factor defines the start size value to affect to the specified gradient
  105773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105774. * @returns the current particle system
  105775. */
  105776. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  105777. if (!this._startSizeGradients) {
  105778. this._startSizeGradients = [];
  105779. }
  105780. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  105781. return this;
  105782. };
  105783. /**
  105784. * Remove a specific start size gradient
  105785. * @param gradient defines the gradient to remove
  105786. * @returns the current particle system
  105787. */
  105788. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  105789. this._removeFactorGradient(this._emitRateGradients, gradient);
  105790. return this;
  105791. };
  105792. ParticleSystem.prototype._createRampGradientTexture = function () {
  105793. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  105794. return;
  105795. }
  105796. var data = new Uint8Array(this._rawTextureWidth * 4);
  105797. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  105798. for (var x = 0; x < this._rawTextureWidth; x++) {
  105799. var ratio = x / this._rawTextureWidth;
  105800. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  105801. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  105802. data[x * 4] = tmpColor.r * 255;
  105803. data[x * 4 + 1] = tmpColor.g * 255;
  105804. data[x * 4 + 2] = tmpColor.b * 255;
  105805. data[x * 4 + 3] = 255;
  105806. });
  105807. }
  105808. 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);
  105809. };
  105810. /**
  105811. * Gets the current list of ramp gradients.
  105812. * You must use addRampGradient and removeRampGradient to udpate this list
  105813. * @returns the list of ramp gradients
  105814. */
  105815. ParticleSystem.prototype.getRampGradients = function () {
  105816. return this._rampGradients;
  105817. };
  105818. /**
  105819. * Adds a new ramp gradient used to remap particle colors
  105820. * @param gradient defines the gradient to use (between 0 and 1)
  105821. * @param color defines the color to affect to the specified gradient
  105822. * @returns the current particle system
  105823. */
  105824. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  105825. if (!this._rampGradients) {
  105826. this._rampGradients = [];
  105827. }
  105828. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  105829. rampGradient.gradient = gradient;
  105830. rampGradient.color = color;
  105831. this._rampGradients.push(rampGradient);
  105832. this._rampGradients.sort(function (a, b) {
  105833. if (a.gradient < b.gradient) {
  105834. return -1;
  105835. }
  105836. else if (a.gradient > b.gradient) {
  105837. return 1;
  105838. }
  105839. return 0;
  105840. });
  105841. if (this._rampGradientsTexture) {
  105842. this._rampGradientsTexture.dispose();
  105843. this._rampGradientsTexture = null;
  105844. }
  105845. this._createRampGradientTexture();
  105846. return this;
  105847. };
  105848. /**
  105849. * Remove a specific ramp gradient
  105850. * @param gradient defines the gradient to remove
  105851. * @returns the current particle system
  105852. */
  105853. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  105854. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  105855. this._rampGradientsTexture = null;
  105856. if (this._rampGradients && this._rampGradients.length > 0) {
  105857. this._createRampGradientTexture();
  105858. }
  105859. return this;
  105860. };
  105861. /**
  105862. * Adds a new color gradient
  105863. * @param gradient defines the gradient to use (between 0 and 1)
  105864. * @param color1 defines the color to affect to the specified gradient
  105865. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105866. * @returns this particle system
  105867. */
  105868. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  105869. if (!this._colorGradients) {
  105870. this._colorGradients = [];
  105871. }
  105872. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  105873. colorGradient.gradient = gradient;
  105874. colorGradient.color1 = color1;
  105875. colorGradient.color2 = color2;
  105876. this._colorGradients.push(colorGradient);
  105877. this._colorGradients.sort(function (a, b) {
  105878. if (a.gradient < b.gradient) {
  105879. return -1;
  105880. }
  105881. else if (a.gradient > b.gradient) {
  105882. return 1;
  105883. }
  105884. return 0;
  105885. });
  105886. return this;
  105887. };
  105888. /**
  105889. * Remove a specific color gradient
  105890. * @param gradient defines the gradient to remove
  105891. * @returns this particle system
  105892. */
  105893. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  105894. if (!this._colorGradients) {
  105895. return this;
  105896. }
  105897. var index = 0;
  105898. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  105899. var colorGradient = _a[_i];
  105900. if (colorGradient.gradient === gradient) {
  105901. this._colorGradients.splice(index, 1);
  105902. break;
  105903. }
  105904. index++;
  105905. }
  105906. return this;
  105907. };
  105908. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  105909. u = Math.abs(u) * 0.5 + 0.5;
  105910. v = Math.abs(v) * 0.5 + 0.5;
  105911. var wrappedU = ((u * width) % width) | 0;
  105912. var wrappedV = ((v * height) % height) | 0;
  105913. var position = (wrappedU + wrappedV * width) * 4;
  105914. return pixels[position] / 255;
  105915. };
  105916. ParticleSystem.prototype._reset = function () {
  105917. this._resetEffect();
  105918. };
  105919. ParticleSystem.prototype._resetEffect = function () {
  105920. if (this._vertexBuffer) {
  105921. this._vertexBuffer.dispose();
  105922. this._vertexBuffer = null;
  105923. }
  105924. if (this._spriteBuffer) {
  105925. this._spriteBuffer.dispose();
  105926. this._spriteBuffer = null;
  105927. }
  105928. this._createVertexBuffers();
  105929. };
  105930. ParticleSystem.prototype._createVertexBuffers = function () {
  105931. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  105932. if (this._isAnimationSheetEnabled) {
  105933. this._vertexBufferSize += 1;
  105934. }
  105935. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105936. this._vertexBufferSize += 3;
  105937. }
  105938. if (this._useRampGradients) {
  105939. this._vertexBufferSize += 4;
  105940. }
  105941. var engine = this._scene.getEngine();
  105942. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  105943. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  105944. var dataOffset = 0;
  105945. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105946. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  105947. dataOffset += 3;
  105948. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105949. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  105950. dataOffset += 4;
  105951. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105952. this._vertexBuffers["angle"] = options;
  105953. dataOffset += 1;
  105954. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105955. this._vertexBuffers["size"] = size;
  105956. dataOffset += 2;
  105957. if (this._isAnimationSheetEnabled) {
  105958. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105959. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  105960. dataOffset += 1;
  105961. }
  105962. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105963. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105964. this._vertexBuffers["direction"] = directionBuffer;
  105965. dataOffset += 3;
  105966. }
  105967. if (this._useRampGradients) {
  105968. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105969. this._vertexBuffers["remapData"] = rampDataBuffer;
  105970. dataOffset += 4;
  105971. }
  105972. var offsets;
  105973. if (this._useInstancing) {
  105974. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  105975. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  105976. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  105977. }
  105978. else {
  105979. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105980. dataOffset += 2;
  105981. }
  105982. this._vertexBuffers["offset"] = offsets;
  105983. };
  105984. ParticleSystem.prototype._createIndexBuffer = function () {
  105985. if (this._useInstancing) {
  105986. return;
  105987. }
  105988. var indices = [];
  105989. var index = 0;
  105990. for (var count = 0; count < this._capacity; count++) {
  105991. indices.push(index);
  105992. indices.push(index + 1);
  105993. indices.push(index + 2);
  105994. indices.push(index);
  105995. indices.push(index + 2);
  105996. indices.push(index + 3);
  105997. index += 4;
  105998. }
  105999. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  106000. };
  106001. /**
  106002. * Gets the maximum number of particles active at the same time.
  106003. * @returns The max number of active particles.
  106004. */
  106005. ParticleSystem.prototype.getCapacity = function () {
  106006. return this._capacity;
  106007. };
  106008. /**
  106009. * Gets whether there are still active particles in the system.
  106010. * @returns True if it is alive, otherwise false.
  106011. */
  106012. ParticleSystem.prototype.isAlive = function () {
  106013. return this._alive;
  106014. };
  106015. /**
  106016. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106017. * @returns True if it has been started, otherwise false.
  106018. */
  106019. ParticleSystem.prototype.isStarted = function () {
  106020. return this._started;
  106021. };
  106022. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  106023. var _this = this;
  106024. this._subEmitters = new Array();
  106025. if (this.subEmitters) {
  106026. this.subEmitters.forEach(function (subEmitter) {
  106027. if (subEmitter instanceof ParticleSystem) {
  106028. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  106029. }
  106030. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  106031. _this._subEmitters.push([subEmitter]);
  106032. }
  106033. else if (subEmitter instanceof Array) {
  106034. _this._subEmitters.push(subEmitter);
  106035. }
  106036. });
  106037. }
  106038. };
  106039. /**
  106040. * Starts the particle system and begins to emit
  106041. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106042. */
  106043. ParticleSystem.prototype.start = function (delay) {
  106044. var _this = this;
  106045. if (delay === void 0) { delay = this.startDelay; }
  106046. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  106047. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  106048. }
  106049. if (delay) {
  106050. setTimeout(function () {
  106051. _this.start(0);
  106052. }, delay);
  106053. return;
  106054. }
  106055. // Convert the subEmitters field to the constant type field _subEmitters
  106056. this._prepareSubEmitterInternalArray();
  106057. this._started = true;
  106058. this._stopped = false;
  106059. this._actualFrame = 0;
  106060. if (this._subEmitters && this._subEmitters.length != 0) {
  106061. this.activeSubSystems = new Array();
  106062. }
  106063. // Reset emit gradient so it acts the same on every start
  106064. if (this._emitRateGradients) {
  106065. if (this._emitRateGradients.length > 0) {
  106066. this._currentEmitRateGradient = this._emitRateGradients[0];
  106067. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  106068. this._currentEmitRate2 = this._currentEmitRate1;
  106069. }
  106070. if (this._emitRateGradients.length > 1) {
  106071. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  106072. }
  106073. }
  106074. // Reset start size gradient so it acts the same on every start
  106075. if (this._startSizeGradients) {
  106076. if (this._startSizeGradients.length > 0) {
  106077. this._currentStartSizeGradient = this._startSizeGradients[0];
  106078. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  106079. this._currentStartSize2 = this._currentStartSize1;
  106080. }
  106081. if (this._startSizeGradients.length > 1) {
  106082. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  106083. }
  106084. }
  106085. if (this.preWarmCycles) {
  106086. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  106087. this.emitter.computeWorldMatrix(true);
  106088. }
  106089. var noiseTextureAsProcedural_1 = this.noiseTexture;
  106090. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  106091. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  106092. setTimeout(function () {
  106093. for (var index = 0; index < _this.preWarmCycles; index++) {
  106094. _this.animate(true);
  106095. noiseTextureAsProcedural_1.render();
  106096. }
  106097. });
  106098. });
  106099. }
  106100. else {
  106101. for (var index = 0; index < this.preWarmCycles; index++) {
  106102. this.animate(true);
  106103. }
  106104. }
  106105. }
  106106. // Animations
  106107. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  106108. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  106109. }
  106110. };
  106111. /**
  106112. * Stops the particle system.
  106113. * @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.
  106114. */
  106115. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  106116. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  106117. this._stopped = true;
  106118. if (stopSubEmitters) {
  106119. this._stopSubEmitters();
  106120. }
  106121. };
  106122. // animation sheet
  106123. /**
  106124. * Remove all active particles
  106125. */
  106126. ParticleSystem.prototype.reset = function () {
  106127. this._stockParticles = [];
  106128. this._particles = [];
  106129. };
  106130. /**
  106131. * @hidden (for internal use only)
  106132. */
  106133. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  106134. var offset = index * this._vertexBufferSize;
  106135. this._vertexData[offset++] = particle.position.x;
  106136. this._vertexData[offset++] = particle.position.y;
  106137. this._vertexData[offset++] = particle.position.z;
  106138. this._vertexData[offset++] = particle.color.r;
  106139. this._vertexData[offset++] = particle.color.g;
  106140. this._vertexData[offset++] = particle.color.b;
  106141. this._vertexData[offset++] = particle.color.a;
  106142. this._vertexData[offset++] = particle.angle;
  106143. this._vertexData[offset++] = particle.scale.x * particle.size;
  106144. this._vertexData[offset++] = particle.scale.y * particle.size;
  106145. if (this._isAnimationSheetEnabled) {
  106146. this._vertexData[offset++] = particle.cellIndex;
  106147. }
  106148. if (!this._isBillboardBased) {
  106149. if (particle._initialDirection) {
  106150. this._vertexData[offset++] = particle._initialDirection.x;
  106151. this._vertexData[offset++] = particle._initialDirection.y;
  106152. this._vertexData[offset++] = particle._initialDirection.z;
  106153. }
  106154. else {
  106155. this._vertexData[offset++] = particle.direction.x;
  106156. this._vertexData[offset++] = particle.direction.y;
  106157. this._vertexData[offset++] = particle.direction.z;
  106158. }
  106159. }
  106160. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  106161. this._vertexData[offset++] = particle.direction.x;
  106162. this._vertexData[offset++] = particle.direction.y;
  106163. this._vertexData[offset++] = particle.direction.z;
  106164. }
  106165. if (this._useRampGradients) {
  106166. this._vertexData[offset++] = particle.remapData.x;
  106167. this._vertexData[offset++] = particle.remapData.y;
  106168. this._vertexData[offset++] = particle.remapData.z;
  106169. this._vertexData[offset++] = particle.remapData.w;
  106170. }
  106171. if (!this._useInstancing) {
  106172. if (this._isAnimationSheetEnabled) {
  106173. if (offsetX === 0) {
  106174. offsetX = this._epsilon;
  106175. }
  106176. else if (offsetX === 1) {
  106177. offsetX = 1 - this._epsilon;
  106178. }
  106179. if (offsetY === 0) {
  106180. offsetY = this._epsilon;
  106181. }
  106182. else if (offsetY === 1) {
  106183. offsetY = 1 - this._epsilon;
  106184. }
  106185. }
  106186. this._vertexData[offset++] = offsetX;
  106187. this._vertexData[offset++] = offsetY;
  106188. }
  106189. };
  106190. ParticleSystem.prototype._stopSubEmitters = function () {
  106191. if (!this.activeSubSystems) {
  106192. return;
  106193. }
  106194. this.activeSubSystems.forEach(function (subSystem) {
  106195. subSystem.stop(true);
  106196. });
  106197. this.activeSubSystems = new Array();
  106198. };
  106199. ParticleSystem.prototype._removeFromRoot = function () {
  106200. if (!this._rootParticleSystem) {
  106201. return;
  106202. }
  106203. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  106204. if (index !== -1) {
  106205. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  106206. }
  106207. this._rootParticleSystem = null;
  106208. };
  106209. // End of sub system methods
  106210. ParticleSystem.prototype._update = function (newParticles) {
  106211. var _this = this;
  106212. // Update current
  106213. this._alive = this._particles.length > 0;
  106214. if (this.emitter.position) {
  106215. var emitterMesh = this.emitter;
  106216. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  106217. }
  106218. else {
  106219. var emitterPosition = this.emitter;
  106220. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  106221. }
  106222. this.updateFunction(this._particles);
  106223. // Add new ones
  106224. var particle;
  106225. var _loop_2 = function () {
  106226. if (this_1._particles.length === this_1._capacity) {
  106227. return "break";
  106228. }
  106229. particle = this_1._createParticle();
  106230. this_1._particles.push(particle);
  106231. // Emitter
  106232. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  106233. if (this_1.startPositionFunction) {
  106234. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106235. }
  106236. else {
  106237. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106238. }
  106239. if (this_1.startDirectionFunction) {
  106240. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106241. }
  106242. else {
  106243. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106244. }
  106245. if (emitPower === 0) {
  106246. if (!particle._initialDirection) {
  106247. particle._initialDirection = particle.direction.clone();
  106248. }
  106249. else {
  106250. particle._initialDirection.copyFrom(particle.direction);
  106251. }
  106252. }
  106253. else {
  106254. particle._initialDirection = null;
  106255. }
  106256. particle.direction.scaleInPlace(emitPower);
  106257. // Life time
  106258. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  106259. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  106260. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  106261. var factorGradient1 = currentGradient;
  106262. var factorGradient2 = nextGradient;
  106263. var lifeTime1 = factorGradient1.getFactor();
  106264. var lifeTime2 = factorGradient2.getFactor();
  106265. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  106266. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  106267. });
  106268. }
  106269. else {
  106270. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  106271. }
  106272. // Size
  106273. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  106274. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  106275. }
  106276. else {
  106277. particle._currentSizeGradient = this_1._sizeGradients[0];
  106278. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  106279. particle.size = particle._currentSize1;
  106280. if (this_1._sizeGradients.length > 1) {
  106281. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  106282. }
  106283. else {
  106284. particle._currentSize2 = particle._currentSize1;
  106285. }
  106286. }
  106287. // Size and scale
  106288. 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));
  106289. // Adjust scale by start size
  106290. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  106291. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  106292. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  106293. if (currentGradient !== _this._currentStartSizeGradient) {
  106294. _this._currentStartSize1 = _this._currentStartSize2;
  106295. _this._currentStartSize2 = nextGradient.getFactor();
  106296. _this._currentStartSizeGradient = currentGradient;
  106297. }
  106298. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  106299. particle.scale.scaleInPlace(value);
  106300. });
  106301. }
  106302. // Angle
  106303. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  106304. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  106305. }
  106306. else {
  106307. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  106308. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  106309. particle._currentAngularSpeed1 = particle.angularSpeed;
  106310. if (this_1._angularSpeedGradients.length > 1) {
  106311. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  106312. }
  106313. else {
  106314. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  106315. }
  106316. }
  106317. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  106318. // Velocity
  106319. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  106320. particle._currentVelocityGradient = this_1._velocityGradients[0];
  106321. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  106322. if (this_1._velocityGradients.length > 1) {
  106323. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  106324. }
  106325. else {
  106326. particle._currentVelocity2 = particle._currentVelocity1;
  106327. }
  106328. }
  106329. // Limit velocity
  106330. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  106331. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  106332. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  106333. if (this_1._limitVelocityGradients.length > 1) {
  106334. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  106335. }
  106336. else {
  106337. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  106338. }
  106339. }
  106340. // Drag
  106341. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  106342. particle._currentDragGradient = this_1._dragGradients[0];
  106343. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  106344. if (this_1._dragGradients.length > 1) {
  106345. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  106346. }
  106347. else {
  106348. particle._currentDrag2 = particle._currentDrag1;
  106349. }
  106350. }
  106351. // Color
  106352. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  106353. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  106354. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  106355. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  106356. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  106357. }
  106358. else {
  106359. particle._currentColorGradient = this_1._colorGradients[0];
  106360. particle._currentColorGradient.getColorToRef(particle.color);
  106361. particle._currentColor1.copyFrom(particle.color);
  106362. if (this_1._colorGradients.length > 1) {
  106363. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  106364. }
  106365. else {
  106366. particle._currentColor2.copyFrom(particle.color);
  106367. }
  106368. }
  106369. // Sheet
  106370. if (this_1._isAnimationSheetEnabled) {
  106371. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  106372. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  106373. }
  106374. // Inherited Velocity
  106375. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  106376. // Ramp
  106377. if (this_1._useRampGradients) {
  106378. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  106379. }
  106380. // Noise texture coordinates
  106381. if (this_1.noiseTexture) {
  106382. if (particle._randomNoiseCoordinates1) {
  106383. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  106384. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  106385. }
  106386. else {
  106387. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106388. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106389. }
  106390. }
  106391. // Update the position of the attached sub-emitters to match their attached particle
  106392. particle._inheritParticleInfoToSubEmitters();
  106393. };
  106394. var this_1 = this, step;
  106395. for (var index = 0; index < newParticles; index++) {
  106396. var state_1 = _loop_2();
  106397. if (state_1 === "break")
  106398. break;
  106399. }
  106400. };
  106401. /** @hidden */
  106402. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  106403. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106404. if (isBillboardBased === void 0) { isBillboardBased = false; }
  106405. if (useRampGradients === void 0) { useRampGradients = false; }
  106406. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  106407. if (isAnimationSheetEnabled) {
  106408. attributeNamesOrOptions.push("cellIndex");
  106409. }
  106410. if (!isBillboardBased) {
  106411. attributeNamesOrOptions.push("direction");
  106412. }
  106413. if (useRampGradients) {
  106414. attributeNamesOrOptions.push("remapData");
  106415. }
  106416. return attributeNamesOrOptions;
  106417. };
  106418. /** @hidden */
  106419. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  106420. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106421. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  106422. if (isAnimationSheetEnabled) {
  106423. effectCreationOption.push("particlesInfos");
  106424. }
  106425. return effectCreationOption;
  106426. };
  106427. /** @hidden */
  106428. ParticleSystem.prototype._getEffect = function (blendMode) {
  106429. if (this._customEffect) {
  106430. return this._customEffect;
  106431. }
  106432. var defines = [];
  106433. if (this._scene.clipPlane) {
  106434. defines.push("#define CLIPPLANE");
  106435. }
  106436. if (this._scene.clipPlane2) {
  106437. defines.push("#define CLIPPLANE2");
  106438. }
  106439. if (this._scene.clipPlane3) {
  106440. defines.push("#define CLIPPLANE3");
  106441. }
  106442. if (this._scene.clipPlane4) {
  106443. defines.push("#define CLIPPLANE4");
  106444. }
  106445. if (this._isAnimationSheetEnabled) {
  106446. defines.push("#define ANIMATESHEET");
  106447. }
  106448. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  106449. defines.push("#define BLENDMULTIPLYMODE");
  106450. }
  106451. if (this._useRampGradients) {
  106452. defines.push("#define RAMPGRADIENT");
  106453. }
  106454. if (this._isBillboardBased) {
  106455. defines.push("#define BILLBOARD");
  106456. switch (this.billboardMode) {
  106457. case ParticleSystem.BILLBOARDMODE_Y:
  106458. defines.push("#define BILLBOARDY");
  106459. break;
  106460. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  106461. defines.push("#define BILLBOARDSTRETCHED");
  106462. break;
  106463. case ParticleSystem.BILLBOARDMODE_ALL:
  106464. default:
  106465. break;
  106466. }
  106467. }
  106468. if (this._imageProcessingConfiguration) {
  106469. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  106470. defines.push(this._imageProcessingConfigurationDefines.toString());
  106471. }
  106472. // Effect
  106473. var join = defines.join("\n");
  106474. if (this._cachedDefines !== join) {
  106475. this._cachedDefines = join;
  106476. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  106477. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  106478. var samplers = ["diffuseSampler", "rampSampler"];
  106479. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  106480. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  106481. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  106482. }
  106483. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  106484. }
  106485. return this._effect;
  106486. };
  106487. /**
  106488. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106489. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  106490. */
  106491. ParticleSystem.prototype.animate = function (preWarmOnly) {
  106492. var _this = this;
  106493. if (preWarmOnly === void 0) { preWarmOnly = false; }
  106494. if (!this._started) {
  106495. return;
  106496. }
  106497. if (!preWarmOnly) {
  106498. // Check
  106499. if (!this.isReady()) {
  106500. return;
  106501. }
  106502. if (this._currentRenderId === this._scene.getFrameId()) {
  106503. return;
  106504. }
  106505. this._currentRenderId = this._scene.getFrameId();
  106506. }
  106507. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  106508. // Determine the number of particles we need to create
  106509. var newParticles;
  106510. if (this.manualEmitCount > -1) {
  106511. newParticles = this.manualEmitCount;
  106512. this._newPartsExcess = 0;
  106513. this.manualEmitCount = 0;
  106514. }
  106515. else {
  106516. var rate_1 = this.emitRate;
  106517. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  106518. var ratio = this._actualFrame / this.targetStopDuration;
  106519. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  106520. if (currentGradient !== _this._currentEmitRateGradient) {
  106521. _this._currentEmitRate1 = _this._currentEmitRate2;
  106522. _this._currentEmitRate2 = nextGradient.getFactor();
  106523. _this._currentEmitRateGradient = currentGradient;
  106524. }
  106525. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  106526. });
  106527. }
  106528. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  106529. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  106530. }
  106531. if (this._newPartsExcess > 1.0) {
  106532. newParticles += this._newPartsExcess >> 0;
  106533. this._newPartsExcess -= this._newPartsExcess >> 0;
  106534. }
  106535. this._alive = false;
  106536. if (!this._stopped) {
  106537. this._actualFrame += this._scaledUpdateSpeed;
  106538. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  106539. this.stop();
  106540. }
  106541. }
  106542. else {
  106543. newParticles = 0;
  106544. }
  106545. this._update(newParticles);
  106546. // Stopped?
  106547. if (this._stopped) {
  106548. if (!this._alive) {
  106549. this._started = false;
  106550. if (this.onAnimationEnd) {
  106551. this.onAnimationEnd();
  106552. }
  106553. if (this.disposeOnStop) {
  106554. this._scene._toBeDisposed.push(this);
  106555. }
  106556. }
  106557. }
  106558. if (!preWarmOnly) {
  106559. // Update VBO
  106560. var offset = 0;
  106561. for (var index = 0; index < this._particles.length; index++) {
  106562. var particle = this._particles[index];
  106563. this._appendParticleVertices(offset, particle);
  106564. offset += this._useInstancing ? 1 : 4;
  106565. }
  106566. if (this._vertexBuffer) {
  106567. this._vertexBuffer.update(this._vertexData);
  106568. }
  106569. }
  106570. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  106571. this.stop();
  106572. }
  106573. };
  106574. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  106575. this._appendParticleVertex(offset++, particle, 0, 0);
  106576. if (!this._useInstancing) {
  106577. this._appendParticleVertex(offset++, particle, 1, 0);
  106578. this._appendParticleVertex(offset++, particle, 1, 1);
  106579. this._appendParticleVertex(offset++, particle, 0, 1);
  106580. }
  106581. };
  106582. /**
  106583. * Rebuilds the particle system.
  106584. */
  106585. ParticleSystem.prototype.rebuild = function () {
  106586. this._createIndexBuffer();
  106587. if (this._vertexBuffer) {
  106588. this._vertexBuffer._rebuild();
  106589. }
  106590. };
  106591. /**
  106592. * Is this system ready to be used/rendered
  106593. * @return true if the system is ready
  106594. */
  106595. ParticleSystem.prototype.isReady = function () {
  106596. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  106597. return false;
  106598. }
  106599. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106600. if (!this._getEffect(this.blendMode).isReady()) {
  106601. return false;
  106602. }
  106603. }
  106604. else {
  106605. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  106606. return false;
  106607. }
  106608. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  106609. return false;
  106610. }
  106611. }
  106612. return true;
  106613. };
  106614. ParticleSystem.prototype._render = function (blendMode) {
  106615. var effect = this._getEffect(blendMode);
  106616. var engine = this._scene.getEngine();
  106617. // Render
  106618. engine.enableEffect(effect);
  106619. var viewMatrix = this._scene.getViewMatrix();
  106620. effect.setTexture("diffuseSampler", this.particleTexture);
  106621. effect.setMatrix("view", viewMatrix);
  106622. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  106623. if (this._isAnimationSheetEnabled && this.particleTexture) {
  106624. var baseSize = this.particleTexture.getBaseSize();
  106625. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  106626. }
  106627. effect.setVector2("translationPivot", this.translationPivot);
  106628. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  106629. if (this._isBillboardBased) {
  106630. var camera = this._scene.activeCamera;
  106631. effect.setVector3("eyePosition", camera.globalPosition);
  106632. }
  106633. if (this._rampGradientsTexture) {
  106634. effect.setTexture("rampSampler", this._rampGradientsTexture);
  106635. }
  106636. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  106637. var invView = viewMatrix.clone();
  106638. invView.invert();
  106639. effect.setMatrix("invView", invView);
  106640. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  106641. }
  106642. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  106643. // image processing
  106644. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  106645. this._imageProcessingConfiguration.bind(effect);
  106646. }
  106647. // Draw order
  106648. switch (blendMode) {
  106649. case ParticleSystem.BLENDMODE_ADD:
  106650. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  106651. break;
  106652. case ParticleSystem.BLENDMODE_ONEONE:
  106653. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  106654. break;
  106655. case ParticleSystem.BLENDMODE_STANDARD:
  106656. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  106657. break;
  106658. case ParticleSystem.BLENDMODE_MULTIPLY:
  106659. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  106660. break;
  106661. }
  106662. if (this._useInstancing) {
  106663. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  106664. }
  106665. else {
  106666. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  106667. }
  106668. return this._particles.length;
  106669. };
  106670. /**
  106671. * Renders the particle system in its current state.
  106672. * @returns the current number of particles
  106673. */
  106674. ParticleSystem.prototype.render = function () {
  106675. // Check
  106676. if (!this.isReady() || !this._particles.length) {
  106677. return 0;
  106678. }
  106679. var engine = this._scene.getEngine();
  106680. engine.setState(false);
  106681. if (this.forceDepthWrite) {
  106682. engine.setDepthWrite(true);
  106683. }
  106684. var outparticles = 0;
  106685. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106686. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  106687. }
  106688. outparticles = this._render(this.blendMode);
  106689. engine.unbindInstanceAttributes();
  106690. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  106691. return outparticles;
  106692. };
  106693. /**
  106694. * Disposes the particle system and free the associated resources
  106695. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106696. */
  106697. ParticleSystem.prototype.dispose = function (disposeTexture) {
  106698. if (disposeTexture === void 0) { disposeTexture = true; }
  106699. if (this._vertexBuffer) {
  106700. this._vertexBuffer.dispose();
  106701. this._vertexBuffer = null;
  106702. }
  106703. if (this._spriteBuffer) {
  106704. this._spriteBuffer.dispose();
  106705. this._spriteBuffer = null;
  106706. }
  106707. if (this._indexBuffer) {
  106708. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  106709. this._indexBuffer = null;
  106710. }
  106711. if (disposeTexture && this.particleTexture) {
  106712. this.particleTexture.dispose();
  106713. this.particleTexture = null;
  106714. }
  106715. if (disposeTexture && this.noiseTexture) {
  106716. this.noiseTexture.dispose();
  106717. this.noiseTexture = null;
  106718. }
  106719. if (this._rampGradientsTexture) {
  106720. this._rampGradientsTexture.dispose();
  106721. this._rampGradientsTexture = null;
  106722. }
  106723. this._removeFromRoot();
  106724. if (this._subEmitters && this._subEmitters.length) {
  106725. for (var index = 0; index < this._subEmitters.length; index++) {
  106726. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  106727. var subEmitter = _a[_i];
  106728. subEmitter.dispose();
  106729. }
  106730. }
  106731. this._subEmitters = [];
  106732. this.subEmitters = [];
  106733. }
  106734. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  106735. this.emitter.dispose(true);
  106736. }
  106737. // Remove from scene
  106738. var index = this._scene.particleSystems.indexOf(this);
  106739. if (index > -1) {
  106740. this._scene.particleSystems.splice(index, 1);
  106741. }
  106742. this._scene._activeParticleSystems.dispose();
  106743. // Callback
  106744. this.onDisposeObservable.notifyObservers(this);
  106745. this.onDisposeObservable.clear();
  106746. this.reset();
  106747. };
  106748. // Clone
  106749. /**
  106750. * Clones the particle system.
  106751. * @param name The name of the cloned object
  106752. * @param newEmitter The new emitter to use
  106753. * @returns the cloned particle system
  106754. */
  106755. ParticleSystem.prototype.clone = function (name, newEmitter) {
  106756. var custom = null;
  106757. var program = null;
  106758. if (this.customShader != null) {
  106759. program = this.customShader;
  106760. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106761. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106762. }
  106763. else if (this._customEffect) {
  106764. custom = this._customEffect;
  106765. }
  106766. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  106767. result.customShader = program;
  106768. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  106769. if (newEmitter === undefined) {
  106770. newEmitter = this.emitter;
  106771. }
  106772. result.noiseTexture = this.noiseTexture;
  106773. result.emitter = newEmitter;
  106774. if (this.particleTexture) {
  106775. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  106776. }
  106777. // Clone gradients
  106778. if (this._colorGradients) {
  106779. this._colorGradients.forEach(function (v) {
  106780. result.addColorGradient(v.gradient, v.color1, v.color2);
  106781. });
  106782. }
  106783. if (this._dragGradients) {
  106784. this._dragGradients.forEach(function (v) {
  106785. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  106786. });
  106787. }
  106788. if (this._angularSpeedGradients) {
  106789. this._angularSpeedGradients.forEach(function (v) {
  106790. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  106791. });
  106792. }
  106793. if (this._emitRateGradients) {
  106794. this._emitRateGradients.forEach(function (v) {
  106795. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  106796. });
  106797. }
  106798. if (this._lifeTimeGradients) {
  106799. this._lifeTimeGradients.forEach(function (v) {
  106800. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  106801. });
  106802. }
  106803. if (this._limitVelocityGradients) {
  106804. this._limitVelocityGradients.forEach(function (v) {
  106805. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  106806. });
  106807. }
  106808. if (this._sizeGradients) {
  106809. this._sizeGradients.forEach(function (v) {
  106810. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  106811. });
  106812. }
  106813. if (this._startSizeGradients) {
  106814. this._startSizeGradients.forEach(function (v) {
  106815. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  106816. });
  106817. }
  106818. if (this._velocityGradients) {
  106819. this._velocityGradients.forEach(function (v) {
  106820. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  106821. });
  106822. }
  106823. if (this._rampGradients) {
  106824. this._rampGradients.forEach(function (v) {
  106825. result.addRampGradient(v.gradient, v.color);
  106826. });
  106827. }
  106828. if (this._colorRemapGradients) {
  106829. this._colorRemapGradients.forEach(function (v) {
  106830. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  106831. });
  106832. }
  106833. if (this._alphaRemapGradients) {
  106834. this._alphaRemapGradients.forEach(function (v) {
  106835. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  106836. });
  106837. }
  106838. if (!this.preventAutoStart) {
  106839. result.start();
  106840. }
  106841. return result;
  106842. };
  106843. /**
  106844. * Serializes the particle system to a JSON object.
  106845. * @returns the JSON object
  106846. */
  106847. ParticleSystem.prototype.serialize = function () {
  106848. var serializationObject = {};
  106849. ParticleSystem._Serialize(serializationObject, this);
  106850. serializationObject.textureMask = this.textureMask.asArray();
  106851. serializationObject.customShader = this.customShader;
  106852. serializationObject.preventAutoStart = this.preventAutoStart;
  106853. // SubEmitters
  106854. if (this.subEmitters) {
  106855. serializationObject.subEmitters = [];
  106856. if (!this._subEmitters) {
  106857. this._prepareSubEmitterInternalArray();
  106858. }
  106859. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  106860. var subs = _a[_i];
  106861. var cell = [];
  106862. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  106863. var sub = subs_1[_b];
  106864. cell.push(sub.serialize());
  106865. }
  106866. serializationObject.subEmitters.push(cell);
  106867. }
  106868. }
  106869. return serializationObject;
  106870. };
  106871. /** @hidden */
  106872. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  106873. serializationObject.name = particleSystem.name;
  106874. serializationObject.id = particleSystem.id;
  106875. serializationObject.capacity = particleSystem.getCapacity();
  106876. // Emitter
  106877. if (particleSystem.emitter.position) {
  106878. var emitterMesh = particleSystem.emitter;
  106879. serializationObject.emitterId = emitterMesh.id;
  106880. }
  106881. else {
  106882. var emitterPosition = particleSystem.emitter;
  106883. serializationObject.emitter = emitterPosition.asArray();
  106884. }
  106885. // Emitter
  106886. if (particleSystem.particleEmitterType) {
  106887. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  106888. }
  106889. if (particleSystem.particleTexture) {
  106890. serializationObject.textureName = particleSystem.particleTexture.name;
  106891. serializationObject.invertY = particleSystem.particleTexture._invertY;
  106892. }
  106893. // Animations
  106894. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  106895. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  106896. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  106897. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  106898. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  106899. // Particle system
  106900. serializationObject.startDelay = particleSystem.startDelay;
  106901. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  106902. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  106903. serializationObject.billboardMode = particleSystem.billboardMode;
  106904. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  106905. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  106906. serializationObject.minSize = particleSystem.minSize;
  106907. serializationObject.maxSize = particleSystem.maxSize;
  106908. serializationObject.minScaleX = particleSystem.minScaleX;
  106909. serializationObject.maxScaleX = particleSystem.maxScaleX;
  106910. serializationObject.minScaleY = particleSystem.minScaleY;
  106911. serializationObject.maxScaleY = particleSystem.maxScaleY;
  106912. serializationObject.minEmitPower = particleSystem.minEmitPower;
  106913. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  106914. serializationObject.minLifeTime = particleSystem.minLifeTime;
  106915. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  106916. serializationObject.emitRate = particleSystem.emitRate;
  106917. serializationObject.gravity = particleSystem.gravity.asArray();
  106918. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  106919. serializationObject.color1 = particleSystem.color1.asArray();
  106920. serializationObject.color2 = particleSystem.color2.asArray();
  106921. serializationObject.colorDead = particleSystem.colorDead.asArray();
  106922. serializationObject.updateSpeed = particleSystem.updateSpeed;
  106923. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  106924. serializationObject.blendMode = particleSystem.blendMode;
  106925. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  106926. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  106927. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  106928. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  106929. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  106930. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  106931. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  106932. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  106933. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  106934. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  106935. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  106936. var colorGradients = particleSystem.getColorGradients();
  106937. if (colorGradients) {
  106938. serializationObject.colorGradients = [];
  106939. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  106940. var colorGradient = colorGradients_1[_i];
  106941. var serializedGradient = {
  106942. gradient: colorGradient.gradient,
  106943. color1: colorGradient.color1.asArray()
  106944. };
  106945. if (colorGradient.color2) {
  106946. serializedGradient.color2 = colorGradient.color2.asArray();
  106947. }
  106948. serializationObject.colorGradients.push(serializedGradient);
  106949. }
  106950. }
  106951. var rampGradients = particleSystem.getRampGradients();
  106952. if (rampGradients) {
  106953. serializationObject.rampGradients = [];
  106954. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  106955. var rampGradient = rampGradients_1[_a];
  106956. var serializedGradient = {
  106957. gradient: rampGradient.gradient,
  106958. color: rampGradient.color.asArray()
  106959. };
  106960. serializationObject.rampGradients.push(serializedGradient);
  106961. }
  106962. serializationObject.useRampGradients = particleSystem.useRampGradients;
  106963. }
  106964. var colorRemapGradients = particleSystem.getColorRemapGradients();
  106965. if (colorRemapGradients) {
  106966. serializationObject.colorRemapGradients = [];
  106967. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  106968. var colorRemapGradient = colorRemapGradients_1[_b];
  106969. var serializedGradient = {
  106970. gradient: colorRemapGradient.gradient,
  106971. factor1: colorRemapGradient.factor1
  106972. };
  106973. if (colorRemapGradient.factor2 !== undefined) {
  106974. serializedGradient.factor2 = colorRemapGradient.factor2;
  106975. }
  106976. serializationObject.colorRemapGradients.push(serializedGradient);
  106977. }
  106978. }
  106979. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  106980. if (alphaRemapGradients) {
  106981. serializationObject.alphaRemapGradients = [];
  106982. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  106983. var alphaRemapGradient = alphaRemapGradients_1[_c];
  106984. var serializedGradient = {
  106985. gradient: alphaRemapGradient.gradient,
  106986. factor1: alphaRemapGradient.factor1
  106987. };
  106988. if (alphaRemapGradient.factor2 !== undefined) {
  106989. serializedGradient.factor2 = alphaRemapGradient.factor2;
  106990. }
  106991. serializationObject.alphaRemapGradients.push(serializedGradient);
  106992. }
  106993. }
  106994. var sizeGradients = particleSystem.getSizeGradients();
  106995. if (sizeGradients) {
  106996. serializationObject.sizeGradients = [];
  106997. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  106998. var sizeGradient = sizeGradients_1[_d];
  106999. var serializedGradient = {
  107000. gradient: sizeGradient.gradient,
  107001. factor1: sizeGradient.factor1
  107002. };
  107003. if (sizeGradient.factor2 !== undefined) {
  107004. serializedGradient.factor2 = sizeGradient.factor2;
  107005. }
  107006. serializationObject.sizeGradients.push(serializedGradient);
  107007. }
  107008. }
  107009. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  107010. if (angularSpeedGradients) {
  107011. serializationObject.angularSpeedGradients = [];
  107012. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  107013. var angularSpeedGradient = angularSpeedGradients_1[_e];
  107014. var serializedGradient = {
  107015. gradient: angularSpeedGradient.gradient,
  107016. factor1: angularSpeedGradient.factor1
  107017. };
  107018. if (angularSpeedGradient.factor2 !== undefined) {
  107019. serializedGradient.factor2 = angularSpeedGradient.factor2;
  107020. }
  107021. serializationObject.angularSpeedGradients.push(serializedGradient);
  107022. }
  107023. }
  107024. var velocityGradients = particleSystem.getVelocityGradients();
  107025. if (velocityGradients) {
  107026. serializationObject.velocityGradients = [];
  107027. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  107028. var velocityGradient = velocityGradients_1[_f];
  107029. var serializedGradient = {
  107030. gradient: velocityGradient.gradient,
  107031. factor1: velocityGradient.factor1
  107032. };
  107033. if (velocityGradient.factor2 !== undefined) {
  107034. serializedGradient.factor2 = velocityGradient.factor2;
  107035. }
  107036. serializationObject.velocityGradients.push(serializedGradient);
  107037. }
  107038. }
  107039. var dragGradients = particleSystem.getDragGradients();
  107040. if (dragGradients) {
  107041. serializationObject.dragyGradients = [];
  107042. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  107043. var dragGradient = dragGradients_1[_g];
  107044. var serializedGradient = {
  107045. gradient: dragGradient.gradient,
  107046. factor1: dragGradient.factor1
  107047. };
  107048. if (dragGradient.factor2 !== undefined) {
  107049. serializedGradient.factor2 = dragGradient.factor2;
  107050. }
  107051. serializationObject.dragGradients.push(serializedGradient);
  107052. }
  107053. }
  107054. var emitRateGradients = particleSystem.getEmitRateGradients();
  107055. if (emitRateGradients) {
  107056. serializationObject.emitRateGradients = [];
  107057. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  107058. var emitRateGradient = emitRateGradients_1[_h];
  107059. var serializedGradient = {
  107060. gradient: emitRateGradient.gradient,
  107061. factor1: emitRateGradient.factor1
  107062. };
  107063. if (emitRateGradient.factor2 !== undefined) {
  107064. serializedGradient.factor2 = emitRateGradient.factor2;
  107065. }
  107066. serializationObject.emitRateGradients.push(serializedGradient);
  107067. }
  107068. }
  107069. var startSizeGradients = particleSystem.getStartSizeGradients();
  107070. if (startSizeGradients) {
  107071. serializationObject.startSizeGradients = [];
  107072. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  107073. var startSizeGradient = startSizeGradients_1[_j];
  107074. var serializedGradient = {
  107075. gradient: startSizeGradient.gradient,
  107076. factor1: startSizeGradient.factor1
  107077. };
  107078. if (startSizeGradient.factor2 !== undefined) {
  107079. serializedGradient.factor2 = startSizeGradient.factor2;
  107080. }
  107081. serializationObject.startSizeGradients.push(serializedGradient);
  107082. }
  107083. }
  107084. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  107085. if (lifeTimeGradients) {
  107086. serializationObject.lifeTimeGradients = [];
  107087. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  107088. var lifeTimeGradient = lifeTimeGradients_1[_k];
  107089. var serializedGradient = {
  107090. gradient: lifeTimeGradient.gradient,
  107091. factor1: lifeTimeGradient.factor1
  107092. };
  107093. if (lifeTimeGradient.factor2 !== undefined) {
  107094. serializedGradient.factor2 = lifeTimeGradient.factor2;
  107095. }
  107096. serializationObject.lifeTimeGradients.push(serializedGradient);
  107097. }
  107098. }
  107099. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  107100. if (limitVelocityGradients) {
  107101. serializationObject.limitVelocityGradients = [];
  107102. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  107103. var limitVelocityGradient = limitVelocityGradients_1[_l];
  107104. var serializedGradient = {
  107105. gradient: limitVelocityGradient.gradient,
  107106. factor1: limitVelocityGradient.factor1
  107107. };
  107108. if (limitVelocityGradient.factor2 !== undefined) {
  107109. serializedGradient.factor2 = limitVelocityGradient.factor2;
  107110. }
  107111. serializationObject.limitVelocityGradients.push(serializedGradient);
  107112. }
  107113. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  107114. }
  107115. if (particleSystem.noiseTexture) {
  107116. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  107117. }
  107118. };
  107119. /** @hidden */
  107120. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  107121. // Texture
  107122. if (parsedParticleSystem.textureName) {
  107123. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  107124. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  107125. }
  107126. // Emitter
  107127. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  107128. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  107129. }
  107130. else if (parsedParticleSystem.emitterId) {
  107131. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  107132. }
  107133. else {
  107134. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  107135. }
  107136. // Misc.
  107137. if (parsedParticleSystem.renderingGroupId !== undefined) {
  107138. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  107139. }
  107140. if (parsedParticleSystem.isBillboardBased !== undefined) {
  107141. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  107142. }
  107143. if (parsedParticleSystem.billboardMode !== undefined) {
  107144. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  107145. }
  107146. // Animations
  107147. if (parsedParticleSystem.animations) {
  107148. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  107149. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  107150. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  107151. if (internalClass) {
  107152. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  107153. }
  107154. }
  107155. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  107156. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  107157. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  107158. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  107159. }
  107160. if (parsedParticleSystem.autoAnimate) {
  107161. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  107162. }
  107163. // Particle system
  107164. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  107165. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  107166. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  107167. particleSystem.minSize = parsedParticleSystem.minSize;
  107168. particleSystem.maxSize = parsedParticleSystem.maxSize;
  107169. if (parsedParticleSystem.minScaleX) {
  107170. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  107171. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  107172. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  107173. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  107174. }
  107175. if (parsedParticleSystem.preWarmCycles !== undefined) {
  107176. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  107177. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  107178. }
  107179. if (parsedParticleSystem.minInitialRotation !== undefined) {
  107180. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  107181. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  107182. }
  107183. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  107184. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  107185. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  107186. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  107187. particleSystem.emitRate = parsedParticleSystem.emitRate;
  107188. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  107189. if (parsedParticleSystem.noiseStrength) {
  107190. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  107191. }
  107192. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  107193. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  107194. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  107195. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  107196. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  107197. particleSystem.blendMode = parsedParticleSystem.blendMode;
  107198. if (parsedParticleSystem.colorGradients) {
  107199. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  107200. var colorGradient = _a[_i];
  107201. 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);
  107202. }
  107203. }
  107204. if (parsedParticleSystem.rampGradients) {
  107205. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  107206. var rampGradient = _c[_b];
  107207. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  107208. }
  107209. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  107210. }
  107211. if (parsedParticleSystem.colorRemapGradients) {
  107212. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  107213. var colorRemapGradient = _e[_d];
  107214. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  107215. }
  107216. }
  107217. if (parsedParticleSystem.alphaRemapGradients) {
  107218. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  107219. var alphaRemapGradient = _g[_f];
  107220. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  107221. }
  107222. }
  107223. if (parsedParticleSystem.sizeGradients) {
  107224. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  107225. var sizeGradient = _j[_h];
  107226. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107227. }
  107228. }
  107229. if (parsedParticleSystem.sizeGradients) {
  107230. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  107231. var sizeGradient = _l[_k];
  107232. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107233. }
  107234. }
  107235. if (parsedParticleSystem.angularSpeedGradients) {
  107236. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  107237. var angularSpeedGradient = _o[_m];
  107238. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  107239. }
  107240. }
  107241. if (parsedParticleSystem.velocityGradients) {
  107242. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  107243. var velocityGradient = _q[_p];
  107244. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  107245. }
  107246. }
  107247. if (parsedParticleSystem.dragGradients) {
  107248. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  107249. var dragGradient = _s[_r];
  107250. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  107251. }
  107252. }
  107253. if (parsedParticleSystem.emitRateGradients) {
  107254. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  107255. var emitRateGradient = _u[_t];
  107256. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  107257. }
  107258. }
  107259. if (parsedParticleSystem.startSizeGradients) {
  107260. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  107261. var startSizeGradient = _w[_v];
  107262. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  107263. }
  107264. }
  107265. if (parsedParticleSystem.lifeTimeGradients) {
  107266. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  107267. var lifeTimeGradient = _y[_x];
  107268. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  107269. }
  107270. }
  107271. if (parsedParticleSystem.limitVelocityGradients) {
  107272. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  107273. var limitVelocityGradient = _0[_z];
  107274. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  107275. }
  107276. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  107277. }
  107278. if (parsedParticleSystem.noiseTexture) {
  107279. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  107280. }
  107281. // Emitter
  107282. var emitterType;
  107283. if (parsedParticleSystem.particleEmitterType) {
  107284. switch (parsedParticleSystem.particleEmitterType.type) {
  107285. case "SphereParticleEmitter":
  107286. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  107287. break;
  107288. case "SphereDirectedParticleEmitter":
  107289. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  107290. break;
  107291. case "ConeEmitter":
  107292. case "ConeParticleEmitter":
  107293. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  107294. break;
  107295. case "CylinderParticleEmitter":
  107296. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  107297. break;
  107298. case "HemisphericParticleEmitter":
  107299. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  107300. break;
  107301. case "BoxEmitter":
  107302. case "BoxParticleEmitter":
  107303. default:
  107304. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107305. break;
  107306. }
  107307. emitterType.parse(parsedParticleSystem.particleEmitterType);
  107308. }
  107309. else {
  107310. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107311. emitterType.parse(parsedParticleSystem);
  107312. }
  107313. particleSystem.particleEmitterType = emitterType;
  107314. // Animation sheet
  107315. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  107316. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  107317. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  107318. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  107319. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  107320. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  107321. };
  107322. /**
  107323. * Parses a JSON object to create a particle system.
  107324. * @param parsedParticleSystem The JSON object to parse
  107325. * @param scene The scene to create the particle system in
  107326. * @param rootUrl The root url to use to load external dependencies like texture
  107327. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107328. * @returns the Parsed particle system
  107329. */
  107330. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  107331. if (doNotStart === void 0) { doNotStart = false; }
  107332. var name = parsedParticleSystem.name;
  107333. var custom = null;
  107334. var program = null;
  107335. if (parsedParticleSystem.customShader) {
  107336. program = parsedParticleSystem.customShader;
  107337. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  107338. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  107339. }
  107340. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  107341. particleSystem.customShader = program;
  107342. if (parsedParticleSystem.id) {
  107343. particleSystem.id = parsedParticleSystem.id;
  107344. }
  107345. // SubEmitters
  107346. if (parsedParticleSystem.subEmitters) {
  107347. particleSystem.subEmitters = [];
  107348. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  107349. var cell = _a[_i];
  107350. var cellArray = [];
  107351. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  107352. var sub = cell_1[_b];
  107353. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  107354. }
  107355. particleSystem.subEmitters.push(cellArray);
  107356. }
  107357. }
  107358. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  107359. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  107360. // Auto start
  107361. if (parsedParticleSystem.preventAutoStart) {
  107362. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  107363. }
  107364. if (!doNotStart && !particleSystem.preventAutoStart) {
  107365. particleSystem.start();
  107366. }
  107367. return particleSystem;
  107368. };
  107369. /**
  107370. * Billboard mode will only apply to Y axis
  107371. */
  107372. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  107373. /**
  107374. * Billboard mode will apply to all axes
  107375. */
  107376. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  107377. /**
  107378. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  107379. */
  107380. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  107381. return ParticleSystem;
  107382. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  107383. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  107384. /***/ }),
  107385. /***/ "./Particles/particleSystemComponent.ts":
  107386. /*!**********************************************!*\
  107387. !*** ./Particles/particleSystemComponent.ts ***!
  107388. \**********************************************/
  107389. /*! exports provided: _IDoNeedToBeInTheBuild */
  107390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107391. "use strict";
  107392. __webpack_require__.r(__webpack_exports__);
  107393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  107394. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107395. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107396. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  107397. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  107398. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107399. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  107400. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  107401. // Adds the parsers to the scene parsers.
  107402. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  107403. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  107404. if (!individualParser) {
  107405. return;
  107406. }
  107407. // Particles Systems
  107408. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  107409. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  107410. var parsedParticleSystem = parsedData.particleSystems[index];
  107411. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  107412. }
  107413. }
  107414. });
  107415. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  107416. if (parsedParticleSystem.activeParticleCount) {
  107417. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107418. return ps;
  107419. }
  107420. else {
  107421. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107422. return ps;
  107423. }
  107424. });
  107425. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  107426. if (uniformsNames === void 0) { uniformsNames = []; }
  107427. if (samplers === void 0) { samplers = []; }
  107428. if (defines === void 0) { defines = ""; }
  107429. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  107430. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  107431. if (defines.indexOf(" BILLBOARD") === -1) {
  107432. defines += "\n#define BILLBOARD\n";
  107433. }
  107434. if (samplers.indexOf("diffuseSampler") === -1) {
  107435. samplers.push("diffuseSampler");
  107436. }
  107437. return this.createEffect({
  107438. vertex: "particles",
  107439. fragmentElement: fragmentName
  107440. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  107441. };
  107442. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  107443. var results = new Array();
  107444. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107445. var particleSystem = this.getScene().particleSystems[index];
  107446. if (particleSystem.emitter === this) {
  107447. results.push(particleSystem);
  107448. }
  107449. }
  107450. return results;
  107451. };
  107452. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  107453. var results = new Array();
  107454. var descendants = this.getDescendants();
  107455. descendants.push(this);
  107456. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107457. var particleSystem = this.getScene().particleSystems[index];
  107458. var emitter = particleSystem.emitter;
  107459. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  107460. results.push(particleSystem);
  107461. }
  107462. }
  107463. return results;
  107464. };
  107465. /**
  107466. * @hidden
  107467. */
  107468. var _IDoNeedToBeInTheBuild = 42;
  107469. /***/ }),
  107470. /***/ "./Particles/particleSystemSet.ts":
  107471. /*!****************************************!*\
  107472. !*** ./Particles/particleSystemSet.ts ***!
  107473. \****************************************/
  107474. /*! exports provided: ParticleSystemSet */
  107475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107476. "use strict";
  107477. __webpack_require__.r(__webpack_exports__);
  107478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  107479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107480. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  107481. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107482. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107483. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  107484. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  107485. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107486. /** Internal class used to store shapes for emitters */
  107487. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  107488. function ParticleSystemSetEmitterCreationOptions() {
  107489. }
  107490. return ParticleSystemSetEmitterCreationOptions;
  107491. }());
  107492. /**
  107493. * Represents a set of particle systems working together to create a specific effect
  107494. */
  107495. var ParticleSystemSet = /** @class */ (function () {
  107496. function ParticleSystemSet() {
  107497. /**
  107498. * Gets the particle system list
  107499. */
  107500. this.systems = new Array();
  107501. }
  107502. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  107503. /**
  107504. * Gets the emitter node used with this set
  107505. */
  107506. get: function () {
  107507. return this._emitterNode;
  107508. },
  107509. enumerable: true,
  107510. configurable: true
  107511. });
  107512. /**
  107513. * Creates a new emitter mesh as a sphere
  107514. * @param options defines the options used to create the sphere
  107515. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107516. * @param scene defines the hosting scene
  107517. */
  107518. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  107519. if (this._emitterNode) {
  107520. this._emitterNode.dispose();
  107521. }
  107522. this._emitterCreationOptions = {
  107523. kind: "Sphere",
  107524. options: options,
  107525. renderingGroupId: renderingGroupId
  107526. };
  107527. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  107528. emitterMesh.renderingGroupId = renderingGroupId;
  107529. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  107530. material.emissiveColor = options.color;
  107531. emitterMesh.material = material;
  107532. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107533. var system = _a[_i];
  107534. system.emitter = emitterMesh;
  107535. }
  107536. this._emitterNode = emitterMesh;
  107537. };
  107538. /**
  107539. * Starts all particle systems of the set
  107540. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107541. */
  107542. ParticleSystemSet.prototype.start = function (emitter) {
  107543. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107544. var system = _a[_i];
  107545. if (emitter) {
  107546. system.emitter = emitter;
  107547. }
  107548. system.start();
  107549. }
  107550. };
  107551. /**
  107552. * Release all associated resources
  107553. */
  107554. ParticleSystemSet.prototype.dispose = function () {
  107555. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107556. var system = _a[_i];
  107557. system.dispose();
  107558. }
  107559. this.systems = [];
  107560. if (this._emitterNode) {
  107561. this._emitterNode.dispose();
  107562. this._emitterNode = null;
  107563. }
  107564. };
  107565. /**
  107566. * Serialize the set into a JSON compatible object
  107567. * @returns a JSON compatible representation of the set
  107568. */
  107569. ParticleSystemSet.prototype.serialize = function () {
  107570. var result = {};
  107571. result.systems = [];
  107572. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107573. var system = _a[_i];
  107574. result.systems.push(system.serialize());
  107575. }
  107576. if (this._emitterNode) {
  107577. result.emitter = this._emitterCreationOptions;
  107578. }
  107579. return result;
  107580. };
  107581. /**
  107582. * Parse a new ParticleSystemSet from a serialized source
  107583. * @param data defines a JSON compatible representation of the set
  107584. * @param scene defines the hosting scene
  107585. * @param gpu defines if we want GPU particles or CPU particles
  107586. * @returns a new ParticleSystemSet
  107587. */
  107588. ParticleSystemSet.Parse = function (data, scene, gpu) {
  107589. if (gpu === void 0) { gpu = false; }
  107590. var result = new ParticleSystemSet();
  107591. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  107592. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  107593. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  107594. var system = _a[_i];
  107595. 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));
  107596. }
  107597. if (data.emitter) {
  107598. var options = data.emitter.options;
  107599. switch (data.emitter.kind) {
  107600. case "Sphere":
  107601. result.setEmitterAsSphere({
  107602. diameter: options.diameter,
  107603. segments: options.segments,
  107604. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  107605. }, data.emitter.renderingGroupId, scene);
  107606. break;
  107607. }
  107608. }
  107609. return result;
  107610. };
  107611. return ParticleSystemSet;
  107612. }());
  107613. /***/ }),
  107614. /***/ "./Particles/solidParticle.ts":
  107615. /*!************************************!*\
  107616. !*** ./Particles/solidParticle.ts ***!
  107617. \************************************/
  107618. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  107619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107620. "use strict";
  107621. __webpack_require__.r(__webpack_exports__);
  107622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  107623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  107624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  107625. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107626. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107627. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  107628. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  107629. /**
  107630. * Represents one particle of a solid particle system.
  107631. */
  107632. var SolidParticle = /** @class */ (function () {
  107633. /**
  107634. * Creates a Solid Particle object.
  107635. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107636. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  107637. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107638. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107639. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107640. * @param shapeId (integer) is the model shape identifier in the SPS.
  107641. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107642. * @param sps defines the sps it is associated to
  107643. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107644. */
  107645. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  107646. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  107647. /**
  107648. * particle global index
  107649. */
  107650. this.idx = 0;
  107651. /**
  107652. * The color of the particle
  107653. */
  107654. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107655. /**
  107656. * The world space position of the particle.
  107657. */
  107658. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107659. /**
  107660. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107661. */
  107662. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107663. /**
  107664. * The scaling of the particle.
  107665. */
  107666. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  107667. /**
  107668. * The uvs of the particle.
  107669. */
  107670. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  107671. /**
  107672. * The current speed of the particle.
  107673. */
  107674. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107675. /**
  107676. * The pivot point in the particle local space.
  107677. */
  107678. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107679. /**
  107680. * Must the particle be translated from its pivot point in its local space ?
  107681. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107682. * Default : false
  107683. */
  107684. this.translateFromPivot = false;
  107685. /**
  107686. * Is the particle active or not ?
  107687. */
  107688. this.alive = true;
  107689. /**
  107690. * Is the particle visible or not ?
  107691. */
  107692. this.isVisible = true;
  107693. /**
  107694. * Index of this particle in the global "positions" array (Internal use)
  107695. * @hidden
  107696. */
  107697. this._pos = 0;
  107698. /**
  107699. * @hidden Index of this particle in the global "indices" array (Internal use)
  107700. */
  107701. this._ind = 0;
  107702. /**
  107703. * ModelShape id of this particle
  107704. */
  107705. this.shapeId = 0;
  107706. /**
  107707. * Index of the particle in its shape id (Internal use)
  107708. */
  107709. this.idxInShape = 0;
  107710. /**
  107711. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107712. */
  107713. this._stillInvisible = false;
  107714. /**
  107715. * @hidden Last computed particle rotation matrix
  107716. */
  107717. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  107718. /**
  107719. * Parent particle Id, if any.
  107720. * Default null.
  107721. */
  107722. this.parentId = null;
  107723. /**
  107724. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107725. * The possible values are :
  107726. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107727. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107728. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107729. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107730. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107731. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107732. * */
  107733. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  107734. /**
  107735. * @hidden Internal global position in the SPS.
  107736. */
  107737. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107738. this.idx = particleIndex;
  107739. this._pos = positionIndex;
  107740. this._ind = indiceIndex;
  107741. this._model = model;
  107742. this.shapeId = shapeId;
  107743. this.idxInShape = idxInShape;
  107744. this._sps = sps;
  107745. if (modelBoundingInfo) {
  107746. this._modelBoundingInfo = modelBoundingInfo;
  107747. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  107748. }
  107749. }
  107750. Object.defineProperty(SolidParticle.prototype, "scale", {
  107751. /**
  107752. * Legacy support, changed scale to scaling
  107753. */
  107754. get: function () {
  107755. return this.scaling;
  107756. },
  107757. /**
  107758. * Legacy support, changed scale to scaling
  107759. */
  107760. set: function (scale) {
  107761. this.scaling = scale;
  107762. },
  107763. enumerable: true,
  107764. configurable: true
  107765. });
  107766. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  107767. /**
  107768. * Legacy support, changed quaternion to rotationQuaternion
  107769. */
  107770. get: function () {
  107771. return this.rotationQuaternion;
  107772. },
  107773. /**
  107774. * Legacy support, changed quaternion to rotationQuaternion
  107775. */
  107776. set: function (q) {
  107777. this.rotationQuaternion = q;
  107778. },
  107779. enumerable: true,
  107780. configurable: true
  107781. });
  107782. /**
  107783. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107784. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107785. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107786. * @returns true if it intersects
  107787. */
  107788. SolidParticle.prototype.intersectsMesh = function (target) {
  107789. if (!this._boundingInfo || !target._boundingInfo) {
  107790. return false;
  107791. }
  107792. if (this._sps._bSphereOnly) {
  107793. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  107794. }
  107795. return this._boundingInfo.intersects(target._boundingInfo, false);
  107796. };
  107797. /**
  107798. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107799. * A particle is in the frustum if its bounding box intersects the frustum
  107800. * @param frustumPlanes defines the frustum to test
  107801. * @returns true if the particle is in the frustum planes
  107802. */
  107803. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  107804. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  107805. };
  107806. /**
  107807. * get the rotation matrix of the particle
  107808. * @hidden
  107809. */
  107810. SolidParticle.prototype.getRotationMatrix = function (m) {
  107811. var quaternion;
  107812. if (this.rotationQuaternion) {
  107813. quaternion = this.rotationQuaternion;
  107814. }
  107815. else {
  107816. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107817. var rotation = this.rotation;
  107818. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107819. }
  107820. quaternion.toRotationMatrix(m);
  107821. };
  107822. return SolidParticle;
  107823. }());
  107824. /**
  107825. * Represents the shape of the model used by one particle of a solid particle system.
  107826. * SPS internal tool, don't use it manually.
  107827. */
  107828. var ModelShape = /** @class */ (function () {
  107829. /**
  107830. * 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.
  107831. * SPS internal tool, don't use it manually.
  107832. * @hidden
  107833. */
  107834. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  107835. /**
  107836. * length of the shape in the model indices array (internal use)
  107837. * @hidden
  107838. */
  107839. this._indicesLength = 0;
  107840. this.shapeID = id;
  107841. this._shape = shape;
  107842. this._indicesLength = indicesLength;
  107843. this._shapeUV = shapeUV;
  107844. this._positionFunction = posFunction;
  107845. this._vertexFunction = vtxFunction;
  107846. }
  107847. return ModelShape;
  107848. }());
  107849. /**
  107850. * Represents a Depth Sorted Particle in the solid particle system.
  107851. */
  107852. var DepthSortedParticle = /** @class */ (function () {
  107853. function DepthSortedParticle() {
  107854. /**
  107855. * Index of the particle in the "indices" array
  107856. */
  107857. this.ind = 0;
  107858. /**
  107859. * Length of the particle shape in the "indices" array
  107860. */
  107861. this.indicesLength = 0;
  107862. /**
  107863. * Squared distance from the particle to the camera
  107864. */
  107865. this.sqDistance = 0.0;
  107866. }
  107867. return DepthSortedParticle;
  107868. }());
  107869. /***/ }),
  107870. /***/ "./Particles/solidParticleSystem.ts":
  107871. /*!******************************************!*\
  107872. !*** ./Particles/solidParticleSystem.ts ***!
  107873. \******************************************/
  107874. /*! exports provided: SolidParticleSystem */
  107875. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107876. "use strict";
  107877. __webpack_require__.r(__webpack_exports__);
  107878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  107879. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107880. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  107881. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  107882. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107883. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  107884. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107885. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  107886. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107887. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  107888. /**
  107889. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107890. *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.
  107891. * The SPS is also a particle system. It provides some methods to manage the particles.
  107892. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107893. *
  107894. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  107895. */
  107896. var SolidParticleSystem = /** @class */ (function () {
  107897. /**
  107898. * Creates a SPS (Solid Particle System) object.
  107899. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107900. * @param scene (Scene) is the scene in which the SPS is added.
  107901. * @param options defines the options of the sps e.g.
  107902. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107903. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107904. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107905. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107906. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107907. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107908. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107909. */
  107910. function SolidParticleSystem(name, scene, options) {
  107911. /**
  107912. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107913. * Example : var p = SPS.particles[i];
  107914. */
  107915. this.particles = new Array();
  107916. /**
  107917. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107918. */
  107919. this.nbParticles = 0;
  107920. /**
  107921. * If the particles must ever face the camera (default false). Useful for planar particles.
  107922. */
  107923. this.billboard = false;
  107924. /**
  107925. * Recompute normals when adding a shape
  107926. */
  107927. this.recomputeNormals = true;
  107928. /**
  107929. * This a counter ofr your own usage. It's not set by any SPS functions.
  107930. */
  107931. this.counter = 0;
  107932. /**
  107933. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107934. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  107935. */
  107936. this.vars = {};
  107937. /**
  107938. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107939. * @hidden
  107940. */
  107941. this._bSphereOnly = false;
  107942. /**
  107943. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107944. * @hidden
  107945. */
  107946. this._bSphereRadiusFactor = 1.0;
  107947. this._positions = new Array();
  107948. this._indices = new Array();
  107949. this._normals = new Array();
  107950. this._colors = new Array();
  107951. this._uvs = new Array();
  107952. this._index = 0; // indices index
  107953. this._updatable = true;
  107954. this._pickable = false;
  107955. this._isVisibilityBoxLocked = false;
  107956. this._alwaysVisible = false;
  107957. this._depthSort = false;
  107958. this._shapeCounter = 0;
  107959. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  107960. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107961. this._computeParticleColor = true;
  107962. this._computeParticleTexture = true;
  107963. this._computeParticleRotation = true;
  107964. this._computeParticleVertex = false;
  107965. this._computeBoundingBox = false;
  107966. this._depthSortParticles = true;
  107967. this._mustUnrotateFixedNormals = false;
  107968. this._particlesIntersect = false;
  107969. this._needs32Bits = false;
  107970. this.name = name;
  107971. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  107972. this._camera = scene.activeCamera;
  107973. this._pickable = options ? options.isPickable : false;
  107974. this._depthSort = options ? options.enableDepthSort : false;
  107975. this._particlesIntersect = options ? options.particleIntersection : false;
  107976. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  107977. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  107978. if (options && options.updatable !== undefined) {
  107979. this._updatable = options.updatable;
  107980. }
  107981. else {
  107982. this._updatable = true;
  107983. }
  107984. if (this._pickable) {
  107985. this.pickedParticles = [];
  107986. }
  107987. if (this._depthSort) {
  107988. this.depthSortedParticles = [];
  107989. }
  107990. }
  107991. /**
  107992. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107993. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107994. * @returns the created mesh
  107995. */
  107996. SolidParticleSystem.prototype.buildMesh = function () {
  107997. if (this.nbParticles === 0) {
  107998. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  107999. this.addShape(triangle, 1);
  108000. triangle.dispose();
  108001. }
  108002. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  108003. this._positions32 = new Float32Array(this._positions);
  108004. this._uvs32 = new Float32Array(this._uvs);
  108005. this._colors32 = new Float32Array(this._colors);
  108006. if (this.recomputeNormals) {
  108007. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  108008. }
  108009. this._normals32 = new Float32Array(this._normals);
  108010. this._fixedNormal32 = new Float32Array(this._normals);
  108011. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  108012. this._unrotateFixedNormals();
  108013. }
  108014. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  108015. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  108016. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108017. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108018. if (this._uvs32.length > 0) {
  108019. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108020. }
  108021. if (this._colors32.length > 0) {
  108022. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108023. }
  108024. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  108025. vertexData.applyToMesh(mesh, this._updatable);
  108026. this.mesh = mesh;
  108027. this.mesh.isPickable = this._pickable;
  108028. // free memory
  108029. if (!this._depthSort) {
  108030. this._indices = null;
  108031. }
  108032. this._positions = null;
  108033. this._normals = null;
  108034. this._uvs = null;
  108035. this._colors = null;
  108036. if (!this._updatable) {
  108037. this.particles.length = 0;
  108038. }
  108039. return mesh;
  108040. };
  108041. /**
  108042. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108043. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108044. * Thus the particles generated from `digest()` have their property `position` set yet.
  108045. * @param mesh ( Mesh ) is the mesh to be digested
  108046. * @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
  108047. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108048. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108049. * @returns the current SPS
  108050. */
  108051. SolidParticleSystem.prototype.digest = function (mesh, options) {
  108052. var size = (options && options.facetNb) || 1;
  108053. var number = (options && options.number) || 0;
  108054. var delta = (options && options.delta) || 0;
  108055. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108056. var meshInd = mesh.getIndices();
  108057. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108058. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108059. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108060. var f = 0; // facet counter
  108061. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  108062. // compute size from number
  108063. if (number) {
  108064. number = (number > totalFacets) ? totalFacets : number;
  108065. size = Math.round(totalFacets / number);
  108066. delta = 0;
  108067. }
  108068. else {
  108069. size = (size > totalFacets) ? totalFacets : size;
  108070. }
  108071. var facetPos = []; // submesh positions
  108072. var facetInd = []; // submesh indices
  108073. var facetUV = []; // submesh UV
  108074. var facetCol = []; // submesh colors
  108075. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108076. var sizeO = size;
  108077. while (f < totalFacets) {
  108078. size = sizeO + Math.floor((1 + delta) * Math.random());
  108079. if (f > totalFacets - size) {
  108080. size = totalFacets - f;
  108081. }
  108082. // reset temp arrays
  108083. facetPos.length = 0;
  108084. facetInd.length = 0;
  108085. facetUV.length = 0;
  108086. facetCol.length = 0;
  108087. // iterate over "size" facets
  108088. var fi = 0;
  108089. for (var j = f * 3; j < (f + size) * 3; j++) {
  108090. facetInd.push(fi);
  108091. var i = meshInd[j];
  108092. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  108093. if (meshUV) {
  108094. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  108095. }
  108096. if (meshCol) {
  108097. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  108098. }
  108099. fi++;
  108100. }
  108101. // create a model shape for each single particle
  108102. var idx = this.nbParticles;
  108103. var shape = this._posToShape(facetPos);
  108104. var shapeUV = this._uvsToShapeUV(facetUV);
  108105. // compute the barycenter of the shape
  108106. var v;
  108107. for (v = 0; v < shape.length; v++) {
  108108. barycenter.addInPlace(shape[v]);
  108109. }
  108110. barycenter.scaleInPlace(1 / shape.length);
  108111. // shift the shape from its barycenter to the origin
  108112. for (v = 0; v < shape.length; v++) {
  108113. shape[v].subtractInPlace(barycenter);
  108114. }
  108115. var bInfo;
  108116. if (this._particlesIntersect) {
  108117. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  108118. }
  108119. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  108120. // add the particle in the SPS
  108121. var currentPos = this._positions.length;
  108122. var currentInd = this._indices.length;
  108123. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  108124. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  108125. // initialize the particle position
  108126. this.particles[this.nbParticles].position.addInPlace(barycenter);
  108127. this._index += shape.length;
  108128. idx++;
  108129. this.nbParticles++;
  108130. this._shapeCounter++;
  108131. f += size;
  108132. }
  108133. return this;
  108134. };
  108135. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108136. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  108137. var index = 0;
  108138. var idx = 0;
  108139. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108140. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  108141. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108142. for (var p = 0; p < this.particles.length; p++) {
  108143. var particle = this.particles[p];
  108144. var shape = particle._model._shape;
  108145. // computing the inverse of the rotation matrix from the quaternion
  108146. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  108147. if (particle.rotationQuaternion) {
  108148. particle.rotationQuaternion.conjugateToRef(quaternion);
  108149. }
  108150. else {
  108151. var rotation = particle.rotation;
  108152. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  108153. quaternion.conjugateInPlace();
  108154. }
  108155. quaternion.toRotationMatrix(invertedRotMatrix);
  108156. for (var pt = 0; pt < shape.length; pt++) {
  108157. idx = index + pt * 3;
  108158. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  108159. tmpNormal.toArray(this._fixedNormal32, idx);
  108160. }
  108161. index = idx + 3;
  108162. }
  108163. };
  108164. //reset copy
  108165. SolidParticleSystem.prototype._resetCopy = function () {
  108166. var copy = this._copy;
  108167. copy.position.setAll(0);
  108168. copy.rotation.setAll(0);
  108169. copy.rotationQuaternion = null;
  108170. copy.scaling.setAll(1);
  108171. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  108172. copy.color = null;
  108173. copy.translateFromPivot = false;
  108174. };
  108175. // _meshBuilder : inserts the shape model in the global SPS mesh
  108176. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  108177. var i;
  108178. var u = 0;
  108179. var c = 0;
  108180. var n = 0;
  108181. this._resetCopy();
  108182. var copy = this._copy;
  108183. if (options && options.positionFunction) { // call to custom positionFunction
  108184. options.positionFunction(copy, idx, idxInShape);
  108185. this._mustUnrotateFixedNormals = true;
  108186. }
  108187. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108188. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108189. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108190. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108191. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108192. copy.getRotationMatrix(rotMatrix);
  108193. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  108194. if (copy.translateFromPivot) {
  108195. pivotBackTranslation.setAll(0.0);
  108196. }
  108197. else {
  108198. pivotBackTranslation.copyFrom(scaledPivot);
  108199. }
  108200. for (i = 0; i < shape.length; i++) {
  108201. tmpVertex.copyFrom(shape[i]);
  108202. if (options && options.vertexFunction) {
  108203. options.vertexFunction(copy, tmpVertex, i);
  108204. }
  108205. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108206. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108207. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  108208. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  108209. if (meshUV) {
  108210. var copyUvs = copy.uvs;
  108211. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  108212. u += 2;
  108213. }
  108214. if (copy.color) {
  108215. this._color = copy.color;
  108216. }
  108217. else {
  108218. var color = this._color;
  108219. if (meshCol && meshCol[c] !== undefined) {
  108220. color.r = meshCol[c];
  108221. color.g = meshCol[c + 1];
  108222. color.b = meshCol[c + 2];
  108223. color.a = meshCol[c + 3];
  108224. }
  108225. else {
  108226. color.r = 1.0;
  108227. color.g = 1.0;
  108228. color.b = 1.0;
  108229. color.a = 1.0;
  108230. }
  108231. }
  108232. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  108233. c += 4;
  108234. if (!this.recomputeNormals && meshNor) {
  108235. tmpVertex.x = meshNor[n];
  108236. tmpVertex.y = meshNor[n + 1];
  108237. tmpVertex.z = meshNor[n + 2];
  108238. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  108239. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  108240. n += 3;
  108241. }
  108242. }
  108243. for (i = 0; i < meshInd.length; i++) {
  108244. var current_ind = p + meshInd[i];
  108245. indices.push(current_ind);
  108246. if (current_ind > 65535) {
  108247. this._needs32Bits = true;
  108248. }
  108249. }
  108250. if (this._pickable) {
  108251. var nbfaces = meshInd.length / 3;
  108252. for (i = 0; i < nbfaces; i++) {
  108253. this.pickedParticles.push({ idx: idx, faceId: i });
  108254. }
  108255. }
  108256. if (this._depthSort) {
  108257. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  108258. }
  108259. return copy;
  108260. };
  108261. // returns a shape array from positions array
  108262. SolidParticleSystem.prototype._posToShape = function (positions) {
  108263. var shape = [];
  108264. for (var i = 0; i < positions.length; i += 3) {
  108265. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  108266. }
  108267. return shape;
  108268. };
  108269. // returns a shapeUV array from a Vector4 uvs
  108270. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  108271. var shapeUV = [];
  108272. if (uvs) {
  108273. for (var i = 0; i < uvs.length; i++) {
  108274. shapeUV.push(uvs[i]);
  108275. }
  108276. }
  108277. return shapeUV;
  108278. };
  108279. // adds a new particle object in the particles array
  108280. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  108281. if (bInfo === void 0) { bInfo = null; }
  108282. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  108283. this.particles.push(sp);
  108284. return sp;
  108285. };
  108286. /**
  108287. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108288. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  108289. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108290. * @param nb (positive integer) the number of particles to be created from this model
  108291. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108292. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108293. * @returns the number of shapes in the system
  108294. */
  108295. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  108296. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108297. var meshInd = mesh.getIndices();
  108298. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108299. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108300. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108301. var bbInfo;
  108302. if (this._particlesIntersect) {
  108303. bbInfo = mesh.getBoundingInfo();
  108304. }
  108305. var shape = this._posToShape(meshPos);
  108306. var shapeUV = this._uvsToShapeUV(meshUV);
  108307. var posfunc = options ? options.positionFunction : null;
  108308. var vtxfunc = options ? options.vertexFunction : null;
  108309. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  108310. // particles
  108311. var sp;
  108312. var currentCopy;
  108313. var idx = this.nbParticles;
  108314. for (var i = 0; i < nb; i++) {
  108315. var currentPos = this._positions.length;
  108316. var currentInd = this._indices.length;
  108317. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  108318. if (this._updatable) {
  108319. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  108320. sp.position.copyFrom(currentCopy.position);
  108321. sp.rotation.copyFrom(currentCopy.rotation);
  108322. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  108323. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  108324. }
  108325. if (currentCopy.color && sp.color) {
  108326. sp.color.copyFrom(currentCopy.color);
  108327. }
  108328. sp.scaling.copyFrom(currentCopy.scaling);
  108329. sp.uvs.copyFrom(currentCopy.uvs);
  108330. }
  108331. this._index += shape.length;
  108332. idx++;
  108333. }
  108334. this.nbParticles += nb;
  108335. this._shapeCounter++;
  108336. return this._shapeCounter - 1;
  108337. };
  108338. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108339. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  108340. this._resetCopy();
  108341. var copy = this._copy;
  108342. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  108343. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  108344. }
  108345. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108346. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108347. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108348. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108349. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108350. copy.getRotationMatrix(rotMatrix);
  108351. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  108352. if (copy.translateFromPivot) {
  108353. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  108354. }
  108355. else {
  108356. pivotBackTranslation.copyFrom(scaledPivot);
  108357. }
  108358. var shape = particle._model._shape;
  108359. for (var pt = 0; pt < shape.length; pt++) {
  108360. tmpVertex.copyFrom(shape[pt]);
  108361. if (particle._model._vertexFunction) {
  108362. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  108363. }
  108364. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108365. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108366. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  108367. }
  108368. particle.position.setAll(0.0);
  108369. particle.rotation.setAll(0.0);
  108370. particle.rotationQuaternion = null;
  108371. particle.scaling.setAll(1.0);
  108372. particle.uvs.setAll(0.0);
  108373. particle.pivot.setAll(0.0);
  108374. particle.translateFromPivot = false;
  108375. particle.parentId = null;
  108376. };
  108377. /**
  108378. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108379. * @returns the SPS.
  108380. */
  108381. SolidParticleSystem.prototype.rebuildMesh = function () {
  108382. for (var p = 0; p < this.particles.length; p++) {
  108383. this._rebuildParticle(this.particles[p]);
  108384. }
  108385. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  108386. return this;
  108387. };
  108388. /**
  108389. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108390. * This method calls `updateParticle()` for each particle of the SPS.
  108391. * For an animated SPS, it is usually called within the render loop.
  108392. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108393. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108394. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108395. * @returns the SPS.
  108396. */
  108397. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  108398. if (start === void 0) { start = 0; }
  108399. if (end === void 0) { end = this.nbParticles - 1; }
  108400. if (update === void 0) { update = true; }
  108401. if (!this._updatable) {
  108402. return this;
  108403. }
  108404. // custom beforeUpdate
  108405. this.beforeUpdateParticles(start, end, update);
  108406. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108407. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  108408. var mesh = this.mesh;
  108409. var colors32 = this._colors32;
  108410. var positions32 = this._positions32;
  108411. var normals32 = this._normals32;
  108412. var uvs32 = this._uvs32;
  108413. var indices32 = this._indices32;
  108414. var indices = this._indices;
  108415. var fixedNormal32 = this._fixedNormal32;
  108416. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  108417. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  108418. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  108419. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  108420. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  108421. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  108422. var camInvertedPosition = tempVectors[10].setAll(0);
  108423. // cases when the World Matrix is to be computed first
  108424. if (this.billboard || this._depthSort) {
  108425. this.mesh.computeWorldMatrix(true);
  108426. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  108427. }
  108428. // if the particles will always face the camera
  108429. if (this.billboard) {
  108430. // compute the camera position and un-rotate it by the current mesh rotation
  108431. var tmpVertex = tempVectors[0];
  108432. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  108433. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  108434. camAxisZ.normalize();
  108435. // same for camera up vector extracted from the cam view matrix
  108436. var view = this._camera.getViewMatrix(true);
  108437. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  108438. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  108439. camAxisY.normalize();
  108440. camAxisX.normalize();
  108441. }
  108442. // if depthSort, compute the camera global position in the mesh local system
  108443. if (this._depthSort) {
  108444. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  108445. }
  108446. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  108447. var idx = 0; // current position index in the global array positions32
  108448. var index = 0; // position start index in the global array positions32 of the current particle
  108449. var colidx = 0; // current color index in the global array colors32
  108450. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  108451. var uvidx = 0; // current uv index in the global array uvs32
  108452. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  108453. var pt = 0; // current index in the particle model shape
  108454. if (this.mesh.isFacetDataEnabled) {
  108455. this._computeBoundingBox = true;
  108456. }
  108457. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  108458. if (this._computeBoundingBox) {
  108459. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  108460. var boundingInfo = this.mesh._boundingInfo;
  108461. if (boundingInfo) {
  108462. minimum.copyFrom(boundingInfo.minimum);
  108463. maximum.copyFrom(boundingInfo.maximum);
  108464. }
  108465. }
  108466. }
  108467. // particle loop
  108468. index = this.particles[start]._pos;
  108469. var vpos = (index / 3) | 0;
  108470. colorIndex = vpos * 4;
  108471. uvIndex = vpos * 2;
  108472. for (var p = start; p <= end; p++) {
  108473. var particle = this.particles[p];
  108474. // call to custom user function to update the particle properties
  108475. this.updateParticle(particle);
  108476. var shape = particle._model._shape;
  108477. var shapeUV = particle._model._shapeUV;
  108478. var particleRotationMatrix = particle._rotationMatrix;
  108479. var particlePosition = particle.position;
  108480. var particleRotation = particle.rotation;
  108481. var particleScaling = particle.scaling;
  108482. var particleGlobalPosition = particle._globalPosition;
  108483. // camera-particle distance for depth sorting
  108484. if (this._depthSort && this._depthSortParticles) {
  108485. var dsp = this.depthSortedParticles[p];
  108486. dsp.ind = particle._ind;
  108487. dsp.indicesLength = particle._model._indicesLength;
  108488. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  108489. }
  108490. // skip the computations for inactive or already invisible particles
  108491. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  108492. // increment indexes for the next particle
  108493. pt = shape.length;
  108494. index += pt * 3;
  108495. colorIndex += pt * 4;
  108496. uvIndex += pt * 2;
  108497. continue;
  108498. }
  108499. if (particle.isVisible) {
  108500. particle._stillInvisible = false; // un-mark permanent invisibility
  108501. var scaledPivot = tempVectors[12];
  108502. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  108503. // particle rotation matrix
  108504. if (this.billboard) {
  108505. particleRotation.x = 0.0;
  108506. particleRotation.y = 0.0;
  108507. }
  108508. if (this._computeParticleRotation || this.billboard) {
  108509. particle.getRotationMatrix(rotMatrix);
  108510. }
  108511. var particleHasParent = (particle.parentId !== null);
  108512. if (particleHasParent) {
  108513. var parent_1 = this.particles[particle.parentId];
  108514. var parentRotationMatrix = parent_1._rotationMatrix;
  108515. var parentGlobalPosition = parent_1._globalPosition;
  108516. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  108517. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  108518. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  108519. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  108520. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  108521. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  108522. if (this._computeParticleRotation || this.billboard) {
  108523. var rotMatrixValues = rotMatrix.m;
  108524. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  108525. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  108526. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  108527. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  108528. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  108529. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  108530. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  108531. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  108532. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  108533. }
  108534. }
  108535. else {
  108536. particleGlobalPosition.x = particlePosition.x;
  108537. particleGlobalPosition.y = particlePosition.y;
  108538. particleGlobalPosition.z = particlePosition.z;
  108539. if (this._computeParticleRotation || this.billboard) {
  108540. var rotMatrixValues = rotMatrix.m;
  108541. particleRotationMatrix[0] = rotMatrixValues[0];
  108542. particleRotationMatrix[1] = rotMatrixValues[1];
  108543. particleRotationMatrix[2] = rotMatrixValues[2];
  108544. particleRotationMatrix[3] = rotMatrixValues[4];
  108545. particleRotationMatrix[4] = rotMatrixValues[5];
  108546. particleRotationMatrix[5] = rotMatrixValues[6];
  108547. particleRotationMatrix[6] = rotMatrixValues[8];
  108548. particleRotationMatrix[7] = rotMatrixValues[9];
  108549. particleRotationMatrix[8] = rotMatrixValues[10];
  108550. }
  108551. }
  108552. var pivotBackTranslation = tempVectors[11];
  108553. if (particle.translateFromPivot) {
  108554. pivotBackTranslation.setAll(0.0);
  108555. }
  108556. else {
  108557. pivotBackTranslation.copyFrom(scaledPivot);
  108558. }
  108559. // particle vertex loop
  108560. for (pt = 0; pt < shape.length; pt++) {
  108561. idx = index + pt * 3;
  108562. colidx = colorIndex + pt * 4;
  108563. uvidx = uvIndex + pt * 2;
  108564. var tmpVertex = tempVectors[0];
  108565. tmpVertex.copyFrom(shape[pt]);
  108566. if (this._computeParticleVertex) {
  108567. this.updateParticleVertex(particle, tmpVertex, pt);
  108568. }
  108569. // positions
  108570. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  108571. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  108572. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  108573. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  108574. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  108575. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  108576. rotatedX += pivotBackTranslation.x;
  108577. rotatedY += pivotBackTranslation.y;
  108578. rotatedZ += pivotBackTranslation.z;
  108579. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108580. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108581. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108582. if (this._computeBoundingBox) {
  108583. minimum.minimizeInPlaceFromFloats(px, py, pz);
  108584. maximum.maximizeInPlaceFromFloats(px, py, pz);
  108585. }
  108586. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  108587. if (!this._computeParticleVertex) {
  108588. var normalx = fixedNormal32[idx];
  108589. var normaly = fixedNormal32[idx + 1];
  108590. var normalz = fixedNormal32[idx + 2];
  108591. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  108592. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  108593. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  108594. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  108595. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  108596. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  108597. }
  108598. if (this._computeParticleColor && particle.color) {
  108599. var color = particle.color;
  108600. var colors32_1 = this._colors32;
  108601. colors32_1[colidx] = color.r;
  108602. colors32_1[colidx + 1] = color.g;
  108603. colors32_1[colidx + 2] = color.b;
  108604. colors32_1[colidx + 3] = color.a;
  108605. }
  108606. if (this._computeParticleTexture) {
  108607. var uvs = particle.uvs;
  108608. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108609. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108610. }
  108611. }
  108612. }
  108613. // particle just set invisible : scaled to zero and positioned at the origin
  108614. else {
  108615. particle._stillInvisible = true; // mark the particle as invisible
  108616. for (pt = 0; pt < shape.length; pt++) {
  108617. idx = index + pt * 3;
  108618. colidx = colorIndex + pt * 4;
  108619. uvidx = uvIndex + pt * 2;
  108620. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  108621. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  108622. if (this._computeParticleColor && particle.color) {
  108623. var color = particle.color;
  108624. colors32[colidx] = color.r;
  108625. colors32[colidx + 1] = color.g;
  108626. colors32[colidx + 2] = color.b;
  108627. colors32[colidx + 3] = color.a;
  108628. }
  108629. if (this._computeParticleTexture) {
  108630. var uvs = particle.uvs;
  108631. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108632. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108633. }
  108634. }
  108635. }
  108636. // if the particle intersections must be computed : update the bbInfo
  108637. if (this._particlesIntersect) {
  108638. var bInfo = particle._boundingInfo;
  108639. var bBox = bInfo.boundingBox;
  108640. var bSphere = bInfo.boundingSphere;
  108641. var modelBoundingInfo = particle._modelBoundingInfo;
  108642. if (!this._bSphereOnly) {
  108643. // place, scale and rotate the particle bbox within the SPS local system, then update it
  108644. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  108645. var tempMin = tempVectors[1];
  108646. var tempMax = tempVectors[2];
  108647. tempMin.setAll(Number.MAX_VALUE);
  108648. tempMax.setAll(-Number.MAX_VALUE);
  108649. for (var b = 0; b < 8; b++) {
  108650. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  108651. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  108652. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  108653. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  108654. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  108655. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  108656. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108657. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108658. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108659. tempMin.minimizeInPlaceFromFloats(x, y, z);
  108660. tempMax.maximizeInPlaceFromFloats(x, y, z);
  108661. }
  108662. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  108663. }
  108664. // place and scale the particle bouding sphere in the SPS local system, then update it
  108665. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  108666. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  108667. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  108668. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  108669. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  108670. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  108671. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  108672. }
  108673. // increment indexes for the next particle
  108674. index = idx + 3;
  108675. colorIndex = colidx + 4;
  108676. uvIndex = uvidx + 2;
  108677. }
  108678. // if the VBO must be updated
  108679. if (update) {
  108680. if (this._computeParticleColor) {
  108681. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  108682. }
  108683. if (this._computeParticleTexture) {
  108684. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  108685. }
  108686. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  108687. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  108688. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  108689. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  108690. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  108691. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  108692. for (var i = 0; i < normals32.length; i++) {
  108693. fixedNormal32[i] = normals32[i];
  108694. }
  108695. }
  108696. if (!mesh.areNormalsFrozen) {
  108697. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  108698. }
  108699. }
  108700. if (this._depthSort && this._depthSortParticles) {
  108701. var depthSortedParticles = this.depthSortedParticles;
  108702. depthSortedParticles.sort(depthSortFunction);
  108703. var dspl = depthSortedParticles.length;
  108704. var sid = 0;
  108705. for (var sorted = 0; sorted < dspl; sorted++) {
  108706. var lind = depthSortedParticles[sorted].indicesLength;
  108707. var sind = depthSortedParticles[sorted].ind;
  108708. for (var i = 0; i < lind; i++) {
  108709. indices32[sid] = indices[sind + i];
  108710. sid++;
  108711. }
  108712. }
  108713. mesh.updateIndices(indices32);
  108714. }
  108715. }
  108716. if (this._computeBoundingBox) {
  108717. if (mesh._boundingInfo) {
  108718. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  108719. }
  108720. else {
  108721. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  108722. }
  108723. }
  108724. this.afterUpdateParticles(start, end, update);
  108725. return this;
  108726. };
  108727. /**
  108728. * Disposes the SPS.
  108729. */
  108730. SolidParticleSystem.prototype.dispose = function () {
  108731. this.mesh.dispose();
  108732. this.vars = null;
  108733. // drop references to internal big arrays for the GC
  108734. this._positions = null;
  108735. this._indices = null;
  108736. this._normals = null;
  108737. this._uvs = null;
  108738. this._colors = null;
  108739. this._indices32 = null;
  108740. this._positions32 = null;
  108741. this._normals32 = null;
  108742. this._fixedNormal32 = null;
  108743. this._uvs32 = null;
  108744. this._colors32 = null;
  108745. this.pickedParticles = null;
  108746. };
  108747. /**
  108748. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108749. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108750. * @returns the SPS.
  108751. */
  108752. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  108753. if (!this._isVisibilityBoxLocked) {
  108754. this.mesh.refreshBoundingInfo();
  108755. }
  108756. return this;
  108757. };
  108758. /**
  108759. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108760. * @param size the size (float) of the visibility box
  108761. * note : this doesn't lock the SPS mesh bounding box.
  108762. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108763. */
  108764. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  108765. var vis = size / 2;
  108766. 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));
  108767. };
  108768. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  108769. /**
  108770. * Gets whether the SPS as always visible or not
  108771. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108772. */
  108773. get: function () {
  108774. return this._alwaysVisible;
  108775. },
  108776. /**
  108777. * Sets the SPS as always visible or not
  108778. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108779. */
  108780. set: function (val) {
  108781. this._alwaysVisible = val;
  108782. this.mesh.alwaysSelectAsActiveMesh = val;
  108783. },
  108784. enumerable: true,
  108785. configurable: true
  108786. });
  108787. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  108788. /**
  108789. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108791. */
  108792. get: function () {
  108793. return this._isVisibilityBoxLocked;
  108794. },
  108795. /**
  108796. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108797. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108798. */
  108799. set: function (val) {
  108800. this._isVisibilityBoxLocked = val;
  108801. var boundingInfo = this.mesh.getBoundingInfo();
  108802. boundingInfo.isLocked = val;
  108803. },
  108804. enumerable: true,
  108805. configurable: true
  108806. });
  108807. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  108808. /**
  108809. * Gets if `setParticles()` computes the particle rotations or not.
  108810. * Default value : true. The SPS is faster when it's set to false.
  108811. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108812. */
  108813. get: function () {
  108814. return this._computeParticleRotation;
  108815. },
  108816. /**
  108817. * Tells to `setParticles()` to compute the particle rotations or not.
  108818. * Default value : true. The SPS is faster when it's set to false.
  108819. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108820. */
  108821. set: function (val) {
  108822. this._computeParticleRotation = val;
  108823. },
  108824. enumerable: true,
  108825. configurable: true
  108826. });
  108827. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  108828. /**
  108829. * Gets if `setParticles()` computes the particle colors or not.
  108830. * Default value : true. The SPS is faster when it's set to false.
  108831. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108832. */
  108833. get: function () {
  108834. return this._computeParticleColor;
  108835. },
  108836. /**
  108837. * Tells to `setParticles()` to compute the particle colors or not.
  108838. * Default value : true. The SPS is faster when it's set to false.
  108839. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108840. */
  108841. set: function (val) {
  108842. this._computeParticleColor = val;
  108843. },
  108844. enumerable: true,
  108845. configurable: true
  108846. });
  108847. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  108848. /**
  108849. * Gets if `setParticles()` computes the particle textures or not.
  108850. * Default value : true. The SPS is faster when it's set to false.
  108851. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108852. */
  108853. get: function () {
  108854. return this._computeParticleTexture;
  108855. },
  108856. set: function (val) {
  108857. this._computeParticleTexture = val;
  108858. },
  108859. enumerable: true,
  108860. configurable: true
  108861. });
  108862. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  108863. /**
  108864. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108865. * Default value : false. The SPS is faster when it's set to false.
  108866. * Note : the particle custom vertex positions aren't stored values.
  108867. */
  108868. get: function () {
  108869. return this._computeParticleVertex;
  108870. },
  108871. /**
  108872. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108873. * Default value : false. The SPS is faster when it's set to false.
  108874. * Note : the particle custom vertex positions aren't stored values.
  108875. */
  108876. set: function (val) {
  108877. this._computeParticleVertex = val;
  108878. },
  108879. enumerable: true,
  108880. configurable: true
  108881. });
  108882. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  108883. /**
  108884. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108885. */
  108886. get: function () {
  108887. return this._computeBoundingBox;
  108888. },
  108889. /**
  108890. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108891. */
  108892. set: function (val) {
  108893. this._computeBoundingBox = val;
  108894. },
  108895. enumerable: true,
  108896. configurable: true
  108897. });
  108898. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  108899. /**
  108900. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108901. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108902. * Default : `true`
  108903. */
  108904. get: function () {
  108905. return this._depthSortParticles;
  108906. },
  108907. /**
  108908. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108909. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108910. * Default : `true`
  108911. */
  108912. set: function (val) {
  108913. this._depthSortParticles = val;
  108914. },
  108915. enumerable: true,
  108916. configurable: true
  108917. });
  108918. // =======================================================================
  108919. // Particle behavior logic
  108920. // these following methods may be overwritten by the user to fit his needs
  108921. /**
  108922. * This function does nothing. It may be overwritten to set all the particle first values.
  108923. * The SPS doesn't call this function, you may have to call it by your own.
  108924. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108925. */
  108926. SolidParticleSystem.prototype.initParticles = function () {
  108927. };
  108928. /**
  108929. * This function does nothing. It may be overwritten to recycle a particle.
  108930. * The SPS doesn't call this function, you may have to call it by your own.
  108931. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108932. * @param particle The particle to recycle
  108933. * @returns the recycled particle
  108934. */
  108935. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  108936. return particle;
  108937. };
  108938. /**
  108939. * Updates a particle : this function should be overwritten by the user.
  108940. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108941. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108942. * @example : just set a particle position or velocity and recycle conditions
  108943. * @param particle The particle to update
  108944. * @returns the updated particle
  108945. */
  108946. SolidParticleSystem.prototype.updateParticle = function (particle) {
  108947. return particle;
  108948. };
  108949. /**
  108950. * Updates a vertex of a particle : it can be overwritten by the user.
  108951. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108952. * @param particle the current particle
  108953. * @param vertex the current index of the current particle
  108954. * @param pt the index of the current vertex in the particle shape
  108955. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  108956. * @example : just set a vertex particle position
  108957. * @returns the updated vertex
  108958. */
  108959. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  108960. return vertex;
  108961. };
  108962. /**
  108963. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108964. * This does nothing and may be overwritten by the user.
  108965. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108966. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108967. * @param update the boolean update value actually passed to setParticles()
  108968. */
  108969. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  108970. };
  108971. /**
  108972. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108973. * This will be passed three parameters.
  108974. * This does nothing and may be overwritten by the user.
  108975. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108976. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108977. * @param update the boolean update value actually passed to setParticles()
  108978. */
  108979. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  108980. };
  108981. return SolidParticleSystem;
  108982. }());
  108983. /***/ }),
  108984. /***/ "./Particles/subEmitter.ts":
  108985. /*!*********************************!*\
  108986. !*** ./Particles/subEmitter.ts ***!
  108987. \*********************************/
  108988. /*! exports provided: SubEmitterType, SubEmitter */
  108989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108990. "use strict";
  108991. __webpack_require__.r(__webpack_exports__);
  108992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  108993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  108994. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108995. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108996. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108997. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  108998. /**
  108999. * Type of sub emitter
  109000. */
  109001. var SubEmitterType;
  109002. (function (SubEmitterType) {
  109003. /**
  109004. * Attached to the particle over it's lifetime
  109005. */
  109006. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  109007. /**
  109008. * Created when the particle dies
  109009. */
  109010. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  109011. })(SubEmitterType || (SubEmitterType = {}));
  109012. /**
  109013. * Sub emitter class used to emit particles from an existing particle
  109014. */
  109015. var SubEmitter = /** @class */ (function () {
  109016. /**
  109017. * Creates a sub emitter
  109018. * @param particleSystem the particle system to be used by the sub emitter
  109019. */
  109020. function SubEmitter(
  109021. /**
  109022. * the particle system to be used by the sub emitter
  109023. */
  109024. particleSystem) {
  109025. this.particleSystem = particleSystem;
  109026. /**
  109027. * Type of the submitter (Default: END)
  109028. */
  109029. this.type = SubEmitterType.END;
  109030. /**
  109031. * 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)
  109032. * Note: This only is supported when using an emitter of type Mesh
  109033. */
  109034. this.inheritDirection = false;
  109035. /**
  109036. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  109037. */
  109038. this.inheritedVelocityAmount = 0;
  109039. // Create mesh as emitter to support rotation
  109040. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  109041. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  109042. }
  109043. // Automatically dispose of subemitter when system is disposed
  109044. particleSystem.onDisposeObservable.add(function () {
  109045. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  109046. particleSystem.emitter.dispose();
  109047. }
  109048. });
  109049. }
  109050. /**
  109051. * Clones the sub emitter
  109052. * @returns the cloned sub emitter
  109053. */
  109054. SubEmitter.prototype.clone = function () {
  109055. // Clone particle system
  109056. var emitter = this.particleSystem.emitter;
  109057. if (!emitter) {
  109058. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109059. }
  109060. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  109061. emitter = emitter.clone();
  109062. }
  109063. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  109064. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  109065. emitter.isVisible = false;
  109066. }
  109067. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  109068. // Clone properties
  109069. clone.type = this.type;
  109070. clone.inheritDirection = this.inheritDirection;
  109071. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  109072. clone.particleSystem._disposeEmitterOnDispose = true;
  109073. clone.particleSystem.disposeOnStop = true;
  109074. return clone;
  109075. };
  109076. /**
  109077. * Serialize current object to a JSON object
  109078. * @returns the serialized object
  109079. */
  109080. SubEmitter.prototype.serialize = function () {
  109081. var serializationObject = {};
  109082. serializationObject.type = this.type;
  109083. serializationObject.inheritDirection = this.inheritDirection;
  109084. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  109085. serializationObject.particleSystem = this.particleSystem.serialize();
  109086. return serializationObject;
  109087. };
  109088. /** @hidden */
  109089. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  109090. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  109091. };
  109092. /**
  109093. * Creates a new SubEmitter from a serialized JSON version
  109094. * @param serializationObject defines the JSON object to read from
  109095. * @param scene defines the hosting scene
  109096. * @param rootUrl defines the rootUrl for data loading
  109097. * @returns a new SubEmitter
  109098. */
  109099. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  109100. var system = serializationObject.particleSystem;
  109101. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  109102. subEmitter.type = serializationObject.type;
  109103. subEmitter.inheritDirection = serializationObject.inheritDirection;
  109104. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  109105. subEmitter.particleSystem._isSubEmitter = true;
  109106. return subEmitter;
  109107. };
  109108. /** Release associated resources */
  109109. SubEmitter.prototype.dispose = function () {
  109110. this.particleSystem.dispose();
  109111. };
  109112. return SubEmitter;
  109113. }());
  109114. /***/ }),
  109115. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  109116. /*!*****************************************!*\
  109117. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  109118. \*****************************************/
  109119. /*! exports provided: AmmoJSPlugin */
  109120. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109121. "use strict";
  109122. __webpack_require__.r(__webpack_exports__);
  109123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  109124. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109125. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109126. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109127. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109128. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109129. /**
  109130. * AmmoJS Physics plugin
  109131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109132. * @see https://github.com/kripken/ammo.js/
  109133. */
  109134. var AmmoJSPlugin = /** @class */ (function () {
  109135. /**
  109136. * Initializes the ammoJS plugin
  109137. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109138. * @param ammoInjection can be used to inject your own ammo reference
  109139. */
  109140. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  109141. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109142. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  109143. var _this = this;
  109144. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109145. /**
  109146. * Reference to the Ammo library
  109147. */
  109148. this.bjsAMMO = {};
  109149. /**
  109150. * Name of the plugin
  109151. */
  109152. this.name = "AmmoJSPlugin";
  109153. this._timeStep = 1 / 60;
  109154. this._fixedTimeStep = 1 / 60;
  109155. this._maxSteps = 5;
  109156. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  109157. this._tmpContactCallbackResult = false;
  109158. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109159. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  109160. if (typeof ammoInjection === "function") {
  109161. ammoInjection(this.bjsAMMO);
  109162. }
  109163. else {
  109164. this.bjsAMMO = ammoInjection;
  109165. }
  109166. if (!this.isSupported()) {
  109167. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  109168. return;
  109169. }
  109170. // Initialize the physics world
  109171. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  109172. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  109173. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  109174. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  109175. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  109176. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  109177. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  109178. // Create temp ammo variables
  109179. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  109180. this._tmpAmmoTransform.setIdentity();
  109181. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  109182. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  109183. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  109184. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  109185. }
  109186. /**
  109187. * Sets the gravity of the physics world (m/(s^2))
  109188. * @param gravity Gravity to set
  109189. */
  109190. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  109191. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  109192. this.world.setGravity(this._tmpAmmoVectorA);
  109193. };
  109194. /**
  109195. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109196. * @param timeStep timestep to use in seconds
  109197. */
  109198. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  109199. this._timeStep = timeStep;
  109200. };
  109201. /**
  109202. * 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)
  109203. * @param fixedTimeStep fixedTimeStep to use in seconds
  109204. */
  109205. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  109206. this._fixedTimeStep = fixedTimeStep;
  109207. };
  109208. /**
  109209. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109210. * @param maxSteps the maximum number of steps by the physics engine per frame
  109211. */
  109212. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  109213. this._maxSteps = maxSteps;
  109214. };
  109215. /**
  109216. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109217. * @returns the current timestep in seconds
  109218. */
  109219. AmmoJSPlugin.prototype.getTimeStep = function () {
  109220. return this._timeStep;
  109221. };
  109222. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  109223. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  109224. this._tmpContactCallbackResult = false;
  109225. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109226. return this._tmpContactCallbackResult;
  109227. };
  109228. // Ammo's collision events have some weird quirks
  109229. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  109230. // so only fire event if both contactTest and contactPairTest have a hit
  109231. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  109232. this._tmpContactCallbackResult = false;
  109233. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109234. return this._tmpContactCallbackResult;
  109235. };
  109236. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  109237. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  109238. //
  109239. // When maxSteps is 0 do the entire simulation in one step
  109240. // 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)
  109241. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  109242. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  109243. if (timeStep === void 0) { timeStep = 1 / 60; }
  109244. if (maxSteps === void 0) { maxSteps = 10; }
  109245. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  109246. if (maxSteps == 0) {
  109247. this.world.stepSimulation(timeStep, 0);
  109248. }
  109249. else {
  109250. while (maxSteps > 0 && timeStep > 0) {
  109251. if (timeStep - fixedTimeStep < fixedTimeStep) {
  109252. this.world.stepSimulation(timeStep, 0);
  109253. timeStep = 0;
  109254. }
  109255. else {
  109256. timeStep -= fixedTimeStep;
  109257. this.world.stepSimulation(fixedTimeStep, 0);
  109258. }
  109259. maxSteps--;
  109260. }
  109261. }
  109262. };
  109263. /**
  109264. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109265. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109266. * After the step the babylon meshes are set to the position of the physics imposters
  109267. * @param delta amount of time to step forward
  109268. * @param impostors array of imposters to update before/after the step
  109269. */
  109270. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  109271. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  109272. var impostor = impostors_1[_i];
  109273. // Update physics world objects to match babylon world
  109274. impostor.beforeStep();
  109275. }
  109276. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  109277. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  109278. var mainImpostor = impostors_2[_a];
  109279. // After physics update make babylon world objects match physics world objects
  109280. mainImpostor.afterStep();
  109281. // Handle collision event
  109282. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  109283. if (this._isImpostorInContact(mainImpostor)) {
  109284. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  109285. var collideCallback = _c[_b];
  109286. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  109287. var otherImpostor = _e[_d];
  109288. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  109289. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  109290. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  109291. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  109292. }
  109293. }
  109294. }
  109295. }
  109296. }
  109297. }
  109298. }
  109299. };
  109300. /**
  109301. * Applies an implulse on the imposter
  109302. * @param impostor imposter to apply impulse
  109303. * @param force amount of force to be applied to the imposter
  109304. * @param contactPoint the location to apply the impulse on the imposter
  109305. */
  109306. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109307. impostor.physicsBody.activate();
  109308. var worldPoint = this._tmpAmmoVectorA;
  109309. var impulse = this._tmpAmmoVectorB;
  109310. // Convert contactPoint into world space
  109311. if (impostor.object && impostor.object.getWorldMatrix) {
  109312. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109313. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109314. contactPoint = this._tmpVector;
  109315. }
  109316. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109317. impulse.setValue(force.x, force.y, force.z);
  109318. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109319. };
  109320. /**
  109321. * Applies a force on the imposter
  109322. * @param impostor imposter to apply force
  109323. * @param force amount of force to be applied to the imposter
  109324. * @param contactPoint the location to apply the force on the imposter
  109325. */
  109326. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109327. impostor.physicsBody.activate();
  109328. var worldPoint = this._tmpAmmoVectorA;
  109329. var impulse = this._tmpAmmoVectorB;
  109330. // Convert contactPoint into world space
  109331. if (impostor.object && impostor.object.getWorldMatrix) {
  109332. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109333. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109334. contactPoint = this._tmpVector;
  109335. }
  109336. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109337. impulse.setValue(force.x, force.y, force.z);
  109338. impostor.physicsBody.applyForce(impulse, worldPoint);
  109339. };
  109340. /**
  109341. * Creates a physics body using the plugin
  109342. * @param impostor the imposter to create the physics body on
  109343. */
  109344. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109345. impostor._pluginData = { toDispose: [] };
  109346. //parent-child relationship
  109347. if (impostor.parent) {
  109348. if (impostor.physicsBody) {
  109349. this.removePhysicsBody(impostor);
  109350. impostor.forceUpdate();
  109351. }
  109352. return;
  109353. }
  109354. if (impostor.isBodyInitRequired()) {
  109355. var colShape = this._createShape(impostor);
  109356. var mass = impostor.getParam("mass");
  109357. impostor._pluginData.mass = mass;
  109358. var localInertia = new Ammo.btVector3(0, 0, 0);
  109359. var startTransform = new Ammo.btTransform();
  109360. startTransform.setIdentity();
  109361. if (mass !== 0) {
  109362. colShape.calculateLocalInertia(mass, localInertia);
  109363. }
  109364. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  109365. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  109366. startTransform.setOrigin(this._tmpAmmoVectorA);
  109367. startTransform.setRotation(this._tmpAmmoQuaternion);
  109368. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  109369. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  109370. var body = new Ammo.btRigidBody(rbInfo);
  109371. // Make objects kinematic if it's mass is 0
  109372. if (mass === 0) {
  109373. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  109374. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  109375. }
  109376. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  109377. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  109378. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  109379. }
  109380. this.world.addRigidBody(body);
  109381. impostor.physicsBody = body;
  109382. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  109383. this.setBodyFriction(impostor, impostor.getParam("friction"));
  109384. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  109385. }
  109386. };
  109387. /**
  109388. * Removes the physics body from the imposter and disposes of the body's memory
  109389. * @param impostor imposter to remove the physics body from
  109390. */
  109391. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109392. var _this = this;
  109393. if (this.world) {
  109394. this.world.removeRigidBody(impostor.physicsBody);
  109395. impostor._pluginData.toDispose.forEach(function (d) {
  109396. _this.bjsAMMO.destroy(d);
  109397. });
  109398. }
  109399. };
  109400. /**
  109401. * Generates a joint
  109402. * @param impostorJoint the imposter joint to create the joint with
  109403. */
  109404. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109405. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109406. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109407. if (!mainBody || !connectedBody) {
  109408. return;
  109409. }
  109410. var jointData = impostorJoint.joint.jointData;
  109411. if (!jointData.mainPivot) {
  109412. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109413. }
  109414. if (!jointData.connectedPivot) {
  109415. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109416. }
  109417. var joint;
  109418. switch (impostorJoint.joint.type) {
  109419. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  109420. var distance = jointData.maxDistance;
  109421. if (distance) {
  109422. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  109423. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  109424. }
  109425. 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));
  109426. break;
  109427. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  109428. if (!jointData.mainAxis) {
  109429. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109430. }
  109431. if (!jointData.connectedAxis) {
  109432. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109433. }
  109434. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  109435. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  109436. 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);
  109437. break;
  109438. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  109439. 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));
  109440. break;
  109441. default:
  109442. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  109443. 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));
  109444. break;
  109445. }
  109446. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  109447. impostorJoint.joint.physicsJoint = joint;
  109448. };
  109449. /**
  109450. * Removes a joint
  109451. * @param impostorJoint the imposter joint to remove the joint from
  109452. */
  109453. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109454. if (this.world) {
  109455. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  109456. }
  109457. };
  109458. // adds all verticies (including child verticies) to the triangle mesh
  109459. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  109460. var _this = this;
  109461. var triangleCount = 0;
  109462. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  109463. var indices = object.getIndices();
  109464. if (!indices) {
  109465. indices = [];
  109466. }
  109467. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  109468. if (!vertexPositions) {
  109469. vertexPositions = [];
  109470. }
  109471. object.computeWorldMatrix(false);
  109472. var faceCount = indices.length / 3;
  109473. for (var i = 0; i < faceCount; i++) {
  109474. var triPoints = [];
  109475. for (var point = 0; point < 3; point++) {
  109476. 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]);
  109477. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  109478. v.subtractInPlace(topLevelObject.position);
  109479. var vec;
  109480. if (point == 0) {
  109481. vec = this._tmpAmmoVectorA;
  109482. }
  109483. else if (point == 1) {
  109484. vec = this._tmpAmmoVectorB;
  109485. }
  109486. else {
  109487. vec = this._tmpAmmoVectorC;
  109488. }
  109489. vec.setValue(v.x, v.y, v.z);
  109490. triPoints.push(vec);
  109491. }
  109492. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  109493. triangleCount++;
  109494. }
  109495. object.getChildMeshes().forEach(function (m) {
  109496. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  109497. });
  109498. }
  109499. return triangleCount;
  109500. };
  109501. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  109502. var _this = this;
  109503. if (ignoreChildren === void 0) { ignoreChildren = false; }
  109504. var object = impostor.object;
  109505. var returnValue;
  109506. var extendSize = impostor.getObjectExtendSize();
  109507. if (!ignoreChildren) {
  109508. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  109509. returnValue = new Ammo.btCompoundShape();
  109510. // Add shape of all children to the compound shape
  109511. var childrenAdded = 0;
  109512. meshChildren.forEach(function (childMesh) {
  109513. var childImpostor = childMesh.getPhysicsImpostor();
  109514. if (childImpostor) {
  109515. var shape = _this._createShape(childImpostor);
  109516. // Position needs to be scaled based on parent's scaling
  109517. var parentMat = childMesh.parent.getWorldMatrix().clone();
  109518. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109519. parentMat.decompose(s);
  109520. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  109521. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  109522. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  109523. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  109524. childImpostor.dispose();
  109525. childrenAdded++;
  109526. }
  109527. });
  109528. if (childrenAdded > 0) {
  109529. // Add parents shape as a child if present
  109530. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  109531. var shape = this._createShape(impostor, true);
  109532. if (shape) {
  109533. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  109534. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  109535. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  109536. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  109537. }
  109538. }
  109539. return returnValue;
  109540. }
  109541. else {
  109542. // If no children with impostors create the actual shape below instead
  109543. Ammo.destroy(returnValue);
  109544. returnValue = null;
  109545. }
  109546. }
  109547. switch (impostor.type) {
  109548. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  109549. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109550. break;
  109551. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  109552. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109553. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  109554. break;
  109555. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  109556. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  109557. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109558. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  109559. break;
  109560. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  109561. var tetraMesh = new Ammo.btTriangleMesh();
  109562. impostor._pluginData.toDispose.concat([tetraMesh]);
  109563. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  109564. if (triangeCount == 0) {
  109565. returnValue = new Ammo.btCompoundShape();
  109566. }
  109567. else {
  109568. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  109569. }
  109570. break;
  109571. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  109572. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  109573. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109574. break;
  109575. default:
  109576. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  109577. break;
  109578. }
  109579. return returnValue;
  109580. };
  109581. /**
  109582. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109583. * @param impostor imposter containing the physics body and babylon object
  109584. */
  109585. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109586. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109587. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  109588. if (!impostor.object.rotationQuaternion) {
  109589. if (impostor.object.rotation) {
  109590. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109591. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  109592. }
  109593. }
  109594. else {
  109595. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109596. }
  109597. };
  109598. /**
  109599. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109600. * @param impostor imposter containing the physics body and babylon object
  109601. * @param newPosition new position
  109602. * @param newRotation new rotation
  109603. */
  109604. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109605. var trans = impostor.physicsBody.getWorldTransform();
  109606. // If rotation/position has changed update and activate riged body
  109607. if (trans.getOrigin().x() != newPosition.x ||
  109608. trans.getOrigin().y() != newPosition.y ||
  109609. trans.getOrigin().z() != newPosition.z ||
  109610. trans.getRotation().x() != newRotation.x ||
  109611. trans.getRotation().y() != newRotation.y ||
  109612. trans.getRotation().z() != newRotation.z ||
  109613. trans.getRotation().w() != newRotation.w) {
  109614. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  109615. trans.setOrigin(this._tmpAmmoVectorA);
  109616. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  109617. trans.setRotation(this._tmpAmmoQuaternion);
  109618. impostor.physicsBody.setWorldTransform(trans);
  109619. if (impostor.mass == 0) {
  109620. // Kinematic objects must be updated using motion state
  109621. var motionState = impostor.physicsBody.getMotionState();
  109622. if (motionState) {
  109623. motionState.setWorldTransform(trans);
  109624. }
  109625. }
  109626. else {
  109627. impostor.physicsBody.activate();
  109628. }
  109629. }
  109630. };
  109631. /**
  109632. * If this plugin is supported
  109633. * @returns true if its supported
  109634. */
  109635. AmmoJSPlugin.prototype.isSupported = function () {
  109636. return this.bjsAMMO !== undefined;
  109637. };
  109638. /**
  109639. * Sets the linear velocity of the physics body
  109640. * @param impostor imposter to set the velocity on
  109641. * @param velocity velocity to set
  109642. */
  109643. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109644. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109645. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  109646. };
  109647. /**
  109648. * Sets the angular velocity of the physics body
  109649. * @param impostor imposter to set the velocity on
  109650. * @param velocity velocity to set
  109651. */
  109652. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109653. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109654. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  109655. };
  109656. /**
  109657. * gets the linear velocity
  109658. * @param impostor imposter to get linear velocity from
  109659. * @returns linear velocity
  109660. */
  109661. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109662. var v = impostor.physicsBody.getLinearVelocity();
  109663. if (!v) {
  109664. return null;
  109665. }
  109666. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109667. };
  109668. /**
  109669. * gets the angular velocity
  109670. * @param impostor imposter to get angular velocity from
  109671. * @returns angular velocity
  109672. */
  109673. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109674. var v = impostor.physicsBody.getAngularVelocity();
  109675. if (!v) {
  109676. return null;
  109677. }
  109678. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109679. };
  109680. /**
  109681. * Sets the mass of physics body
  109682. * @param impostor imposter to set the mass on
  109683. * @param mass mass to set
  109684. */
  109685. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109686. impostor.physicsBody.setMassProps(mass);
  109687. impostor._pluginData.mass = mass;
  109688. };
  109689. /**
  109690. * Gets the mass of the physics body
  109691. * @param impostor imposter to get the mass from
  109692. * @returns mass
  109693. */
  109694. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  109695. return impostor._pluginData.mass;
  109696. };
  109697. /**
  109698. * Gets friction of the impostor
  109699. * @param impostor impostor to get friction from
  109700. * @returns friction value
  109701. */
  109702. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  109703. return impostor._pluginData.friction;
  109704. };
  109705. /**
  109706. * Sets friction of the impostor
  109707. * @param impostor impostor to set friction on
  109708. * @param friction friction value
  109709. */
  109710. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109711. impostor.physicsBody.setFriction(friction);
  109712. impostor._pluginData.friction = friction;
  109713. };
  109714. /**
  109715. * Gets restitution of the impostor
  109716. * @param impostor impostor to get restitution from
  109717. * @returns restitution value
  109718. */
  109719. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109720. return impostor._pluginData.restitution;
  109721. };
  109722. /**
  109723. * Sets resitution of the impostor
  109724. * @param impostor impostor to set resitution on
  109725. * @param restitution resitution value
  109726. */
  109727. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109728. impostor.physicsBody.setRestitution(restitution);
  109729. impostor._pluginData.restitution = restitution;
  109730. };
  109731. /**
  109732. * Sleeps the physics body and stops it from being active
  109733. * @param impostor impostor to sleep
  109734. */
  109735. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  109736. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  109737. };
  109738. /**
  109739. * Activates the physics body
  109740. * @param impostor impostor to activate
  109741. */
  109742. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  109743. impostor.physicsBody.activate();
  109744. };
  109745. /**
  109746. * Updates the distance parameters of the joint
  109747. * @param joint joint to update
  109748. * @param maxDistance maximum distance of the joint
  109749. * @param minDistance minimum distance of the joint
  109750. */
  109751. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  109752. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  109753. };
  109754. /**
  109755. * Sets a motor on the joint
  109756. * @param joint joint to set motor on
  109757. * @param speed speed of the motor
  109758. * @param maxForce maximum force of the motor
  109759. * @param motorIndex index of the motor
  109760. */
  109761. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109762. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  109763. };
  109764. /**
  109765. * Sets the motors limit
  109766. * @param joint joint to set limit on
  109767. * @param upperLimit upper limit
  109768. * @param lowerLimit lower limit
  109769. */
  109770. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109771. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  109772. };
  109773. /**
  109774. * Syncs the position and rotation of a mesh with the impostor
  109775. * @param mesh mesh to sync
  109776. * @param impostor impostor to update the mesh with
  109777. */
  109778. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109779. var body = impostor.physicsBody;
  109780. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109781. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  109782. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  109783. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  109784. if (mesh.rotationQuaternion) {
  109785. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  109786. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  109787. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  109788. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  109789. }
  109790. };
  109791. /**
  109792. * Gets the radius of the impostor
  109793. * @param impostor impostor to get radius from
  109794. * @returns the radius
  109795. */
  109796. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  109797. var exntend = impostor.getObjectExtendSize();
  109798. return exntend.x / 2;
  109799. };
  109800. /**
  109801. * Gets the box size of the impostor
  109802. * @param impostor impostor to get box size from
  109803. * @param result the resulting box size
  109804. */
  109805. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109806. var exntend = impostor.getObjectExtendSize();
  109807. result.x = exntend.x;
  109808. result.y = exntend.y;
  109809. result.z = exntend.z;
  109810. };
  109811. /**
  109812. * Disposes of the impostor
  109813. */
  109814. AmmoJSPlugin.prototype.dispose = function () {
  109815. // Dispose of world
  109816. Ammo.destroy(this.world);
  109817. Ammo.destroy(this._solver);
  109818. Ammo.destroy(this._overlappingPairCache);
  109819. Ammo.destroy(this._dispatcher);
  109820. Ammo.destroy(this._collisionConfiguration);
  109821. // Dispose of tmp variables
  109822. Ammo.destroy(this._tmpAmmoVectorA);
  109823. Ammo.destroy(this._tmpAmmoVectorB);
  109824. Ammo.destroy(this._tmpAmmoVectorC);
  109825. Ammo.destroy(this._tmpAmmoTransform);
  109826. Ammo.destroy(this._tmpAmmoQuaternion);
  109827. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  109828. this.world = null;
  109829. };
  109830. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  109831. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  109832. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  109833. return AmmoJSPlugin;
  109834. }());
  109835. /***/ }),
  109836. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  109837. /*!*******************************************!*\
  109838. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  109839. \*******************************************/
  109840. /*! exports provided: CannonJSPlugin */
  109841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109842. "use strict";
  109843. __webpack_require__.r(__webpack_exports__);
  109844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  109845. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109846. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109847. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109848. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109849. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109850. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  109851. /** @hidden */
  109852. var CannonJSPlugin = /** @class */ (function () {
  109853. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  109854. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109855. if (iterations === void 0) { iterations = 10; }
  109856. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  109857. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109858. this.name = "CannonJSPlugin";
  109859. this._physicsMaterials = new Array();
  109860. this._fixedTimeStep = 1 / 60;
  109861. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  109862. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  109863. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109864. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109865. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  109866. this.BJSCANNON = cannonInjection;
  109867. if (!this.isSupported()) {
  109868. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  109869. return;
  109870. }
  109871. this._extendNamespace();
  109872. this.world = new this.BJSCANNON.World();
  109873. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  109874. this.world.solver.iterations = iterations;
  109875. }
  109876. CannonJSPlugin.prototype.setGravity = function (gravity) {
  109877. this.world.gravity.copy(gravity);
  109878. };
  109879. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  109880. this._fixedTimeStep = timeStep;
  109881. };
  109882. CannonJSPlugin.prototype.getTimeStep = function () {
  109883. return this._fixedTimeStep;
  109884. };
  109885. CannonJSPlugin.prototype.executeStep = function (delta) {
  109886. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  109887. };
  109888. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109889. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109890. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109891. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109892. };
  109893. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109894. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109895. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109896. impostor.physicsBody.applyForce(impulse, worldPoint);
  109897. };
  109898. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109899. //parent-child relationship. Does this impostor has a parent impostor?
  109900. if (impostor.parent) {
  109901. if (impostor.physicsBody) {
  109902. this.removePhysicsBody(impostor);
  109903. //TODO is that needed?
  109904. impostor.forceUpdate();
  109905. }
  109906. return;
  109907. }
  109908. //should a new body be created for this impostor?
  109909. if (impostor.isBodyInitRequired()) {
  109910. var shape = this._createShape(impostor);
  109911. //unregister events, if body is being changed
  109912. var oldBody = impostor.physicsBody;
  109913. if (oldBody) {
  109914. this.removePhysicsBody(impostor);
  109915. }
  109916. //create the body and material
  109917. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  109918. var bodyCreationObject = {
  109919. mass: impostor.getParam("mass"),
  109920. material: material
  109921. };
  109922. // A simple extend, in case native options were used.
  109923. var nativeOptions = impostor.getParam("nativeOptions");
  109924. for (var key in nativeOptions) {
  109925. if (nativeOptions.hasOwnProperty(key)) {
  109926. bodyCreationObject[key] = nativeOptions[key];
  109927. }
  109928. }
  109929. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  109930. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  109931. this.world.addEventListener("preStep", impostor.beforeStep);
  109932. this.world.addEventListener("postStep", impostor.afterStep);
  109933. impostor.physicsBody.addShape(shape);
  109934. this.world.add(impostor.physicsBody);
  109935. //try to keep the body moving in the right direction by taking old properties.
  109936. //Should be tested!
  109937. if (oldBody) {
  109938. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  109939. impostor.physicsBody[param].copy(oldBody[param]);
  109940. });
  109941. }
  109942. this._processChildMeshes(impostor);
  109943. }
  109944. //now update the body's transformation
  109945. this._updatePhysicsBodyTransformation(impostor);
  109946. };
  109947. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  109948. var _this = this;
  109949. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  109950. var currentRotation = mainImpostor.object.rotationQuaternion;
  109951. if (meshChildren.length) {
  109952. var processMesh = function (localPosition, mesh) {
  109953. if (!currentRotation || !mesh.rotationQuaternion) {
  109954. return;
  109955. }
  109956. var childImpostor = mesh.getPhysicsImpostor();
  109957. if (childImpostor) {
  109958. var parent = childImpostor.parent;
  109959. if (parent !== mainImpostor) {
  109960. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  109961. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  109962. if (childImpostor.physicsBody) {
  109963. _this.removePhysicsBody(childImpostor);
  109964. childImpostor.physicsBody = null;
  109965. }
  109966. childImpostor.parent = mainImpostor;
  109967. childImpostor.resetUpdateFlags();
  109968. 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));
  109969. //Add the mass of the children.
  109970. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  109971. }
  109972. }
  109973. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  109974. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  109975. };
  109976. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  109977. }
  109978. };
  109979. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109980. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  109981. this.world.removeEventListener("preStep", impostor.beforeStep);
  109982. this.world.removeEventListener("postStep", impostor.afterStep);
  109983. this.world.remove(impostor.physicsBody);
  109984. };
  109985. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109986. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109987. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109988. if (!mainBody || !connectedBody) {
  109989. return;
  109990. }
  109991. var constraint;
  109992. var jointData = impostorJoint.joint.jointData;
  109993. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  109994. var constraintData = {
  109995. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  109996. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  109997. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  109998. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  109999. maxForce: jointData.nativeParams.maxForce,
  110000. collideConnected: !!jointData.collision
  110001. };
  110002. switch (impostorJoint.joint.type) {
  110003. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  110004. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  110005. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  110006. break;
  110007. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  110008. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  110009. break;
  110010. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  110011. var springData = jointData;
  110012. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  110013. restLength: springData.length,
  110014. stiffness: springData.stiffness,
  110015. damping: springData.damping,
  110016. localAnchorA: constraintData.pivotA,
  110017. localAnchorB: constraintData.pivotB
  110018. });
  110019. break;
  110020. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  110021. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  110022. break;
  110023. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  110024. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  110025. default:
  110026. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  110027. break;
  110028. }
  110029. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  110030. constraint.collideConnected = !!jointData.collision;
  110031. impostorJoint.joint.physicsJoint = constraint;
  110032. //don't add spring as constraint, as it is not one.
  110033. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  110034. this.world.addConstraint(constraint);
  110035. }
  110036. else {
  110037. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  110038. constraint.applyForce();
  110039. };
  110040. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  110041. }
  110042. };
  110043. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110044. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  110045. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  110046. }
  110047. else {
  110048. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  110049. }
  110050. };
  110051. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  110052. var index;
  110053. var mat;
  110054. for (index = 0; index < this._physicsMaterials.length; index++) {
  110055. mat = this._physicsMaterials[index];
  110056. if (mat.friction === friction && mat.restitution === restitution) {
  110057. return mat;
  110058. }
  110059. }
  110060. var currentMat = new this.BJSCANNON.Material(name);
  110061. currentMat.friction = friction;
  110062. currentMat.restitution = restitution;
  110063. this._physicsMaterials.push(currentMat);
  110064. return currentMat;
  110065. };
  110066. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  110067. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  110068. };
  110069. CannonJSPlugin.prototype._createShape = function (impostor) {
  110070. var object = impostor.object;
  110071. var returnValue;
  110072. var extendSize = impostor.getObjectExtendSize();
  110073. switch (impostor.type) {
  110074. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  110075. var radiusX = extendSize.x;
  110076. var radiusY = extendSize.y;
  110077. var radiusZ = extendSize.z;
  110078. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  110079. break;
  110080. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  110081. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  110082. var nativeParams = impostor.getParam("nativeOptions");
  110083. if (!nativeParams) {
  110084. nativeParams = {};
  110085. }
  110086. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  110087. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  110088. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  110089. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  110090. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  110091. // Rotate 90 degrees as this shape is horizontal in cannon
  110092. var quat = new this.BJSCANNON.Quaternion();
  110093. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  110094. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  110095. returnValue.transformAllPoints(translation, quat);
  110096. break;
  110097. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  110098. var box = extendSize.scale(0.5);
  110099. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  110100. break;
  110101. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  110102. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  110103. returnValue = new this.BJSCANNON.Plane();
  110104. break;
  110105. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  110106. // should transform the vertex data to world coordinates!!
  110107. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  110108. var rawFaces = object.getIndices ? object.getIndices() : [];
  110109. if (!rawVerts) {
  110110. return;
  110111. }
  110112. // get only scale! so the object could transform correctly.
  110113. var oldPosition = object.position.clone();
  110114. var oldRotation = object.rotation && object.rotation.clone();
  110115. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  110116. object.position.copyFromFloats(0, 0, 0);
  110117. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  110118. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  110119. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  110120. var transform = object.computeWorldMatrix(true);
  110121. // convert rawVerts to object space
  110122. var temp = new Array();
  110123. var index;
  110124. for (index = 0; index < rawVerts.length; index += 3) {
  110125. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  110126. }
  110127. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  110128. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  110129. //now set back the transformation!
  110130. object.position.copyFrom(oldPosition);
  110131. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  110132. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  110133. break;
  110134. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  110135. var oldPosition2 = object.position.clone();
  110136. var oldRotation2 = object.rotation && object.rotation.clone();
  110137. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  110138. object.position.copyFromFloats(0, 0, 0);
  110139. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  110140. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  110141. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  110142. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  110143. returnValue = this._createHeightmap(object);
  110144. object.position.copyFrom(oldPosition2);
  110145. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  110146. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  110147. object.computeWorldMatrix(true);
  110148. break;
  110149. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  110150. returnValue = new this.BJSCANNON.Particle();
  110151. break;
  110152. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  110153. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  110154. break;
  110155. }
  110156. return returnValue;
  110157. };
  110158. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  110159. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  110160. var transform = object.computeWorldMatrix(true);
  110161. // convert rawVerts to object space
  110162. var temp = new Array();
  110163. var index;
  110164. for (index = 0; index < pos.length; index += 3) {
  110165. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  110166. }
  110167. pos = temp;
  110168. var matrix = new Array();
  110169. //For now pointDepth will not be used and will be automatically calculated.
  110170. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  110171. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  110172. var boundingInfo = object.getBoundingInfo();
  110173. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  110174. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  110175. var elementSize = dim * 2 / arraySize;
  110176. for (var i = 0; i < pos.length; i = i + 3) {
  110177. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  110178. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  110179. var y = -pos[i + 2] + minY;
  110180. if (!matrix[x]) {
  110181. matrix[x] = [];
  110182. }
  110183. if (!matrix[x][z]) {
  110184. matrix[x][z] = y;
  110185. }
  110186. matrix[x][z] = Math.max(y, matrix[x][z]);
  110187. }
  110188. for (var x = 0; x <= arraySize; ++x) {
  110189. if (!matrix[x]) {
  110190. var loc = 1;
  110191. while (!matrix[(x + loc) % arraySize]) {
  110192. loc++;
  110193. }
  110194. matrix[x] = matrix[(x + loc) % arraySize].slice();
  110195. //console.log("missing x", x);
  110196. }
  110197. for (var z = 0; z <= arraySize; ++z) {
  110198. if (!matrix[x][z]) {
  110199. var loc = 1;
  110200. var newValue;
  110201. while (newValue === undefined) {
  110202. newValue = matrix[x][(z + loc++) % arraySize];
  110203. }
  110204. matrix[x][z] = newValue;
  110205. }
  110206. }
  110207. }
  110208. var shape = new this.BJSCANNON.Heightfield(matrix, {
  110209. elementSize: elementSize
  110210. });
  110211. //For future reference, needed for body transformation
  110212. shape.minY = minY;
  110213. return shape;
  110214. };
  110215. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  110216. var object = impostor.object;
  110217. //make sure it is updated...
  110218. object.computeWorldMatrix && object.computeWorldMatrix(true);
  110219. // The delta between the mesh position and the mesh bounding box center
  110220. var bInfo = object.getBoundingInfo();
  110221. if (!bInfo) {
  110222. return;
  110223. }
  110224. var center = impostor.getObjectCenter();
  110225. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  110226. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  110227. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  110228. this._tmpPosition.copyFrom(center);
  110229. var quaternion = object.rotationQuaternion;
  110230. if (!quaternion) {
  110231. return;
  110232. }
  110233. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  110234. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  110235. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110236. //-90 DEG in X, precalculated
  110237. quaternion = quaternion.multiply(this._minus90X);
  110238. //Invert! (Precalculated, 90 deg in X)
  110239. //No need to clone. this will never change.
  110240. impostor.setDeltaRotation(this._plus90X);
  110241. }
  110242. //If it is a heightfield, if should be centered.
  110243. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110244. var mesh = object;
  110245. var boundingInfo = mesh.getBoundingInfo();
  110246. //calculate the correct body position:
  110247. var rotationQuaternion = mesh.rotationQuaternion;
  110248. mesh.rotationQuaternion = this._tmpUnityRotation;
  110249. mesh.computeWorldMatrix(true);
  110250. //get original center with no rotation
  110251. var c = center.clone();
  110252. var oldPivot = mesh.getPivotMatrix();
  110253. if (oldPivot) {
  110254. // create a copy the pivot Matrix as it is modified in place
  110255. oldPivot = oldPivot.clone();
  110256. }
  110257. else {
  110258. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  110259. }
  110260. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  110261. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  110262. mesh.setPreTransformMatrix(p);
  110263. mesh.computeWorldMatrix(true);
  110264. //calculate the translation
  110265. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  110266. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  110267. //add it inverted to the delta
  110268. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  110269. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  110270. //rotation is back
  110271. mesh.rotationQuaternion = rotationQuaternion;
  110272. mesh.setPreTransformMatrix(oldPivot);
  110273. mesh.computeWorldMatrix(true);
  110274. }
  110275. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  110276. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  110277. //this._tmpPosition.copyFrom(object.position);
  110278. }
  110279. impostor.setDeltaPosition(this._tmpDeltaPosition);
  110280. //Now update the impostor object
  110281. impostor.physicsBody.position.copy(this._tmpPosition);
  110282. impostor.physicsBody.quaternion.copy(quaternion);
  110283. };
  110284. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110285. impostor.object.position.copyFrom(impostor.physicsBody.position);
  110286. if (impostor.object.rotationQuaternion) {
  110287. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  110288. }
  110289. };
  110290. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110291. impostor.physicsBody.position.copy(newPosition);
  110292. impostor.physicsBody.quaternion.copy(newRotation);
  110293. };
  110294. CannonJSPlugin.prototype.isSupported = function () {
  110295. return this.BJSCANNON !== undefined;
  110296. };
  110297. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110298. impostor.physicsBody.velocity.copy(velocity);
  110299. };
  110300. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110301. impostor.physicsBody.angularVelocity.copy(velocity);
  110302. };
  110303. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110304. var v = impostor.physicsBody.velocity;
  110305. if (!v) {
  110306. return null;
  110307. }
  110308. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110309. };
  110310. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110311. var v = impostor.physicsBody.angularVelocity;
  110312. if (!v) {
  110313. return null;
  110314. }
  110315. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110316. };
  110317. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110318. impostor.physicsBody.mass = mass;
  110319. impostor.physicsBody.updateMassProperties();
  110320. };
  110321. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  110322. return impostor.physicsBody.mass;
  110323. };
  110324. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  110325. return impostor.physicsBody.material.friction;
  110326. };
  110327. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110328. impostor.physicsBody.material.friction = friction;
  110329. };
  110330. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110331. return impostor.physicsBody.material.restitution;
  110332. };
  110333. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110334. impostor.physicsBody.material.restitution = restitution;
  110335. };
  110336. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  110337. impostor.physicsBody.sleep();
  110338. };
  110339. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  110340. impostor.physicsBody.wakeUp();
  110341. };
  110342. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  110343. joint.physicsJoint.distance = maxDistance;
  110344. };
  110345. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110346. // if (!motorIndex) {
  110347. // joint.physicsJoint.enableMotor();
  110348. // }
  110349. // }
  110350. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110351. // if (!motorIndex) {
  110352. // joint.physicsJoint.disableMotor();
  110353. // }
  110354. // }
  110355. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  110356. if (!motorIndex) {
  110357. joint.physicsJoint.enableMotor();
  110358. joint.physicsJoint.setMotorSpeed(speed);
  110359. if (maxForce) {
  110360. this.setLimit(joint, maxForce);
  110361. }
  110362. }
  110363. };
  110364. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  110365. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  110366. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  110367. };
  110368. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110369. var body = impostor.physicsBody;
  110370. mesh.position.x = body.position.x;
  110371. mesh.position.y = body.position.y;
  110372. mesh.position.z = body.position.z;
  110373. if (mesh.rotationQuaternion) {
  110374. mesh.rotationQuaternion.x = body.quaternion.x;
  110375. mesh.rotationQuaternion.y = body.quaternion.y;
  110376. mesh.rotationQuaternion.z = body.quaternion.z;
  110377. mesh.rotationQuaternion.w = body.quaternion.w;
  110378. }
  110379. };
  110380. CannonJSPlugin.prototype.getRadius = function (impostor) {
  110381. var shape = impostor.physicsBody.shapes[0];
  110382. return shape.boundingSphereRadius;
  110383. };
  110384. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110385. var shape = impostor.physicsBody.shapes[0];
  110386. result.x = shape.halfExtents.x * 2;
  110387. result.y = shape.halfExtents.y * 2;
  110388. result.z = shape.halfExtents.z * 2;
  110389. };
  110390. CannonJSPlugin.prototype.dispose = function () {
  110391. };
  110392. CannonJSPlugin.prototype._extendNamespace = function () {
  110393. //this will force cannon to execute at least one step when using interpolation
  110394. var step_tmp1 = new this.BJSCANNON.Vec3();
  110395. var Engine = this.BJSCANNON;
  110396. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  110397. maxSubSteps = maxSubSteps || 10;
  110398. timeSinceLastCalled = timeSinceLastCalled || 0;
  110399. if (timeSinceLastCalled === 0) {
  110400. this.internalStep(dt);
  110401. this.time += dt;
  110402. }
  110403. else {
  110404. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  110405. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  110406. var t0 = performance.now();
  110407. for (var i = 0; i !== internalSteps; i++) {
  110408. this.internalStep(dt);
  110409. if (performance.now() - t0 > dt * 1000) {
  110410. break;
  110411. }
  110412. }
  110413. this.time += timeSinceLastCalled;
  110414. var h = this.time % dt;
  110415. var h_div_dt = h / dt;
  110416. var interpvelo = step_tmp1;
  110417. var bodies = this.bodies;
  110418. for (var j = 0; j !== bodies.length; j++) {
  110419. var b = bodies[j];
  110420. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  110421. b.position.vsub(b.previousPosition, interpvelo);
  110422. interpvelo.scale(h_div_dt, interpvelo);
  110423. b.position.vadd(interpvelo, b.interpolatedPosition);
  110424. }
  110425. else {
  110426. b.interpolatedPosition.copy(b.position);
  110427. b.interpolatedQuaternion.copy(b.quaternion);
  110428. }
  110429. }
  110430. }
  110431. };
  110432. };
  110433. return CannonJSPlugin;
  110434. }());
  110435. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  110436. /***/ }),
  110437. /***/ "./Physics/Plugins/index.ts":
  110438. /*!**********************************!*\
  110439. !*** ./Physics/Plugins/index.ts ***!
  110440. \**********************************/
  110441. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110443. "use strict";
  110444. __webpack_require__.r(__webpack_exports__);
  110445. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  110446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  110447. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  110448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  110449. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  110450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  110451. /***/ }),
  110452. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  110453. /*!*****************************************!*\
  110454. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  110455. \*****************************************/
  110456. /*! exports provided: OimoJSPlugin */
  110457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110458. "use strict";
  110459. __webpack_require__.r(__webpack_exports__);
  110460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  110461. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  110462. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  110463. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  110464. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  110465. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  110466. /** @hidden */
  110467. var OimoJSPlugin = /** @class */ (function () {
  110468. function OimoJSPlugin(iterations, oimoInjection) {
  110469. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  110470. this.name = "OimoJSPlugin";
  110471. this._tmpImpostorsArray = [];
  110472. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110473. this.BJSOIMO = oimoInjection;
  110474. this.world = new this.BJSOIMO.World({
  110475. iterations: iterations
  110476. });
  110477. this.world.clear();
  110478. }
  110479. OimoJSPlugin.prototype.setGravity = function (gravity) {
  110480. this.world.gravity.copy(gravity);
  110481. };
  110482. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  110483. this.world.timeStep = timeStep;
  110484. };
  110485. OimoJSPlugin.prototype.getTimeStep = function () {
  110486. return this.world.timeStep;
  110487. };
  110488. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  110489. var _this = this;
  110490. impostors.forEach(function (impostor) {
  110491. impostor.beforeStep();
  110492. });
  110493. this.world.step();
  110494. impostors.forEach(function (impostor) {
  110495. impostor.afterStep();
  110496. //update the ordered impostors array
  110497. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  110498. });
  110499. //check for collisions
  110500. var contact = this.world.contacts;
  110501. while (contact !== null) {
  110502. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  110503. contact = contact.next;
  110504. continue;
  110505. }
  110506. //is this body colliding with any other? get the impostor
  110507. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  110508. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  110509. if (!mainImpostor || !collidingImpostor) {
  110510. contact = contact.next;
  110511. continue;
  110512. }
  110513. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  110514. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  110515. contact = contact.next;
  110516. }
  110517. };
  110518. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  110519. var mass = impostor.physicsBody.mass;
  110520. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  110521. };
  110522. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  110523. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  110524. this.applyImpulse(impostor, force, contactPoint);
  110525. };
  110526. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  110527. var _this = this;
  110528. //parent-child relationship. Does this impostor has a parent impostor?
  110529. if (impostor.parent) {
  110530. if (impostor.physicsBody) {
  110531. this.removePhysicsBody(impostor);
  110532. //TODO is that needed?
  110533. impostor.forceUpdate();
  110534. }
  110535. return;
  110536. }
  110537. if (impostor.isBodyInitRequired()) {
  110538. var bodyConfig = {
  110539. name: impostor.uniqueId,
  110540. //Oimo must have mass, also for static objects.
  110541. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  110542. size: [],
  110543. type: [],
  110544. pos: [],
  110545. posShape: [],
  110546. rot: [],
  110547. rotShape: [],
  110548. move: impostor.getParam("mass") !== 0,
  110549. density: impostor.getParam("mass"),
  110550. friction: impostor.getParam("friction"),
  110551. restitution: impostor.getParam("restitution"),
  110552. //Supporting older versions of Oimo
  110553. world: this.world
  110554. };
  110555. var impostors = [impostor];
  110556. var addToArray = function (parent) {
  110557. if (!parent.getChildMeshes) {
  110558. return;
  110559. }
  110560. parent.getChildMeshes().forEach(function (m) {
  110561. if (m.physicsImpostor) {
  110562. impostors.push(m.physicsImpostor);
  110563. //m.physicsImpostor._init();
  110564. }
  110565. });
  110566. };
  110567. addToArray(impostor.object);
  110568. var checkWithEpsilon_1 = function (value) {
  110569. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  110570. };
  110571. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  110572. impostors.forEach(function (i) {
  110573. if (!i.object.rotationQuaternion) {
  110574. return;
  110575. }
  110576. //get the correct bounding box
  110577. var oldQuaternion = i.object.rotationQuaternion;
  110578. globalQuaternion_1 = oldQuaternion.clone();
  110579. var rot = oldQuaternion.toEulerAngles();
  110580. var extendSize = i.getObjectExtendSize();
  110581. var radToDeg = 57.295779513082320876;
  110582. if (i === impostor) {
  110583. var center = impostor.getObjectCenter();
  110584. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  110585. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  110586. //Can also use Array.prototype.push.apply
  110587. bodyConfig.pos.push(center.x);
  110588. bodyConfig.pos.push(center.y);
  110589. bodyConfig.pos.push(center.z);
  110590. bodyConfig.posShape.push(0, 0, 0);
  110591. bodyConfig.rotShape.push(0, 0, 0);
  110592. }
  110593. else {
  110594. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  110595. bodyConfig.posShape.push(localPosition.x);
  110596. bodyConfig.posShape.push(localPosition.y);
  110597. bodyConfig.posShape.push(localPosition.z);
  110598. bodyConfig.pos.push(0, 0, 0);
  110599. bodyConfig.rotShape.push(rot.x * radToDeg);
  110600. bodyConfig.rotShape.push(rot.y * radToDeg);
  110601. bodyConfig.rotShape.push(rot.z * radToDeg);
  110602. }
  110603. // register mesh
  110604. switch (i.type) {
  110605. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  110606. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  110607. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  110608. var radiusX = extendSize.x;
  110609. var radiusY = extendSize.y;
  110610. var radiusZ = extendSize.z;
  110611. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  110612. bodyConfig.type.push('sphere');
  110613. //due to the way oimo works with compounds, add 3 times
  110614. bodyConfig.size.push(size);
  110615. bodyConfig.size.push(size);
  110616. bodyConfig.size.push(size);
  110617. break;
  110618. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  110619. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  110620. var sizeY = checkWithEpsilon_1(extendSize.y);
  110621. bodyConfig.type.push('cylinder');
  110622. bodyConfig.size.push(sizeX);
  110623. bodyConfig.size.push(sizeY);
  110624. //due to the way oimo works with compounds, add one more value.
  110625. bodyConfig.size.push(sizeY);
  110626. break;
  110627. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  110628. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  110629. default:
  110630. var sizeX = checkWithEpsilon_1(extendSize.x);
  110631. var sizeY = checkWithEpsilon_1(extendSize.y);
  110632. var sizeZ = checkWithEpsilon_1(extendSize.z);
  110633. bodyConfig.type.push('box');
  110634. //if (i === impostor) {
  110635. bodyConfig.size.push(sizeX);
  110636. bodyConfig.size.push(sizeY);
  110637. bodyConfig.size.push(sizeZ);
  110638. //} else {
  110639. // bodyConfig.size.push(0,0,0);
  110640. //}
  110641. break;
  110642. }
  110643. //actually not needed, but hey...
  110644. i.object.rotationQuaternion = oldQuaternion;
  110645. });
  110646. impostor.physicsBody = this.world.add(bodyConfig);
  110647. // set the quaternion, ignoring the previously defined (euler) rotation
  110648. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  110649. // update with delta 0, so the body will reveive the new rotation.
  110650. impostor.physicsBody.updatePosition(0);
  110651. }
  110652. else {
  110653. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  110654. }
  110655. impostor.setDeltaPosition(this._tmpPositionVector);
  110656. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  110657. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  110658. };
  110659. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  110660. //impostor.physicsBody.dispose();
  110661. //Same as : (older oimo versions)
  110662. this.world.removeRigidBody(impostor.physicsBody);
  110663. };
  110664. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  110665. var mainBody = impostorJoint.mainImpostor.physicsBody;
  110666. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  110667. if (!mainBody || !connectedBody) {
  110668. return;
  110669. }
  110670. var jointData = impostorJoint.joint.jointData;
  110671. var options = jointData.nativeParams || {};
  110672. var type;
  110673. var nativeJointData = {
  110674. body1: mainBody,
  110675. body2: connectedBody,
  110676. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  110677. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  110678. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  110679. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  110680. min: options.min,
  110681. max: options.max,
  110682. collision: options.collision || jointData.collision,
  110683. spring: options.spring,
  110684. //supporting older version of Oimo
  110685. world: this.world
  110686. };
  110687. switch (impostorJoint.joint.type) {
  110688. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  110689. type = "jointBall";
  110690. break;
  110691. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  110692. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  110693. var springData = jointData;
  110694. nativeJointData.min = springData.length || nativeJointData.min;
  110695. //Max should also be set, just make sure it is at least min
  110696. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  110697. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  110698. type = "jointDistance";
  110699. nativeJointData.max = jointData.maxDistance;
  110700. break;
  110701. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  110702. type = "jointPrisme";
  110703. break;
  110704. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  110705. type = "jointSlide";
  110706. break;
  110707. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  110708. type = "jointWheel";
  110709. break;
  110710. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  110711. default:
  110712. type = "jointHinge";
  110713. break;
  110714. }
  110715. nativeJointData.type = type;
  110716. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  110717. };
  110718. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110719. //Bug in Oimo prevents us from disposing a joint in the playground
  110720. //joint.joint.physicsJoint.dispose();
  110721. //So we will bruteforce it!
  110722. try {
  110723. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  110724. }
  110725. catch (e) {
  110726. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  110727. }
  110728. };
  110729. OimoJSPlugin.prototype.isSupported = function () {
  110730. return this.BJSOIMO !== undefined;
  110731. };
  110732. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110733. if (!impostor.physicsBody.sleeping) {
  110734. //TODO check that
  110735. /*if (impostor.physicsBody.shapes.next) {
  110736. var parentShape = this._getLastShape(impostor.physicsBody);
  110737. impostor.object.position.copyFrom(parentShape.position);
  110738. console.log(parentShape.position);
  110739. } else {*/
  110740. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  110741. //}
  110742. if (impostor.object.rotationQuaternion) {
  110743. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  110744. }
  110745. }
  110746. };
  110747. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110748. var body = impostor.physicsBody;
  110749. body.position.copy(newPosition);
  110750. body.orientation.copy(newRotation);
  110751. body.syncShapes();
  110752. body.awake();
  110753. };
  110754. /*private _getLastShape(body: any): any {
  110755. var lastShape = body.shapes;
  110756. while (lastShape.next) {
  110757. lastShape = lastShape.next;
  110758. }
  110759. return lastShape;
  110760. }*/
  110761. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110762. impostor.physicsBody.linearVelocity.copy(velocity);
  110763. };
  110764. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110765. impostor.physicsBody.angularVelocity.copy(velocity);
  110766. };
  110767. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110768. var v = impostor.physicsBody.linearVelocity;
  110769. if (!v) {
  110770. return null;
  110771. }
  110772. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110773. };
  110774. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110775. var v = impostor.physicsBody.angularVelocity;
  110776. if (!v) {
  110777. return null;
  110778. }
  110779. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110780. };
  110781. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110782. var staticBody = mass === 0;
  110783. //this will actually set the body's density and not its mass.
  110784. //But this is how oimo treats the mass variable.
  110785. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  110786. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  110787. };
  110788. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  110789. return impostor.physicsBody.shapes.density;
  110790. };
  110791. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  110792. return impostor.physicsBody.shapes.friction;
  110793. };
  110794. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110795. impostor.physicsBody.shapes.friction = friction;
  110796. };
  110797. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110798. return impostor.physicsBody.shapes.restitution;
  110799. };
  110800. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110801. impostor.physicsBody.shapes.restitution = restitution;
  110802. };
  110803. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  110804. impostor.physicsBody.sleep();
  110805. };
  110806. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  110807. impostor.physicsBody.awake();
  110808. };
  110809. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  110810. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  110811. if (minDistance !== void 0) {
  110812. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  110813. }
  110814. };
  110815. OimoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  110816. if (maxForce !== undefined) {
  110817. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with maxForce parameter");
  110818. }
  110819. speed *= -1;
  110820. //TODO separate rotational and transational motors.
  110821. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110822. if (motor) {
  110823. motor.setMotor(speed, maxForce);
  110824. }
  110825. };
  110826. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  110827. //TODO separate rotational and transational motors.
  110828. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110829. if (motor) {
  110830. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  110831. }
  110832. };
  110833. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110834. var body = impostor.physicsBody;
  110835. mesh.position.x = body.position.x;
  110836. mesh.position.y = body.position.y;
  110837. mesh.position.z = body.position.z;
  110838. if (mesh.rotationQuaternion) {
  110839. mesh.rotationQuaternion.x = body.orientation.x;
  110840. mesh.rotationQuaternion.y = body.orientation.y;
  110841. mesh.rotationQuaternion.z = body.orientation.z;
  110842. mesh.rotationQuaternion.w = body.orientation.s;
  110843. }
  110844. };
  110845. OimoJSPlugin.prototype.getRadius = function (impostor) {
  110846. return impostor.physicsBody.shapes.radius;
  110847. };
  110848. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110849. var shape = impostor.physicsBody.shapes;
  110850. result.x = shape.halfWidth * 2;
  110851. result.y = shape.halfHeight * 2;
  110852. result.z = shape.halfDepth * 2;
  110853. };
  110854. OimoJSPlugin.prototype.dispose = function () {
  110855. this.world.clear();
  110856. };
  110857. return OimoJSPlugin;
  110858. }());
  110859. /***/ }),
  110860. /***/ "./Physics/index.ts":
  110861. /*!**************************!*\
  110862. !*** ./Physics/index.ts ***!
  110863. \**************************/
  110864. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110865. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110866. "use strict";
  110867. __webpack_require__.r(__webpack_exports__);
  110868. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  110869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  110870. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  110871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  110872. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  110873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  110874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  110875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  110876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  110877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  110878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  110879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  110880. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  110881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  110882. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  110884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  110885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  110886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  110887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  110888. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  110889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  110890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  110891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  110892. /***/ }),
  110893. /***/ "./Physics/physicsEngine.ts":
  110894. /*!**********************************!*\
  110895. !*** ./Physics/physicsEngine.ts ***!
  110896. \**********************************/
  110897. /*! exports provided: PhysicsEngine */
  110898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110899. "use strict";
  110900. __webpack_require__.r(__webpack_exports__);
  110901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  110902. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110903. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  110904. /**
  110905. * Class used to control physics engine
  110906. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110907. */
  110908. var PhysicsEngine = /** @class */ (function () {
  110909. /**
  110910. * Creates a new Physics Engine
  110911. * @param gravity defines the gravity vector used by the simulation
  110912. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  110913. */
  110914. function PhysicsEngine(gravity, _physicsPlugin) {
  110915. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  110916. this._physicsPlugin = _physicsPlugin;
  110917. this._impostors = [];
  110918. this._joints = [];
  110919. if (!this._physicsPlugin.isSupported()) {
  110920. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  110921. + "Please make sure it is included.");
  110922. }
  110923. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  110924. this.setGravity(gravity);
  110925. this.setTimeStep();
  110926. }
  110927. /**
  110928. * Factory used to create the default physics plugin.
  110929. * @returns The default physics plugin
  110930. */
  110931. PhysicsEngine.DefaultPluginFactory = function () {
  110932. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  110933. };
  110934. /**
  110935. * Sets the gravity vector used by the simulation
  110936. * @param gravity defines the gravity vector to use
  110937. */
  110938. PhysicsEngine.prototype.setGravity = function (gravity) {
  110939. this.gravity = gravity;
  110940. this._physicsPlugin.setGravity(this.gravity);
  110941. };
  110942. /**
  110943. * Set the time step of the physics engine.
  110944. * Default is 1/60.
  110945. * To slow it down, enter 1/600 for example.
  110946. * To speed it up, 1/30
  110947. * @param newTimeStep defines the new timestep to apply to this world.
  110948. */
  110949. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  110950. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  110951. this._physicsPlugin.setTimeStep(newTimeStep);
  110952. };
  110953. /**
  110954. * Get the time step of the physics engine.
  110955. * @returns the current time step
  110956. */
  110957. PhysicsEngine.prototype.getTimeStep = function () {
  110958. return this._physicsPlugin.getTimeStep();
  110959. };
  110960. /**
  110961. * Release all resources
  110962. */
  110963. PhysicsEngine.prototype.dispose = function () {
  110964. this._impostors.forEach(function (impostor) {
  110965. impostor.dispose();
  110966. });
  110967. this._physicsPlugin.dispose();
  110968. };
  110969. /**
  110970. * Gets the name of the current physics plugin
  110971. * @returns the name of the plugin
  110972. */
  110973. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  110974. return this._physicsPlugin.name;
  110975. };
  110976. /**
  110977. * Adding a new impostor for the impostor tracking.
  110978. * This will be done by the impostor itself.
  110979. * @param impostor the impostor to add
  110980. */
  110981. PhysicsEngine.prototype.addImpostor = function (impostor) {
  110982. impostor.uniqueId = this._impostors.push(impostor);
  110983. //if no parent, generate the body
  110984. if (!impostor.parent) {
  110985. this._physicsPlugin.generatePhysicsBody(impostor);
  110986. }
  110987. };
  110988. /**
  110989. * Remove an impostor from the engine.
  110990. * This impostor and its mesh will not longer be updated by the physics engine.
  110991. * @param impostor the impostor to remove
  110992. */
  110993. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  110994. var index = this._impostors.indexOf(impostor);
  110995. if (index > -1) {
  110996. var removed = this._impostors.splice(index, 1);
  110997. //Is it needed?
  110998. if (removed.length) {
  110999. //this will also remove it from the world.
  111000. removed[0].physicsBody = null;
  111001. }
  111002. }
  111003. };
  111004. /**
  111005. * Add a joint to the physics engine
  111006. * @param mainImpostor defines the main impostor to which the joint is added.
  111007. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111008. * @param joint defines the joint that will connect both impostors.
  111009. */
  111010. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  111011. var impostorJoint = {
  111012. mainImpostor: mainImpostor,
  111013. connectedImpostor: connectedImpostor,
  111014. joint: joint
  111015. };
  111016. joint.physicsPlugin = this._physicsPlugin;
  111017. this._joints.push(impostorJoint);
  111018. this._physicsPlugin.generateJoint(impostorJoint);
  111019. };
  111020. /**
  111021. * Removes a joint from the simulation
  111022. * @param mainImpostor defines the impostor used with the joint
  111023. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111024. * @param joint defines the joint to remove
  111025. */
  111026. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  111027. var matchingJoints = this._joints.filter(function (impostorJoint) {
  111028. return (impostorJoint.connectedImpostor === connectedImpostor
  111029. && impostorJoint.joint === joint
  111030. && impostorJoint.mainImpostor === mainImpostor);
  111031. });
  111032. if (matchingJoints.length) {
  111033. this._physicsPlugin.removeJoint(matchingJoints[0]);
  111034. //TODO remove it from the list as well
  111035. }
  111036. };
  111037. /**
  111038. * Called by the scene. No need to call it.
  111039. * @param delta defines the timespam between frames
  111040. */
  111041. PhysicsEngine.prototype._step = function (delta) {
  111042. var _this = this;
  111043. //check if any mesh has no body / requires an update
  111044. this._impostors.forEach(function (impostor) {
  111045. if (impostor.isBodyInitRequired()) {
  111046. _this._physicsPlugin.generatePhysicsBody(impostor);
  111047. }
  111048. });
  111049. if (delta > 0.1) {
  111050. delta = 0.1;
  111051. }
  111052. else if (delta <= 0) {
  111053. delta = 1.0 / 60.0;
  111054. }
  111055. this._physicsPlugin.executeStep(delta, this._impostors);
  111056. };
  111057. /**
  111058. * Gets the current plugin used to run the simulation
  111059. * @returns current plugin
  111060. */
  111061. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  111062. return this._physicsPlugin;
  111063. };
  111064. /**
  111065. * Gets the list of physic impostors
  111066. * @returns an array of PhysicsImpostor
  111067. */
  111068. PhysicsEngine.prototype.getImpostors = function () {
  111069. return this._impostors;
  111070. };
  111071. /**
  111072. * Gets the impostor for a physics enabled object
  111073. * @param object defines the object impersonated by the impostor
  111074. * @returns the PhysicsImpostor or null if not found
  111075. */
  111076. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  111077. for (var i = 0; i < this._impostors.length; ++i) {
  111078. if (this._impostors[i].object === object) {
  111079. return this._impostors[i];
  111080. }
  111081. }
  111082. return null;
  111083. };
  111084. /**
  111085. * Gets the impostor for a physics body object
  111086. * @param body defines physics body used by the impostor
  111087. * @returns the PhysicsImpostor or null if not found
  111088. */
  111089. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  111090. for (var i = 0; i < this._impostors.length; ++i) {
  111091. if (this._impostors[i].physicsBody === body) {
  111092. return this._impostors[i];
  111093. }
  111094. }
  111095. return null;
  111096. };
  111097. /**
  111098. * Global value used to control the smallest number supported by the simulation
  111099. */
  111100. PhysicsEngine.Epsilon = 0.001;
  111101. return PhysicsEngine;
  111102. }());
  111103. /***/ }),
  111104. /***/ "./Physics/physicsEngineComponent.ts":
  111105. /*!*******************************************!*\
  111106. !*** ./Physics/physicsEngineComponent.ts ***!
  111107. \*******************************************/
  111108. /*! exports provided: PhysicsEngineSceneComponent */
  111109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111110. "use strict";
  111111. __webpack_require__.r(__webpack_exports__);
  111112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  111113. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111114. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  111115. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111116. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  111117. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  111118. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  111119. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111120. /**
  111121. * Gets the current physics engine
  111122. * @returns a IPhysicsEngine or null if none attached
  111123. */
  111124. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  111125. return this._physicsEngine;
  111126. };
  111127. /**
  111128. * Enables physics to the current scene
  111129. * @param gravity defines the scene's gravity for the physics engine
  111130. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111131. * @return a boolean indicating if the physics engine was initialized
  111132. */
  111133. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  111134. if (gravity === void 0) { gravity = null; }
  111135. if (this._physicsEngine) {
  111136. return true;
  111137. }
  111138. // Register the component to the scene
  111139. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  111140. if (!component) {
  111141. component = new PhysicsEngineSceneComponent(this);
  111142. this._addComponent(component);
  111143. }
  111144. try {
  111145. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  111146. return true;
  111147. }
  111148. catch (e) {
  111149. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  111150. return false;
  111151. }
  111152. };
  111153. /**
  111154. * Disables and disposes the physics engine associated with the scene
  111155. */
  111156. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  111157. if (!this._physicsEngine) {
  111158. return;
  111159. }
  111160. this._physicsEngine.dispose();
  111161. this._physicsEngine = null;
  111162. };
  111163. /**
  111164. * Gets a boolean indicating if there is an active physics engine
  111165. * @returns a boolean indicating if there is an active physics engine
  111166. */
  111167. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  111168. return this._physicsEngine !== undefined;
  111169. };
  111170. /**
  111171. * Deletes a physics compound impostor
  111172. * @param compound defines the compound to delete
  111173. */
  111174. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  111175. var mesh = compound.parts[0].mesh;
  111176. if (mesh.physicsImpostor) {
  111177. mesh.physicsImpostor.dispose( /*true*/);
  111178. mesh.physicsImpostor = null;
  111179. }
  111180. };
  111181. /** @hidden */
  111182. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  111183. if (this._physicsEngine) {
  111184. this.onBeforePhysicsObservable.notifyObservers(this);
  111185. this._physicsEngine._step(step / 1000);
  111186. this.onAfterPhysicsObservable.notifyObservers(this);
  111187. }
  111188. };
  111189. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  111190. get: function () {
  111191. return this._physicsImpostor;
  111192. },
  111193. set: function (value) {
  111194. var _this = this;
  111195. if (this._physicsImpostor === value) {
  111196. return;
  111197. }
  111198. if (this._disposePhysicsObserver) {
  111199. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  111200. }
  111201. this._physicsImpostor = value;
  111202. if (value) {
  111203. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  111204. // Physics
  111205. if (_this.physicsImpostor) {
  111206. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  111207. _this.physicsImpostor = null;
  111208. }
  111209. });
  111210. }
  111211. },
  111212. enumerable: true,
  111213. configurable: true
  111214. });
  111215. /**
  111216. * Gets the current physics impostor
  111217. * @see http://doc.babylonjs.com/features/physics_engine
  111218. * @returns a physics impostor or null
  111219. */
  111220. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  111221. return this.physicsImpostor;
  111222. };
  111223. /**
  111224. * Apply a physic impulse to the mesh
  111225. * @param force defines the force to apply
  111226. * @param contactPoint defines where to apply the force
  111227. * @returns the current mesh
  111228. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111229. */
  111230. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  111231. if (!this.physicsImpostor) {
  111232. return this;
  111233. }
  111234. this.physicsImpostor.applyImpulse(force, contactPoint);
  111235. return this;
  111236. };
  111237. /**
  111238. * Creates a physic joint between two meshes
  111239. * @param otherMesh defines the other mesh to use
  111240. * @param pivot1 defines the pivot to use on this mesh
  111241. * @param pivot2 defines the pivot to use on the other mesh
  111242. * @param options defines additional options (can be plugin dependent)
  111243. * @returns the current mesh
  111244. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111245. */
  111246. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  111247. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  111248. return this;
  111249. }
  111250. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  111251. mainPivot: pivot1,
  111252. connectedPivot: pivot2,
  111253. nativeParams: options
  111254. });
  111255. return this;
  111256. };
  111257. /**
  111258. * Defines the physics engine scene component responsible to manage a physics engine
  111259. */
  111260. var PhysicsEngineSceneComponent = /** @class */ (function () {
  111261. /**
  111262. * Creates a new instance of the component for the given scene
  111263. * @param scene Defines the scene to register the component in
  111264. */
  111265. function PhysicsEngineSceneComponent(scene) {
  111266. var _this = this;
  111267. /**
  111268. * The component name helpful to identify the component in the list of scene components.
  111269. */
  111270. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  111271. this.scene = scene;
  111272. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111273. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111274. // Replace the function used to get the deterministic frame time
  111275. this.scene.getDeterministicFrameTime = function () {
  111276. if (_this.scene._physicsEngine) {
  111277. return _this.scene._physicsEngine.getTimeStep() * 1000;
  111278. }
  111279. return 1000.0 / 60.0;
  111280. };
  111281. }
  111282. /**
  111283. * Registers the component in a given scene
  111284. */
  111285. PhysicsEngineSceneComponent.prototype.register = function () {
  111286. };
  111287. /**
  111288. * Rebuilds the elements related to this component in case of
  111289. * context lost for instance.
  111290. */
  111291. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  111292. // Nothing to do for this component
  111293. };
  111294. /**
  111295. * Disposes the component and the associated ressources
  111296. */
  111297. PhysicsEngineSceneComponent.prototype.dispose = function () {
  111298. this.scene.onBeforePhysicsObservable.clear();
  111299. this.scene.onAfterPhysicsObservable.clear();
  111300. if (this.scene._physicsEngine) {
  111301. this.scene.disablePhysicsEngine();
  111302. }
  111303. };
  111304. return PhysicsEngineSceneComponent;
  111305. }());
  111306. /***/ }),
  111307. /***/ "./Physics/physicsHelper.ts":
  111308. /*!**********************************!*\
  111309. !*** ./Physics/physicsHelper.ts ***!
  111310. \**********************************/
  111311. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  111312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111313. "use strict";
  111314. __webpack_require__.r(__webpack_exports__);
  111315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  111316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  111317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  111318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  111319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  111320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  111321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  111322. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111323. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111324. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  111325. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  111326. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  111327. /**
  111328. * A helper for physics simulations
  111329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111330. */
  111331. var PhysicsHelper = /** @class */ (function () {
  111332. /**
  111333. * Initializes the Physics helper
  111334. * @param scene Babylon.js scene
  111335. */
  111336. function PhysicsHelper(scene) {
  111337. this._scene = scene;
  111338. this._physicsEngine = this._scene.getPhysicsEngine();
  111339. if (!this._physicsEngine) {
  111340. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  111341. }
  111342. }
  111343. /**
  111344. * Applies a radial explosion impulse
  111345. * @param origin the origin of the explosion
  111346. * @param radius the explosion radius
  111347. * @param strength the explosion strength
  111348. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111349. * @returns A physics radial explosion event, or null
  111350. */
  111351. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  111352. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111353. if (!this._physicsEngine) {
  111354. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  111355. return null;
  111356. }
  111357. var impostors = this._physicsEngine.getImpostors();
  111358. if (impostors.length === 0) {
  111359. return null;
  111360. }
  111361. var event = new PhysicsRadialExplosionEvent(this._scene);
  111362. impostors.forEach(function (impostor) {
  111363. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111364. if (!impostorForceAndContactPoint) {
  111365. return;
  111366. }
  111367. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111368. });
  111369. event.dispose(false);
  111370. return event;
  111371. };
  111372. /**
  111373. * Applies a radial explosion force
  111374. * @param origin the origin of the explosion
  111375. * @param radius the explosion radius
  111376. * @param strength the explosion strength
  111377. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111378. * @returns A physics radial explosion event, or null
  111379. */
  111380. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  111381. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111382. if (!this._physicsEngine) {
  111383. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111384. return null;
  111385. }
  111386. var impostors = this._physicsEngine.getImpostors();
  111387. if (impostors.length === 0) {
  111388. return null;
  111389. }
  111390. var event = new PhysicsRadialExplosionEvent(this._scene);
  111391. impostors.forEach(function (impostor) {
  111392. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111393. if (!impostorForceAndContactPoint) {
  111394. return;
  111395. }
  111396. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111397. });
  111398. event.dispose(false);
  111399. return event;
  111400. };
  111401. /**
  111402. * Creates a gravitational field
  111403. * @param origin the origin of the explosion
  111404. * @param radius the explosion radius
  111405. * @param strength the explosion strength
  111406. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111407. * @returns A physics gravitational field event, or null
  111408. */
  111409. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  111410. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111411. if (!this._physicsEngine) {
  111412. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111413. return null;
  111414. }
  111415. var impostors = this._physicsEngine.getImpostors();
  111416. if (impostors.length === 0) {
  111417. return null;
  111418. }
  111419. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  111420. event.dispose(false);
  111421. return event;
  111422. };
  111423. /**
  111424. * Creates a physics updraft event
  111425. * @param origin the origin of the updraft
  111426. * @param radius the radius of the updraft
  111427. * @param strength the strength of the updraft
  111428. * @param height the height of the updraft
  111429. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111430. * @returns A physics updraft event, or null
  111431. */
  111432. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  111433. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  111434. if (!this._physicsEngine) {
  111435. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111436. return null;
  111437. }
  111438. if (this._physicsEngine.getImpostors().length === 0) {
  111439. return null;
  111440. }
  111441. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  111442. event.dispose(false);
  111443. return event;
  111444. };
  111445. /**
  111446. * Creates a physics vortex event
  111447. * @param origin the of the vortex
  111448. * @param radius the radius of the vortex
  111449. * @param strength the strength of the vortex
  111450. * @param height the height of the vortex
  111451. * @returns a Physics vortex event, or null
  111452. * A physics vortex event or null
  111453. */
  111454. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  111455. if (!this._physicsEngine) {
  111456. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111457. return null;
  111458. }
  111459. if (this._physicsEngine.getImpostors().length === 0) {
  111460. return null;
  111461. }
  111462. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  111463. event.dispose(false);
  111464. return event;
  111465. };
  111466. return PhysicsHelper;
  111467. }());
  111468. /**
  111469. * Represents a physics radial explosion event
  111470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111471. */
  111472. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  111473. /**
  111474. * Initializes a radial explosioin event
  111475. * @param scene BabylonJS scene
  111476. */
  111477. function PhysicsRadialExplosionEvent(scene) {
  111478. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  111479. this._rays = [];
  111480. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  111481. this._scene = scene;
  111482. }
  111483. /**
  111484. * Returns the data related to the radial explosion event (sphere & rays).
  111485. * @returns The radial explosion event data
  111486. */
  111487. PhysicsRadialExplosionEvent.prototype.getData = function () {
  111488. this._dataFetched = true;
  111489. return {
  111490. sphere: this._sphere,
  111491. rays: this._rays,
  111492. };
  111493. };
  111494. /**
  111495. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111496. * @param impostor A physics imposter
  111497. * @param origin the origin of the explosion
  111498. * @param radius the explosion radius
  111499. * @param strength the explosion strength
  111500. * @param falloff possible options: Constant & Linear
  111501. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  111502. */
  111503. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  111504. if (impostor.mass === 0) {
  111505. return null;
  111506. }
  111507. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  111508. return null;
  111509. }
  111510. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111511. return null;
  111512. }
  111513. var impostorObjectCenter = impostor.getObjectCenter();
  111514. var direction = impostorObjectCenter.subtract(origin);
  111515. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](origin, direction, radius);
  111516. this._rays.push(ray);
  111517. var hit = ray.intersectsMesh(impostor.object);
  111518. var contactPoint = hit.pickedPoint;
  111519. if (!contactPoint) {
  111520. return null;
  111521. }
  111522. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  111523. if (distanceFromOrigin > radius) {
  111524. return null;
  111525. }
  111526. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  111527. ? strength
  111528. : strength * (1 - (distanceFromOrigin / radius));
  111529. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111530. return { force: force, contactPoint: contactPoint };
  111531. };
  111532. /**
  111533. * Disposes the sphere.
  111534. * @param force Specifies if the sphere should be disposed by force
  111535. */
  111536. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  111537. var _this = this;
  111538. if (force === void 0) { force = true; }
  111539. if (force) {
  111540. this._sphere.dispose();
  111541. }
  111542. else {
  111543. setTimeout(function () {
  111544. if (!_this._dataFetched) {
  111545. _this._sphere.dispose();
  111546. }
  111547. }, 0);
  111548. }
  111549. };
  111550. /*** Helpers ***/
  111551. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  111552. if (!this._sphere) {
  111553. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  111554. this._sphere.isVisible = false;
  111555. }
  111556. };
  111557. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  111558. var impostorObject = impostor.object;
  111559. this._prepareSphere();
  111560. this._sphere.position = origin;
  111561. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  111562. this._sphere._updateBoundingInfo();
  111563. this._sphere.computeWorldMatrix(true);
  111564. return this._sphere.intersectsMesh(impostorObject, true);
  111565. };
  111566. return PhysicsRadialExplosionEvent;
  111567. }());
  111568. /**
  111569. * Represents a gravitational field event
  111570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111571. */
  111572. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  111573. /**
  111574. * Initializes the physics gravitational field event
  111575. * @param physicsHelper A physics helper
  111576. * @param scene BabylonJS scene
  111577. * @param origin The origin position of the gravitational field event
  111578. * @param radius The radius of the gravitational field event
  111579. * @param strength The strength of the gravitational field event
  111580. * @param falloff The falloff for the gravitational field event
  111581. */
  111582. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  111583. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111584. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111585. this._physicsHelper = physicsHelper;
  111586. this._scene = scene;
  111587. this._origin = origin;
  111588. this._radius = radius;
  111589. this._strength = strength;
  111590. this._falloff = falloff;
  111591. this._tickCallback = this._tick.bind(this);
  111592. }
  111593. /**
  111594. * Returns the data related to the gravitational field event (sphere).
  111595. * @returns A gravitational field event
  111596. */
  111597. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  111598. this._dataFetched = true;
  111599. return {
  111600. sphere: this._sphere,
  111601. };
  111602. };
  111603. /**
  111604. * Enables the gravitational field.
  111605. */
  111606. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  111607. this._tickCallback.call(this);
  111608. this._scene.registerBeforeRender(this._tickCallback);
  111609. };
  111610. /**
  111611. * Disables the gravitational field.
  111612. */
  111613. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  111614. this._scene.unregisterBeforeRender(this._tickCallback);
  111615. };
  111616. /**
  111617. * Disposes the sphere.
  111618. * @param force The force to dispose from the gravitational field event
  111619. */
  111620. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  111621. var _this = this;
  111622. if (force === void 0) { force = true; }
  111623. if (force) {
  111624. this._sphere.dispose();
  111625. }
  111626. else {
  111627. setTimeout(function () {
  111628. if (!_this._dataFetched) {
  111629. _this._sphere.dispose();
  111630. }
  111631. }, 0);
  111632. }
  111633. };
  111634. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  111635. // Since the params won't change, we fetch the event only once
  111636. if (this._sphere) {
  111637. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111638. }
  111639. else {
  111640. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111641. if (radialExplosionEvent) {
  111642. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  111643. }
  111644. }
  111645. };
  111646. return PhysicsGravitationalFieldEvent;
  111647. }());
  111648. /**
  111649. * Represents a physics updraft event
  111650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111651. */
  111652. var PhysicsUpdraftEvent = /** @class */ (function () {
  111653. /**
  111654. * Initializes the physics updraft event
  111655. * @param _scene BabylonJS scene
  111656. * @param _origin The origin position of the updraft
  111657. * @param _radius The radius of the updraft
  111658. * @param _strength The strength of the updraft
  111659. * @param _height The height of the updraft
  111660. * @param _updraftMode The mode of the updraft
  111661. */
  111662. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  111663. this._scene = _scene;
  111664. this._origin = _origin;
  111665. this._radius = _radius;
  111666. this._strength = _strength;
  111667. this._height = _height;
  111668. this._updraftMode = _updraftMode;
  111669. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111670. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  111671. 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
  111672. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111673. this._physicsEngine = this._scene.getPhysicsEngine();
  111674. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111675. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111676. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111677. this._originDirection = this._origin.subtract(this._originTop).normalize();
  111678. }
  111679. this._tickCallback = this._tick.bind(this);
  111680. this._prepareCylinder();
  111681. }
  111682. /**
  111683. * Returns the data related to the updraft event (cylinder).
  111684. * @returns A physics updraft event
  111685. */
  111686. PhysicsUpdraftEvent.prototype.getData = function () {
  111687. this._dataFetched = true;
  111688. return {
  111689. cylinder: this._cylinder,
  111690. };
  111691. };
  111692. /**
  111693. * Enables the updraft.
  111694. */
  111695. PhysicsUpdraftEvent.prototype.enable = function () {
  111696. this._tickCallback.call(this);
  111697. this._scene.registerBeforeRender(this._tickCallback);
  111698. };
  111699. /**
  111700. * Disables the cortex.
  111701. */
  111702. PhysicsUpdraftEvent.prototype.disable = function () {
  111703. this._scene.unregisterBeforeRender(this._tickCallback);
  111704. };
  111705. /**
  111706. * Disposes the sphere.
  111707. * @param force Specifies if the updraft should be disposed by force
  111708. */
  111709. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  111710. var _this = this;
  111711. if (force === void 0) { force = true; }
  111712. if (!this._cylinder) {
  111713. return;
  111714. }
  111715. if (force) {
  111716. this._cylinder.dispose();
  111717. }
  111718. else {
  111719. setTimeout(function () {
  111720. if (!_this._dataFetched) {
  111721. _this._cylinder.dispose();
  111722. }
  111723. }, 0);
  111724. }
  111725. };
  111726. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111727. if (impostor.mass === 0) {
  111728. return null;
  111729. }
  111730. if (!this._intersectsWithCylinder(impostor)) {
  111731. return null;
  111732. }
  111733. var impostorObjectCenter = impostor.getObjectCenter();
  111734. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111735. var direction = this._originDirection;
  111736. }
  111737. else {
  111738. var direction = impostorObjectCenter.subtract(this._originTop);
  111739. }
  111740. var multiplier = this._strength * -1;
  111741. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111742. return { force: force, contactPoint: impostorObjectCenter };
  111743. };
  111744. PhysicsUpdraftEvent.prototype._tick = function () {
  111745. var _this = this;
  111746. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111747. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111748. if (!impostorForceAndContactPoint) {
  111749. return;
  111750. }
  111751. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111752. });
  111753. };
  111754. /*** Helpers ***/
  111755. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  111756. if (!this._cylinder) {
  111757. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  111758. height: this._height,
  111759. diameter: this._radius * 2,
  111760. }, this._scene);
  111761. this._cylinder.isVisible = false;
  111762. }
  111763. };
  111764. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  111765. var impostorObject = impostor.object;
  111766. this._cylinder.position = this._cylinderPosition;
  111767. return this._cylinder.intersectsMesh(impostorObject, true);
  111768. };
  111769. return PhysicsUpdraftEvent;
  111770. }());
  111771. /**
  111772. * Represents a physics vortex event
  111773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111774. */
  111775. var PhysicsVortexEvent = /** @class */ (function () {
  111776. /**
  111777. * Initializes the physics vortex event
  111778. * @param _scene The BabylonJS scene
  111779. * @param _origin The origin position of the vortex
  111780. * @param _radius The radius of the vortex
  111781. * @param _strength The strength of the vortex
  111782. * @param _height The height of the vortex
  111783. */
  111784. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  111785. this._scene = _scene;
  111786. this._origin = _origin;
  111787. this._radius = _radius;
  111788. this._strength = _strength;
  111789. this._height = _height;
  111790. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111791. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  111792. this._updraftMultiplier = 0.02;
  111793. 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
  111794. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111795. this._physicsEngine = this._scene.getPhysicsEngine();
  111796. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111797. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111798. this._tickCallback = this._tick.bind(this);
  111799. this._prepareCylinder();
  111800. }
  111801. /**
  111802. * Returns the data related to the vortex event (cylinder).
  111803. * @returns The physics vortex event data
  111804. */
  111805. PhysicsVortexEvent.prototype.getData = function () {
  111806. this._dataFetched = true;
  111807. return {
  111808. cylinder: this._cylinder,
  111809. };
  111810. };
  111811. /**
  111812. * Enables the vortex.
  111813. */
  111814. PhysicsVortexEvent.prototype.enable = function () {
  111815. this._tickCallback.call(this);
  111816. this._scene.registerBeforeRender(this._tickCallback);
  111817. };
  111818. /**
  111819. * Disables the cortex.
  111820. */
  111821. PhysicsVortexEvent.prototype.disable = function () {
  111822. this._scene.unregisterBeforeRender(this._tickCallback);
  111823. };
  111824. /**
  111825. * Disposes the sphere.
  111826. * @param force
  111827. */
  111828. PhysicsVortexEvent.prototype.dispose = function (force) {
  111829. var _this = this;
  111830. if (force === void 0) { force = true; }
  111831. if (force) {
  111832. this._cylinder.dispose();
  111833. }
  111834. else {
  111835. setTimeout(function () {
  111836. if (!_this._dataFetched) {
  111837. _this._cylinder.dispose();
  111838. }
  111839. }, 0);
  111840. }
  111841. };
  111842. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111843. if (impostor.mass === 0) {
  111844. return null;
  111845. }
  111846. if (!this._intersectsWithCylinder(impostor)) {
  111847. return null;
  111848. }
  111849. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111850. return null;
  111851. }
  111852. var impostorObjectCenter = impostor.getObjectCenter();
  111853. 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)
  111854. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  111855. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  111856. var hit = ray.intersectsMesh(impostor.object);
  111857. var contactPoint = hit.pickedPoint;
  111858. if (!contactPoint) {
  111859. return null;
  111860. }
  111861. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  111862. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  111863. var directionToOrigin = contactPoint.normalize();
  111864. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111865. directionToOrigin = directionToOrigin.negate();
  111866. }
  111867. // TODO: find a more physically based solution
  111868. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111869. var forceX = directionToOrigin.x * this._strength / 8;
  111870. var forceY = directionToOrigin.y * this._updraftMultiplier;
  111871. var forceZ = directionToOrigin.z * this._strength / 8;
  111872. }
  111873. else {
  111874. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  111875. var forceY = this._originTop.y * this._updraftMultiplier;
  111876. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  111877. }
  111878. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  111879. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  111880. return { force: force, contactPoint: impostorObjectCenter };
  111881. };
  111882. PhysicsVortexEvent.prototype._tick = function () {
  111883. var _this = this;
  111884. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111885. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111886. if (!impostorForceAndContactPoint) {
  111887. return;
  111888. }
  111889. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111890. });
  111891. };
  111892. /*** Helpers ***/
  111893. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  111894. if (!this._cylinder) {
  111895. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  111896. height: this._height,
  111897. diameter: this._radius * 2,
  111898. }, this._scene);
  111899. this._cylinder.isVisible = false;
  111900. }
  111901. };
  111902. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  111903. var impostorObject = impostor.object;
  111904. this._cylinder.position = this._cylinderPosition;
  111905. return this._cylinder.intersectsMesh(impostorObject, true);
  111906. };
  111907. return PhysicsVortexEvent;
  111908. }());
  111909. /**
  111910. * The strenght of the force in correspondence to the distance of the affected object
  111911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111912. */
  111913. var PhysicsRadialImpulseFalloff;
  111914. (function (PhysicsRadialImpulseFalloff) {
  111915. /** Defines that impulse is constant in strength across it's whole radius */
  111916. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  111917. /** DEfines that impulse gets weaker if it's further from the origin */
  111918. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  111919. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  111920. /**
  111921. * The strength of the force in correspondence to the distance of the affected object
  111922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111923. */
  111924. var PhysicsUpdraftMode;
  111925. (function (PhysicsUpdraftMode) {
  111926. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111927. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  111928. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111929. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  111930. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  111931. /***/ }),
  111932. /***/ "./Physics/physicsImpostor.ts":
  111933. /*!************************************!*\
  111934. !*** ./Physics/physicsImpostor.ts ***!
  111935. \************************************/
  111936. /*! exports provided: PhysicsImpostor */
  111937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111938. "use strict";
  111939. __webpack_require__.r(__webpack_exports__);
  111940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  111941. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111942. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  111943. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111944. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111945. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111946. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111947. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  111948. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  111949. mass: jsonObject.physicsMass,
  111950. friction: jsonObject.physicsFriction,
  111951. restitution: jsonObject.physicsRestitution
  111952. }, scene);
  111953. };
  111954. /**
  111955. * Represents a physics imposter
  111956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111957. */
  111958. var PhysicsImpostor = /** @class */ (function () {
  111959. /**
  111960. * Initializes the physics imposter
  111961. * @param object The physics-enabled object used as the physics imposter
  111962. * @param type The type of the physics imposter
  111963. * @param _options The options for the physics imposter
  111964. * @param _scene The Babylon scene
  111965. */
  111966. function PhysicsImpostor(
  111967. /**
  111968. * The physics-enabled object used as the physics imposter
  111969. */
  111970. object,
  111971. /**
  111972. * The type of the physics imposter
  111973. */
  111974. type, _options, _scene) {
  111975. if (_options === void 0) { _options = { mass: 0 }; }
  111976. var _this = this;
  111977. this.object = object;
  111978. this.type = type;
  111979. this._options = _options;
  111980. this._scene = _scene;
  111981. this._bodyUpdateRequired = false;
  111982. this._onBeforePhysicsStepCallbacks = new Array();
  111983. this._onAfterPhysicsStepCallbacks = new Array();
  111984. /** @hidden */
  111985. this._onPhysicsCollideCallbacks = [];
  111986. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111987. this._isDisposed = false;
  111988. //temp variables for parent rotation calculations
  111989. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  111990. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111991. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111992. /**
  111993. * this function is executed by the physics engine.
  111994. */
  111995. this.beforeStep = function () {
  111996. if (!_this._physicsEngine) {
  111997. return;
  111998. }
  111999. _this.object.translate(_this._deltaPosition, -1);
  112000. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  112001. _this.object.computeWorldMatrix(false);
  112002. if (_this.object.parent && _this.object.rotationQuaternion) {
  112003. _this.getParentsRotation();
  112004. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  112005. }
  112006. else {
  112007. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  112008. }
  112009. if (!_this._options.disableBidirectionalTransformation) {
  112010. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  112011. }
  112012. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  112013. func(_this);
  112014. });
  112015. };
  112016. /**
  112017. * this function is executed by the physics engine
  112018. */
  112019. this.afterStep = function () {
  112020. if (!_this._physicsEngine) {
  112021. return;
  112022. }
  112023. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  112024. func(_this);
  112025. });
  112026. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  112027. // object has now its world rotation. needs to be converted to local.
  112028. if (_this.object.parent && _this.object.rotationQuaternion) {
  112029. _this.getParentsRotation();
  112030. _this._tmpQuat.conjugateInPlace();
  112031. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  112032. }
  112033. // take the position set and make it the absolute position of this object.
  112034. _this.object.setAbsolutePosition(_this.object.position);
  112035. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  112036. _this.object.translate(_this._deltaPosition, 1);
  112037. };
  112038. /**
  112039. * Legacy collision detection event support
  112040. */
  112041. this.onCollideEvent = null;
  112042. /**
  112043. * event and body object due to cannon's event-based architecture.
  112044. */
  112045. this.onCollide = function (e) {
  112046. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  112047. return;
  112048. }
  112049. if (!_this._physicsEngine) {
  112050. return;
  112051. }
  112052. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  112053. if (otherImpostor) {
  112054. // Legacy collision detection event support
  112055. if (_this.onCollideEvent) {
  112056. _this.onCollideEvent(_this, otherImpostor);
  112057. }
  112058. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  112059. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  112060. }).forEach(function (obj) {
  112061. obj.callback(_this, otherImpostor);
  112062. });
  112063. }
  112064. };
  112065. //sanity check!
  112066. if (!this.object) {
  112067. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  112068. return;
  112069. }
  112070. // Legacy support for old syntax.
  112071. if (!this._scene && object.getScene) {
  112072. this._scene = object.getScene();
  112073. }
  112074. if (!this._scene) {
  112075. return;
  112076. }
  112077. this._physicsEngine = this._scene.getPhysicsEngine();
  112078. if (!this._physicsEngine) {
  112079. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  112080. }
  112081. else {
  112082. //set the object's quaternion, if not set
  112083. if (!this.object.rotationQuaternion) {
  112084. if (this.object.rotation) {
  112085. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  112086. }
  112087. else {
  112088. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112089. }
  112090. }
  112091. //default options params
  112092. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  112093. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  112094. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  112095. this._joints = [];
  112096. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  112097. if (!this.object.parent || this._options.ignoreParent) {
  112098. this._init();
  112099. }
  112100. else if (this.object.parent.physicsImpostor) {
  112101. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  112102. }
  112103. }
  112104. }
  112105. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  112106. /**
  112107. * Specifies if the physics imposter is disposed
  112108. */
  112109. get: function () {
  112110. return this._isDisposed;
  112111. },
  112112. enumerable: true,
  112113. configurable: true
  112114. });
  112115. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  112116. /**
  112117. * Gets the mass of the physics imposter
  112118. */
  112119. get: function () {
  112120. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  112121. },
  112122. set: function (value) {
  112123. this.setMass(value);
  112124. },
  112125. enumerable: true,
  112126. configurable: true
  112127. });
  112128. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  112129. /**
  112130. * Gets the coefficient of friction
  112131. */
  112132. get: function () {
  112133. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  112134. },
  112135. /**
  112136. * Sets the coefficient of friction
  112137. */
  112138. set: function (value) {
  112139. if (!this._physicsEngine) {
  112140. return;
  112141. }
  112142. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  112143. },
  112144. enumerable: true,
  112145. configurable: true
  112146. });
  112147. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  112148. /**
  112149. * Gets the coefficient of restitution
  112150. */
  112151. get: function () {
  112152. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  112153. },
  112154. /**
  112155. * Sets the coefficient of restitution
  112156. */
  112157. set: function (value) {
  112158. if (!this._physicsEngine) {
  112159. return;
  112160. }
  112161. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  112162. },
  112163. enumerable: true,
  112164. configurable: true
  112165. });
  112166. /**
  112167. * This function will completly initialize this impostor.
  112168. * It will create a new body - but only if this mesh has no parent.
  112169. * If it has, this impostor will not be used other than to define the impostor
  112170. * of the child mesh.
  112171. * @hidden
  112172. */
  112173. PhysicsImpostor.prototype._init = function () {
  112174. if (!this._physicsEngine) {
  112175. return;
  112176. }
  112177. this._physicsEngine.removeImpostor(this);
  112178. this.physicsBody = null;
  112179. this._parent = this._parent || this._getPhysicsParent();
  112180. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  112181. this._physicsEngine.addImpostor(this);
  112182. }
  112183. };
  112184. PhysicsImpostor.prototype._getPhysicsParent = function () {
  112185. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  112186. var parentMesh = this.object.parent;
  112187. return parentMesh.physicsImpostor;
  112188. }
  112189. return null;
  112190. };
  112191. /**
  112192. * Should a new body be generated.
  112193. * @returns boolean specifying if body initialization is required
  112194. */
  112195. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  112196. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  112197. };
  112198. /**
  112199. * Sets the updated scaling
  112200. * @param updated Specifies if the scaling is updated
  112201. */
  112202. PhysicsImpostor.prototype.setScalingUpdated = function () {
  112203. this.forceUpdate();
  112204. };
  112205. /**
  112206. * Force a regeneration of this or the parent's impostor's body.
  112207. * Use under cautious - This will remove all joints already implemented.
  112208. */
  112209. PhysicsImpostor.prototype.forceUpdate = function () {
  112210. this._init();
  112211. if (this.parent && !this._options.ignoreParent) {
  112212. this.parent.forceUpdate();
  112213. }
  112214. };
  112215. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  112216. /*public get mesh(): AbstractMesh {
  112217. return this._mesh;
  112218. }*/
  112219. /**
  112220. * Gets the body that holds this impostor. Either its own, or its parent.
  112221. */
  112222. get: function () {
  112223. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  112224. },
  112225. /**
  112226. * Set the physics body. Used mainly by the physics engine/plugin
  112227. */
  112228. set: function (physicsBody) {
  112229. if (this._physicsBody && this._physicsEngine) {
  112230. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  112231. }
  112232. this._physicsBody = physicsBody;
  112233. this.resetUpdateFlags();
  112234. },
  112235. enumerable: true,
  112236. configurable: true
  112237. });
  112238. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  112239. /**
  112240. * Get the parent of the physics imposter
  112241. * @returns Physics imposter or null
  112242. */
  112243. get: function () {
  112244. return !this._options.ignoreParent && this._parent ? this._parent : null;
  112245. },
  112246. /**
  112247. * Sets the parent of the physics imposter
  112248. */
  112249. set: function (value) {
  112250. this._parent = value;
  112251. },
  112252. enumerable: true,
  112253. configurable: true
  112254. });
  112255. /**
  112256. * Resets the update flags
  112257. */
  112258. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  112259. this._bodyUpdateRequired = false;
  112260. };
  112261. /**
  112262. * Gets the object extend size
  112263. * @returns the object extend size
  112264. */
  112265. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  112266. if (this.object.getBoundingInfo) {
  112267. var q = this.object.rotationQuaternion;
  112268. //reset rotation
  112269. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  112270. //calculate the world matrix with no rotation
  112271. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112272. var boundingInfo = this.object.getBoundingInfo();
  112273. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  112274. //bring back the rotation
  112275. this.object.rotationQuaternion = q;
  112276. //calculate the world matrix with the new rotation
  112277. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112278. return size;
  112279. }
  112280. else {
  112281. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  112282. }
  112283. };
  112284. /**
  112285. * Gets the object center
  112286. * @returns The object center
  112287. */
  112288. PhysicsImpostor.prototype.getObjectCenter = function () {
  112289. if (this.object.getBoundingInfo) {
  112290. var boundingInfo = this.object.getBoundingInfo();
  112291. return boundingInfo.boundingBox.centerWorld;
  112292. }
  112293. else {
  112294. return this.object.position;
  112295. }
  112296. };
  112297. /**
  112298. * Get a specific parametes from the options parameter
  112299. * @param paramName The object parameter name
  112300. * @returns The object parameter
  112301. */
  112302. PhysicsImpostor.prototype.getParam = function (paramName) {
  112303. return this._options[paramName];
  112304. };
  112305. /**
  112306. * Sets a specific parameter in the options given to the physics plugin
  112307. * @param paramName The parameter name
  112308. * @param value The value of the parameter
  112309. */
  112310. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  112311. this._options[paramName] = value;
  112312. this._bodyUpdateRequired = true;
  112313. };
  112314. /**
  112315. * Specifically change the body's mass option. Won't recreate the physics body object
  112316. * @param mass The mass of the physics imposter
  112317. */
  112318. PhysicsImpostor.prototype.setMass = function (mass) {
  112319. if (this.getParam("mass") !== mass) {
  112320. this.setParam("mass", mass);
  112321. }
  112322. if (this._physicsEngine) {
  112323. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  112324. }
  112325. };
  112326. /**
  112327. * Gets the linear velocity
  112328. * @returns linear velocity or null
  112329. */
  112330. PhysicsImpostor.prototype.getLinearVelocity = function () {
  112331. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112332. };
  112333. /**
  112334. * Sets the linear velocity
  112335. * @param velocity linear velocity or null
  112336. */
  112337. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  112338. if (this._physicsEngine) {
  112339. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  112340. }
  112341. };
  112342. /**
  112343. * Gets the angular velocity
  112344. * @returns angular velocity or null
  112345. */
  112346. PhysicsImpostor.prototype.getAngularVelocity = function () {
  112347. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112348. };
  112349. /**
  112350. * Sets the angular velocity
  112351. * @param velocity The velocity or null
  112352. */
  112353. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  112354. if (this._physicsEngine) {
  112355. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  112356. }
  112357. };
  112358. /**
  112359. * Execute a function with the physics plugin native code
  112360. * Provide a function the will have two variables - the world object and the physics body object
  112361. * @param func The function to execute with the physics plugin native code
  112362. */
  112363. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  112364. if (this._physicsEngine) {
  112365. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  112366. }
  112367. };
  112368. /**
  112369. * Register a function that will be executed before the physics world is stepping forward
  112370. * @param func The function to execute before the physics world is stepped forward
  112371. */
  112372. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  112373. this._onBeforePhysicsStepCallbacks.push(func);
  112374. };
  112375. /**
  112376. * Unregister a function that will be executed before the physics world is stepping forward
  112377. * @param func The function to execute before the physics world is stepped forward
  112378. */
  112379. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  112380. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  112381. if (index > -1) {
  112382. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  112383. }
  112384. else {
  112385. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112386. }
  112387. };
  112388. /**
  112389. * Register a function that will be executed after the physics step
  112390. * @param func The function to execute after physics step
  112391. */
  112392. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  112393. this._onAfterPhysicsStepCallbacks.push(func);
  112394. };
  112395. /**
  112396. * Unregisters a function that will be executed after the physics step
  112397. * @param func The function to execute after physics step
  112398. */
  112399. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  112400. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  112401. if (index > -1) {
  112402. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  112403. }
  112404. else {
  112405. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112406. }
  112407. };
  112408. /**
  112409. * register a function that will be executed when this impostor collides against a different body
  112410. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112411. * @param func Callback that is executed on collision
  112412. */
  112413. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  112414. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112415. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  112416. };
  112417. /**
  112418. * Unregisters the physics imposter on contact
  112419. * @param collideAgainst The physics object to collide against
  112420. * @param func Callback to execute on collision
  112421. */
  112422. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  112423. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112424. var index = -1;
  112425. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  112426. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  112427. // chcek the arrays match
  112428. var sameList = cbDef.otherImpostors.every(function (impostor) {
  112429. return collidedAgainstList.indexOf(impostor) > -1;
  112430. });
  112431. if (sameList) {
  112432. index = idx;
  112433. }
  112434. return sameList;
  112435. }
  112436. return false;
  112437. });
  112438. if (found) {
  112439. this._onPhysicsCollideCallbacks.splice(index, 1);
  112440. }
  112441. else {
  112442. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112443. }
  112444. };
  112445. /**
  112446. * Get the parent rotation
  112447. * @returns The parent rotation
  112448. */
  112449. PhysicsImpostor.prototype.getParentsRotation = function () {
  112450. var parent = this.object.parent;
  112451. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  112452. while (parent) {
  112453. if (parent.rotationQuaternion) {
  112454. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  112455. }
  112456. else {
  112457. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  112458. }
  112459. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  112460. parent = parent.parent;
  112461. }
  112462. return this._tmpQuat;
  112463. };
  112464. /**
  112465. * Apply a force
  112466. * @param force The force to apply
  112467. * @param contactPoint The contact point for the force
  112468. * @returns The physics imposter
  112469. */
  112470. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  112471. if (this._physicsEngine) {
  112472. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  112473. }
  112474. return this;
  112475. };
  112476. /**
  112477. * Apply an impulse
  112478. * @param force The impulse force
  112479. * @param contactPoint The contact point for the impulse force
  112480. * @returns The physics imposter
  112481. */
  112482. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  112483. if (this._physicsEngine) {
  112484. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  112485. }
  112486. return this;
  112487. };
  112488. /**
  112489. * A help function to create a joint
  112490. * @param otherImpostor A physics imposter used to create a joint
  112491. * @param jointType The type of joint
  112492. * @param jointData The data for the joint
  112493. * @returns The physics imposter
  112494. */
  112495. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  112496. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  112497. this.addJoint(otherImpostor, joint);
  112498. return this;
  112499. };
  112500. /**
  112501. * Add a joint to this impostor with a different impostor
  112502. * @param otherImpostor A physics imposter used to add a joint
  112503. * @param joint The joint to add
  112504. * @returns The physics imposter
  112505. */
  112506. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  112507. this._joints.push({
  112508. otherImpostor: otherImpostor,
  112509. joint: joint
  112510. });
  112511. if (this._physicsEngine) {
  112512. this._physicsEngine.addJoint(this, otherImpostor, joint);
  112513. }
  112514. return this;
  112515. };
  112516. /**
  112517. * Will keep this body still, in a sleep mode.
  112518. * @returns the physics imposter
  112519. */
  112520. PhysicsImpostor.prototype.sleep = function () {
  112521. if (this._physicsEngine) {
  112522. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  112523. }
  112524. return this;
  112525. };
  112526. /**
  112527. * Wake the body up.
  112528. * @returns The physics imposter
  112529. */
  112530. PhysicsImpostor.prototype.wakeUp = function () {
  112531. if (this._physicsEngine) {
  112532. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  112533. }
  112534. return this;
  112535. };
  112536. /**
  112537. * Clones the physics imposter
  112538. * @param newObject The physics imposter clones to this physics-enabled object
  112539. * @returns A nullable physics imposter
  112540. */
  112541. PhysicsImpostor.prototype.clone = function (newObject) {
  112542. if (!newObject) {
  112543. return null;
  112544. }
  112545. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  112546. };
  112547. /**
  112548. * Disposes the physics imposter
  112549. */
  112550. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  112551. var _this = this;
  112552. //no dispose if no physics engine is available.
  112553. if (!this._physicsEngine) {
  112554. return;
  112555. }
  112556. this._joints.forEach(function (j) {
  112557. if (_this._physicsEngine) {
  112558. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  112559. }
  112560. });
  112561. //dispose the physics body
  112562. this._physicsEngine.removeImpostor(this);
  112563. if (this.parent) {
  112564. this.parent.forceUpdate();
  112565. }
  112566. else {
  112567. /*this._object.getChildMeshes().forEach(function(mesh) {
  112568. if (mesh.physicsImpostor) {
  112569. if (disposeChildren) {
  112570. mesh.physicsImpostor.dispose();
  112571. mesh.physicsImpostor = null;
  112572. }
  112573. }
  112574. })*/
  112575. }
  112576. this._isDisposed = true;
  112577. };
  112578. /**
  112579. * Sets the delta position
  112580. * @param position The delta position amount
  112581. */
  112582. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  112583. this._deltaPosition.copyFrom(position);
  112584. };
  112585. /**
  112586. * Sets the delta rotation
  112587. * @param rotation The delta rotation amount
  112588. */
  112589. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  112590. if (!this._deltaRotation) {
  112591. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112592. }
  112593. this._deltaRotation.copyFrom(rotation);
  112594. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  112595. };
  112596. /**
  112597. * Gets the box size of the physics imposter and stores the result in the input parameter
  112598. * @param result Stores the box size
  112599. * @returns The physics imposter
  112600. */
  112601. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  112602. if (this._physicsEngine) {
  112603. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  112604. }
  112605. return this;
  112606. };
  112607. /**
  112608. * Gets the radius of the physics imposter
  112609. * @returns Radius of the physics imposter
  112610. */
  112611. PhysicsImpostor.prototype.getRadius = function () {
  112612. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  112613. };
  112614. /**
  112615. * Sync a bone with this impostor
  112616. * @param bone The bone to sync to the impostor.
  112617. * @param boneMesh The mesh that the bone is influencing.
  112618. * @param jointPivot The pivot of the joint / bone in local space.
  112619. * @param distToJoint Optional distance from the impostor to the joint.
  112620. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112621. */
  112622. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  112623. var tempVec = PhysicsImpostor._tmpVecs[0];
  112624. var mesh = this.object;
  112625. if (mesh.rotationQuaternion) {
  112626. if (adjustRotation) {
  112627. var tempQuat = PhysicsImpostor._tmpQuat;
  112628. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  112629. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112630. }
  112631. else {
  112632. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112633. }
  112634. }
  112635. tempVec.x = 0;
  112636. tempVec.y = 0;
  112637. tempVec.z = 0;
  112638. if (jointPivot) {
  112639. tempVec.x = jointPivot.x;
  112640. tempVec.y = jointPivot.y;
  112641. tempVec.z = jointPivot.z;
  112642. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  112643. if (distToJoint === undefined || distToJoint === null) {
  112644. distToJoint = jointPivot.length();
  112645. }
  112646. tempVec.x *= distToJoint;
  112647. tempVec.y *= distToJoint;
  112648. tempVec.z *= distToJoint;
  112649. }
  112650. if (bone.getParent()) {
  112651. tempVec.addInPlace(mesh.getAbsolutePosition());
  112652. bone.setAbsolutePosition(tempVec, boneMesh);
  112653. }
  112654. else {
  112655. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  112656. boneMesh.position.x -= tempVec.x;
  112657. boneMesh.position.y -= tempVec.y;
  112658. boneMesh.position.z -= tempVec.z;
  112659. }
  112660. };
  112661. /**
  112662. * Sync impostor to a bone
  112663. * @param bone The bone that the impostor will be synced to.
  112664. * @param boneMesh The mesh that the bone is influencing.
  112665. * @param jointPivot The pivot of the joint / bone in local space.
  112666. * @param distToJoint Optional distance from the impostor to the joint.
  112667. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112668. * @param boneAxis Optional vector3 axis the bone is aligned with
  112669. */
  112670. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  112671. var mesh = this.object;
  112672. if (mesh.rotationQuaternion) {
  112673. if (adjustRotation) {
  112674. var tempQuat = PhysicsImpostor._tmpQuat;
  112675. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  112676. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  112677. }
  112678. else {
  112679. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  112680. }
  112681. }
  112682. var pos = PhysicsImpostor._tmpVecs[0];
  112683. var boneDir = PhysicsImpostor._tmpVecs[1];
  112684. if (!boneAxis) {
  112685. boneAxis = PhysicsImpostor._tmpVecs[2];
  112686. boneAxis.x = 0;
  112687. boneAxis.y = 1;
  112688. boneAxis.z = 0;
  112689. }
  112690. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  112691. bone.getAbsolutePositionToRef(boneMesh, pos);
  112692. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  112693. distToJoint = jointPivot.length();
  112694. }
  112695. if (distToJoint !== undefined && distToJoint !== null) {
  112696. pos.x += boneDir.x * distToJoint;
  112697. pos.y += boneDir.y * distToJoint;
  112698. pos.z += boneDir.z * distToJoint;
  112699. }
  112700. mesh.setAbsolutePosition(pos);
  112701. };
  112702. /**
  112703. * The default object size of the imposter
  112704. */
  112705. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  112706. /**
  112707. * The identity quaternion of the imposter
  112708. */
  112709. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112710. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  112711. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112712. //Impostor types
  112713. /**
  112714. * No-Imposter type
  112715. */
  112716. PhysicsImpostor.NoImpostor = 0;
  112717. /**
  112718. * Sphere-Imposter type
  112719. */
  112720. PhysicsImpostor.SphereImpostor = 1;
  112721. /**
  112722. * Box-Imposter type
  112723. */
  112724. PhysicsImpostor.BoxImpostor = 2;
  112725. /**
  112726. * Plane-Imposter type
  112727. */
  112728. PhysicsImpostor.PlaneImpostor = 3;
  112729. /**
  112730. * Mesh-imposter type
  112731. */
  112732. PhysicsImpostor.MeshImpostor = 4;
  112733. /**
  112734. * Cylinder-Imposter type
  112735. */
  112736. PhysicsImpostor.CylinderImpostor = 7;
  112737. /**
  112738. * Particle-Imposter type
  112739. */
  112740. PhysicsImpostor.ParticleImpostor = 8;
  112741. /**
  112742. * Heightmap-Imposter type
  112743. */
  112744. PhysicsImpostor.HeightmapImpostor = 9;
  112745. return PhysicsImpostor;
  112746. }());
  112747. /***/ }),
  112748. /***/ "./Physics/physicsJoint.ts":
  112749. /*!*********************************!*\
  112750. !*** ./Physics/physicsJoint.ts ***!
  112751. \*********************************/
  112752. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  112753. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112754. "use strict";
  112755. __webpack_require__.r(__webpack_exports__);
  112756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  112757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  112758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  112759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  112760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  112761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112762. /**
  112763. * This is a holder class for the physics joint created by the physics plugin
  112764. * It holds a set of functions to control the underlying joint
  112765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112766. */
  112767. var PhysicsJoint = /** @class */ (function () {
  112768. /**
  112769. * Initializes the physics joint
  112770. * @param type The type of the physics joint
  112771. * @param jointData The data for the physics joint
  112772. */
  112773. function PhysicsJoint(
  112774. /**
  112775. * The type of the physics joint
  112776. */
  112777. type,
  112778. /**
  112779. * The data for the physics joint
  112780. */
  112781. jointData) {
  112782. this.type = type;
  112783. this.jointData = jointData;
  112784. jointData.nativeParams = jointData.nativeParams || {};
  112785. }
  112786. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  112787. /**
  112788. * Gets the physics joint
  112789. */
  112790. get: function () {
  112791. return this._physicsJoint;
  112792. },
  112793. /**
  112794. * Sets the physics joint
  112795. */
  112796. set: function (newJoint) {
  112797. if (this._physicsJoint) {
  112798. //remove from the wolrd
  112799. }
  112800. this._physicsJoint = newJoint;
  112801. },
  112802. enumerable: true,
  112803. configurable: true
  112804. });
  112805. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  112806. /**
  112807. * Sets the physics plugin
  112808. */
  112809. set: function (physicsPlugin) {
  112810. this._physicsPlugin = physicsPlugin;
  112811. },
  112812. enumerable: true,
  112813. configurable: true
  112814. });
  112815. /**
  112816. * Execute a function that is physics-plugin specific.
  112817. * @param {Function} func the function that will be executed.
  112818. * It accepts two parameters: the physics world and the physics joint
  112819. */
  112820. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  112821. func(this._physicsPlugin.world, this._physicsJoint);
  112822. };
  112823. //TODO check if the native joints are the same
  112824. //Joint Types
  112825. /**
  112826. * Distance-Joint type
  112827. */
  112828. PhysicsJoint.DistanceJoint = 0;
  112829. /**
  112830. * Hinge-Joint type
  112831. */
  112832. PhysicsJoint.HingeJoint = 1;
  112833. /**
  112834. * Ball-and-Socket joint type
  112835. */
  112836. PhysicsJoint.BallAndSocketJoint = 2;
  112837. /**
  112838. * Wheel-Joint type
  112839. */
  112840. PhysicsJoint.WheelJoint = 3;
  112841. /**
  112842. * Slider-Joint type
  112843. */
  112844. PhysicsJoint.SliderJoint = 4;
  112845. //OIMO
  112846. /**
  112847. * Prismatic-Joint type
  112848. */
  112849. PhysicsJoint.PrismaticJoint = 5;
  112850. //
  112851. /**
  112852. * Universal-Joint type
  112853. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112854. */
  112855. PhysicsJoint.UniversalJoint = 6;
  112856. /**
  112857. * Hinge-Joint 2 type
  112858. */
  112859. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  112860. //Cannon
  112861. /**
  112862. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112863. */
  112864. PhysicsJoint.PointToPointJoint = 8;
  112865. //Cannon only at the moment
  112866. /**
  112867. * Spring-Joint type
  112868. */
  112869. PhysicsJoint.SpringJoint = 9;
  112870. /**
  112871. * Lock-Joint type
  112872. */
  112873. PhysicsJoint.LockJoint = 10;
  112874. return PhysicsJoint;
  112875. }());
  112876. /**
  112877. * A class representing a physics distance joint
  112878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112879. */
  112880. var DistanceJoint = /** @class */ (function (_super) {
  112881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  112882. /**
  112883. *
  112884. * @param jointData The data for the Distance-Joint
  112885. */
  112886. function DistanceJoint(jointData) {
  112887. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  112888. }
  112889. /**
  112890. * Update the predefined distance.
  112891. * @param maxDistance The maximum preferred distance
  112892. * @param minDistance The minimum preferred distance
  112893. */
  112894. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  112895. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  112896. };
  112897. return DistanceJoint;
  112898. }(PhysicsJoint));
  112899. /**
  112900. * Represents a Motor-Enabled Joint
  112901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112902. */
  112903. var MotorEnabledJoint = /** @class */ (function (_super) {
  112904. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  112905. /**
  112906. * Initializes the Motor-Enabled Joint
  112907. * @param type The type of the joint
  112908. * @param jointData The physica joint data for the joint
  112909. */
  112910. function MotorEnabledJoint(type, jointData) {
  112911. return _super.call(this, type, jointData) || this;
  112912. }
  112913. /**
  112914. * Set the motor values.
  112915. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112916. * @param force the force to apply
  112917. * @param maxForce max force for this motor.
  112918. */
  112919. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  112920. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112921. };
  112922. /**
  112923. * Set the motor's limits.
  112924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112925. * @param upperLimit The upper limit of the motor
  112926. * @param lowerLimit The lower limit of the motor
  112927. */
  112928. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112929. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112930. };
  112931. return MotorEnabledJoint;
  112932. }(PhysicsJoint));
  112933. /**
  112934. * This class represents a single physics Hinge-Joint
  112935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112936. */
  112937. var HingeJoint = /** @class */ (function (_super) {
  112938. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  112939. /**
  112940. * Initializes the Hinge-Joint
  112941. * @param jointData The joint data for the Hinge-Joint
  112942. */
  112943. function HingeJoint(jointData) {
  112944. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  112945. }
  112946. /**
  112947. * Set the motor values.
  112948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112949. * @param {number} force the force to apply
  112950. * @param {number} maxForce max force for this motor.
  112951. */
  112952. HingeJoint.prototype.setMotor = function (force, maxForce) {
  112953. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112954. };
  112955. /**
  112956. * Set the motor's limits.
  112957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112958. * @param upperLimit The upper limit of the motor
  112959. * @param lowerLimit The lower limit of the motor
  112960. */
  112961. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112962. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112963. };
  112964. return HingeJoint;
  112965. }(MotorEnabledJoint));
  112966. /**
  112967. * This class represents a dual hinge physics joint (same as wheel joint)
  112968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112969. */
  112970. var Hinge2Joint = /** @class */ (function (_super) {
  112971. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  112972. /**
  112973. * Initializes the Hinge2-Joint
  112974. * @param jointData The joint data for the Hinge2-Joint
  112975. */
  112976. function Hinge2Joint(jointData) {
  112977. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  112978. }
  112979. /**
  112980. * Set the motor values.
  112981. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112982. * @param {number} force the force to apply
  112983. * @param {number} maxForce max force for this motor.
  112984. * @param {motorIndex} the motor's index, 0 or 1.
  112985. */
  112986. Hinge2Joint.prototype.setMotor = function (force, maxForce, motorIndex) {
  112987. if (motorIndex === void 0) { motorIndex = 0; }
  112988. this._physicsPlugin.setMotor(this, force || 0, maxForce, motorIndex);
  112989. };
  112990. /**
  112991. * Set the motor limits.
  112992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112993. * @param {number} upperLimit the upper limit
  112994. * @param {number} lowerLimit lower limit
  112995. * @param {motorIndex} the motor's index, 0 or 1.
  112996. */
  112997. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  112998. if (motorIndex === void 0) { motorIndex = 0; }
  112999. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  113000. };
  113001. return Hinge2Joint;
  113002. }(MotorEnabledJoint));
  113003. /***/ }),
  113004. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  113005. /*!****************************************************************************!*\
  113006. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  113007. \****************************************************************************/
  113008. /*! exports provided: DefaultRenderingPipeline */
  113009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113010. "use strict";
  113011. __webpack_require__.r(__webpack_exports__);
  113012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  113013. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113014. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113015. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113016. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113017. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113018. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  113019. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  113020. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  113021. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  113022. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  113023. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  113024. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113025. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113026. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  113027. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  113028. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113029. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  113030. /**
  113031. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113032. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113033. */
  113034. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  113035. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  113036. /**
  113037. * @constructor
  113038. * @param name - The rendering pipeline name (default: "")
  113039. * @param hdr - If high dynamic range textures should be used (default: true)
  113040. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113041. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113042. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113043. */
  113044. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  113045. if (name === void 0) { name = ""; }
  113046. if (hdr === void 0) { hdr = true; }
  113047. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  113048. if (automaticBuild === void 0) { automaticBuild = true; }
  113049. var _this = _super.call(this, scene.getEngine(), name) || this;
  113050. _this._camerasToBeAttached = [];
  113051. /**
  113052. * ID of the sharpen post process,
  113053. */
  113054. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  113055. /**
  113056. * @ignore
  113057. * ID of the image processing post process;
  113058. */
  113059. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  113060. /**
  113061. * @ignore
  113062. * ID of the Fast Approximate Anti-Aliasing post process;
  113063. */
  113064. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  113065. /**
  113066. * ID of the chromatic aberration post process,
  113067. */
  113068. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  113069. /**
  113070. * ID of the grain post process
  113071. */
  113072. _this.GrainPostProcessId = "GrainPostProcessEffect";
  113073. /**
  113074. * Glow post process which adds a glow to emmisive areas of the image
  113075. */
  113076. _this._glowLayer = null;
  113077. /**
  113078. * Animations which can be used to tweak settings over a period of time
  113079. */
  113080. _this.animations = [];
  113081. _this._imageProcessingConfigurationObserver = null;
  113082. // Values
  113083. _this._sharpenEnabled = false;
  113084. _this._bloomEnabled = false;
  113085. _this._depthOfFieldEnabled = false;
  113086. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  113087. _this._fxaaEnabled = false;
  113088. _this._imageProcessingEnabled = true;
  113089. _this._bloomScale = 0.5;
  113090. _this._chromaticAberrationEnabled = false;
  113091. _this._grainEnabled = false;
  113092. _this._buildAllowed = true;
  113093. _this._resizeObserver = null;
  113094. _this._hardwareScaleLevel = 1.0;
  113095. _this._bloomKernel = 64;
  113096. /**
  113097. * Specifies the weight of the bloom in the final rendering
  113098. */
  113099. _this._bloomWeight = 0.15;
  113100. /**
  113101. * Specifies the luma threshold for the area that will be blurred by the bloom
  113102. */
  113103. _this._bloomThreshold = 0.9;
  113104. _this._samples = 1;
  113105. _this._hasCleared = false;
  113106. _this._prevPostProcess = null;
  113107. _this._prevPrevPostProcess = null;
  113108. _this._depthOfFieldSceneObserver = null;
  113109. _this._cameras = cameras || scene.cameras;
  113110. _this._cameras = _this._cameras.slice();
  113111. _this._camerasToBeAttached = _this._cameras.slice();
  113112. _this._buildAllowed = automaticBuild;
  113113. // Initialize
  113114. _this._scene = scene;
  113115. var caps = _this._scene.getEngine().getCaps();
  113116. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  113117. // Misc
  113118. if (_this._hdr) {
  113119. if (caps.textureHalfFloatRender) {
  113120. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  113121. }
  113122. else if (caps.textureFloatRender) {
  113123. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  113124. }
  113125. }
  113126. else {
  113127. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  113128. }
  113129. // Attach
  113130. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113131. var engine = _this._scene.getEngine();
  113132. // Create post processes before hand so they can be modified before enabled.
  113133. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  113134. _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);
  113135. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  113136. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  113137. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  113138. _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);
  113139. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  113140. _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);
  113141. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  113142. _this._resizeObserver = engine.onResizeObservable.add(function () {
  113143. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  113144. _this.bloomKernel = _this.bloomKernel;
  113145. });
  113146. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  113147. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  113148. });
  113149. _this._buildPipeline();
  113150. return _this;
  113151. }
  113152. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  113153. get: function () {
  113154. return this._sharpenEnabled;
  113155. },
  113156. /**
  113157. * Enable or disable the sharpen process from the pipeline
  113158. */
  113159. set: function (enabled) {
  113160. if (this._sharpenEnabled === enabled) {
  113161. return;
  113162. }
  113163. this._sharpenEnabled = enabled;
  113164. this._buildPipeline();
  113165. },
  113166. enumerable: true,
  113167. configurable: true
  113168. });
  113169. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  113170. /**
  113171. * Specifies the size of the bloom blur kernel, relative to the final output size
  113172. */
  113173. get: function () {
  113174. return this._bloomKernel;
  113175. },
  113176. set: function (value) {
  113177. this._bloomKernel = value;
  113178. this.bloom.kernel = value / this._hardwareScaleLevel;
  113179. },
  113180. enumerable: true,
  113181. configurable: true
  113182. });
  113183. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  113184. get: function () {
  113185. return this._bloomWeight;
  113186. },
  113187. /**
  113188. * The strength of the bloom.
  113189. */
  113190. set: function (value) {
  113191. if (this._bloomWeight === value) {
  113192. return;
  113193. }
  113194. this.bloom.weight = value;
  113195. this._bloomWeight = value;
  113196. },
  113197. enumerable: true,
  113198. configurable: true
  113199. });
  113200. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  113201. get: function () {
  113202. return this._bloomThreshold;
  113203. },
  113204. /**
  113205. * The strength of the bloom.
  113206. */
  113207. set: function (value) {
  113208. if (this._bloomThreshold === value) {
  113209. return;
  113210. }
  113211. this.bloom.threshold = value;
  113212. this._bloomThreshold = value;
  113213. },
  113214. enumerable: true,
  113215. configurable: true
  113216. });
  113217. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  113218. get: function () {
  113219. return this._bloomScale;
  113220. },
  113221. /**
  113222. * The scale of the bloom, lower value will provide better performance.
  113223. */
  113224. set: function (value) {
  113225. if (this._bloomScale === value) {
  113226. return;
  113227. }
  113228. this._bloomScale = value;
  113229. // recreate bloom and dispose old as this setting is not dynamic
  113230. this._rebuildBloom();
  113231. this._buildPipeline();
  113232. },
  113233. enumerable: true,
  113234. configurable: true
  113235. });
  113236. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  113237. get: function () {
  113238. return this._bloomEnabled;
  113239. },
  113240. /**
  113241. * Enable or disable the bloom from the pipeline
  113242. */
  113243. set: function (enabled) {
  113244. if (this._bloomEnabled === enabled) {
  113245. return;
  113246. }
  113247. this._bloomEnabled = enabled;
  113248. this._buildPipeline();
  113249. },
  113250. enumerable: true,
  113251. configurable: true
  113252. });
  113253. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  113254. // recreate bloom and dispose old as this setting is not dynamic
  113255. var oldBloom = this.bloom;
  113256. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  113257. this.bloom.threshold = oldBloom.threshold;
  113258. for (var i = 0; i < this._cameras.length; i++) {
  113259. oldBloom.disposeEffects(this._cameras[i]);
  113260. }
  113261. };
  113262. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  113263. /**
  113264. * If the depth of field is enabled.
  113265. */
  113266. get: function () {
  113267. return this._depthOfFieldEnabled;
  113268. },
  113269. set: function (enabled) {
  113270. if (this._depthOfFieldEnabled === enabled) {
  113271. return;
  113272. }
  113273. this._depthOfFieldEnabled = enabled;
  113274. this._buildPipeline();
  113275. },
  113276. enumerable: true,
  113277. configurable: true
  113278. });
  113279. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  113280. /**
  113281. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113282. */
  113283. get: function () {
  113284. return this._depthOfFieldBlurLevel;
  113285. },
  113286. set: function (value) {
  113287. if (this._depthOfFieldBlurLevel === value) {
  113288. return;
  113289. }
  113290. this._depthOfFieldBlurLevel = value;
  113291. // recreate dof and dispose old as this setting is not dynamic
  113292. var oldDof = this.depthOfField;
  113293. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  113294. this.depthOfField.focalLength = oldDof.focalLength;
  113295. this.depthOfField.focusDistance = oldDof.focusDistance;
  113296. this.depthOfField.fStop = oldDof.fStop;
  113297. this.depthOfField.lensSize = oldDof.lensSize;
  113298. for (var i = 0; i < this._cameras.length; i++) {
  113299. oldDof.disposeEffects(this._cameras[i]);
  113300. }
  113301. this._buildPipeline();
  113302. },
  113303. enumerable: true,
  113304. configurable: true
  113305. });
  113306. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  113307. get: function () {
  113308. return this._fxaaEnabled;
  113309. },
  113310. /**
  113311. * If the anti aliasing is enabled.
  113312. */
  113313. set: function (enabled) {
  113314. if (this._fxaaEnabled === enabled) {
  113315. return;
  113316. }
  113317. this._fxaaEnabled = enabled;
  113318. this._buildPipeline();
  113319. },
  113320. enumerable: true,
  113321. configurable: true
  113322. });
  113323. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  113324. get: function () {
  113325. return this._samples;
  113326. },
  113327. /**
  113328. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113329. */
  113330. set: function (sampleCount) {
  113331. if (this._samples === sampleCount) {
  113332. return;
  113333. }
  113334. this._samples = sampleCount;
  113335. this._buildPipeline();
  113336. },
  113337. enumerable: true,
  113338. configurable: true
  113339. });
  113340. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  113341. get: function () {
  113342. return this._imageProcessingEnabled;
  113343. },
  113344. /**
  113345. * If image processing is enabled.
  113346. */
  113347. set: function (enabled) {
  113348. if (this._imageProcessingEnabled === enabled) {
  113349. return;
  113350. }
  113351. this._imageProcessingEnabled = enabled;
  113352. this._buildPipeline();
  113353. },
  113354. enumerable: true,
  113355. configurable: true
  113356. });
  113357. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  113358. get: function () {
  113359. return this._glowLayer == null;
  113360. },
  113361. /**
  113362. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113363. */
  113364. set: function (enabled) {
  113365. if (enabled && !this._glowLayer) {
  113366. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  113367. }
  113368. else if (!enabled && this._glowLayer) {
  113369. this._glowLayer.dispose();
  113370. this._glowLayer = null;
  113371. }
  113372. },
  113373. enumerable: true,
  113374. configurable: true
  113375. });
  113376. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  113377. get: function () {
  113378. return this._chromaticAberrationEnabled;
  113379. },
  113380. /**
  113381. * Enable or disable the chromaticAberration process from the pipeline
  113382. */
  113383. set: function (enabled) {
  113384. if (this._chromaticAberrationEnabled === enabled) {
  113385. return;
  113386. }
  113387. this._chromaticAberrationEnabled = enabled;
  113388. this._buildPipeline();
  113389. },
  113390. enumerable: true,
  113391. configurable: true
  113392. });
  113393. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  113394. get: function () {
  113395. return this._grainEnabled;
  113396. },
  113397. /**
  113398. * Enable or disable the grain process from the pipeline
  113399. */
  113400. set: function (enabled) {
  113401. if (this._grainEnabled === enabled) {
  113402. return;
  113403. }
  113404. this._grainEnabled = enabled;
  113405. this._buildPipeline();
  113406. },
  113407. enumerable: true,
  113408. configurable: true
  113409. });
  113410. /**
  113411. * Force the compilation of the entire pipeline.
  113412. */
  113413. DefaultRenderingPipeline.prototype.prepare = function () {
  113414. var previousState = this._buildAllowed;
  113415. this._buildAllowed = true;
  113416. this._buildPipeline();
  113417. this._buildAllowed = previousState;
  113418. };
  113419. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  113420. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  113421. if (this._hasCleared) {
  113422. postProcess.autoClear = false;
  113423. }
  113424. else {
  113425. postProcess.autoClear = true;
  113426. this._scene.autoClear = false;
  113427. this._hasCleared = true;
  113428. }
  113429. if (!skipTextureSharing) {
  113430. if (this._prevPrevPostProcess) {
  113431. postProcess.shareOutputWith(this._prevPrevPostProcess);
  113432. }
  113433. else {
  113434. postProcess.useOwnOutput();
  113435. }
  113436. if (this._prevPostProcess) {
  113437. this._prevPrevPostProcess = this._prevPostProcess;
  113438. }
  113439. this._prevPostProcess = postProcess;
  113440. }
  113441. };
  113442. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  113443. var _this = this;
  113444. if (!this._buildAllowed) {
  113445. return;
  113446. }
  113447. this._scene.autoClear = true;
  113448. var engine = this._scene.getEngine();
  113449. this._disposePostProcesses();
  113450. if (this._cameras !== null) {
  113451. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113452. // get back cameras to be used to reattach pipeline
  113453. this._cameras = this._camerasToBeAttached.slice();
  113454. }
  113455. this._reset();
  113456. this._prevPostProcess = null;
  113457. this._prevPrevPostProcess = null;
  113458. this._hasCleared = false;
  113459. if (this.depthOfFieldEnabled) {
  113460. // Multi camera suport
  113461. if (this._cameras.length > 1) {
  113462. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  113463. var camera = _a[_i];
  113464. var depthRenderer = this._scene.enableDepthRenderer(camera);
  113465. depthRenderer.useOnlyInActiveCamera = true;
  113466. }
  113467. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  113468. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  113469. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  113470. }
  113471. });
  113472. }
  113473. else {
  113474. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113475. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  113476. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  113477. }
  113478. if (!this.depthOfField._isReady()) {
  113479. this.depthOfField._updateEffects();
  113480. }
  113481. this.addEffect(this.depthOfField);
  113482. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  113483. }
  113484. else {
  113485. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113486. }
  113487. if (this.bloomEnabled) {
  113488. if (!this.bloom._isReady()) {
  113489. this.bloom._updateEffects();
  113490. }
  113491. this.addEffect(this.bloom);
  113492. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  113493. }
  113494. if (this._imageProcessingEnabled) {
  113495. 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);
  113496. if (this._hdr) {
  113497. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  113498. this._setAutoClearAndTextureSharing(this.imageProcessing);
  113499. }
  113500. else {
  113501. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  113502. }
  113503. }
  113504. if (this.sharpenEnabled) {
  113505. if (!this.sharpen.isReady()) {
  113506. this.sharpen.updateEffect();
  113507. }
  113508. this.addEffect(this._sharpenEffect);
  113509. this._setAutoClearAndTextureSharing(this.sharpen);
  113510. }
  113511. if (this.grainEnabled) {
  113512. if (!this.grain.isReady()) {
  113513. this.grain.updateEffect();
  113514. }
  113515. this.addEffect(this._grainEffect);
  113516. this._setAutoClearAndTextureSharing(this.grain);
  113517. }
  113518. if (this.chromaticAberrationEnabled) {
  113519. if (!this.chromaticAberration.isReady()) {
  113520. this.chromaticAberration.updateEffect();
  113521. }
  113522. this.addEffect(this._chromaticAberrationEffect);
  113523. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  113524. }
  113525. if (this.fxaaEnabled) {
  113526. 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);
  113527. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  113528. this._setAutoClearAndTextureSharing(this.fxaa, true);
  113529. }
  113530. if (this._cameras !== null) {
  113531. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  113532. }
  113533. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  113534. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  113535. }
  113536. };
  113537. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  113538. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  113539. for (var i = 0; i < this._cameras.length; i++) {
  113540. var camera = this._cameras[i];
  113541. if (this.imageProcessing) {
  113542. this.imageProcessing.dispose(camera);
  113543. }
  113544. if (this.fxaa) {
  113545. this.fxaa.dispose(camera);
  113546. }
  113547. // These are created in the constructor and should not be disposed on every pipeline change
  113548. if (disposeNonRecreated) {
  113549. if (this.sharpen) {
  113550. this.sharpen.dispose(camera);
  113551. }
  113552. if (this.depthOfField) {
  113553. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113554. this.depthOfField.disposeEffects(camera);
  113555. }
  113556. if (this.bloom) {
  113557. this.bloom.disposeEffects(camera);
  113558. }
  113559. if (this.chromaticAberration) {
  113560. this.chromaticAberration.dispose(camera);
  113561. }
  113562. if (this.grain) {
  113563. this.grain.dispose(camera);
  113564. }
  113565. if (this._glowLayer) {
  113566. this._glowLayer.dispose();
  113567. }
  113568. }
  113569. }
  113570. this.imageProcessing = null;
  113571. this.fxaa = null;
  113572. if (disposeNonRecreated) {
  113573. this.sharpen = null;
  113574. this._sharpenEffect = null;
  113575. this.depthOfField = null;
  113576. this.bloom = null;
  113577. this.chromaticAberration = null;
  113578. this._chromaticAberrationEffect = null;
  113579. this.grain = null;
  113580. this._grainEffect = null;
  113581. this._glowLayer = null;
  113582. }
  113583. };
  113584. /**
  113585. * Adds a camera to the pipeline
  113586. * @param camera the camera to be added
  113587. */
  113588. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  113589. this._camerasToBeAttached.push(camera);
  113590. this._buildPipeline();
  113591. };
  113592. /**
  113593. * Removes a camera from the pipeline
  113594. * @param camera the camera to remove
  113595. */
  113596. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  113597. var index = this._camerasToBeAttached.indexOf(camera);
  113598. this._camerasToBeAttached.splice(index, 1);
  113599. this._buildPipeline();
  113600. };
  113601. /**
  113602. * Dispose of the pipeline and stop all post processes
  113603. */
  113604. DefaultRenderingPipeline.prototype.dispose = function () {
  113605. this._disposePostProcesses(true);
  113606. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113607. this._scene.autoClear = true;
  113608. if (this._resizeObserver) {
  113609. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  113610. this._resizeObserver = null;
  113611. }
  113612. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  113613. _super.prototype.dispose.call(this);
  113614. };
  113615. /**
  113616. * Serialize the rendering pipeline (Used when exporting)
  113617. * @returns the serialized object
  113618. */
  113619. DefaultRenderingPipeline.prototype.serialize = function () {
  113620. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  113621. serializationObject.customType = "DefaultRenderingPipeline";
  113622. return serializationObject;
  113623. };
  113624. /**
  113625. * Parse the serialized pipeline
  113626. * @param source Source pipeline.
  113627. * @param scene The scene to load the pipeline to.
  113628. * @param rootUrl The URL of the serialized pipeline.
  113629. * @returns An instantiated pipeline from the serialized object.
  113630. */
  113631. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  113632. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  113633. };
  113634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113636. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  113637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113639. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  113640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113642. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  113643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113645. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  113646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113648. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  113649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113651. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  113652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113654. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  113655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113657. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  113658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113660. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  113661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113663. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  113664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113666. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  113667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113669. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  113670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113672. ], DefaultRenderingPipeline.prototype, "samples", null);
  113673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113675. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  113676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113678. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  113679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113681. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  113682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113684. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  113685. return DefaultRenderingPipeline;
  113686. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  113687. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  113688. /***/ }),
  113689. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  113690. /*!*********************************************************!*\
  113691. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  113692. \*********************************************************/
  113693. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  113694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113695. "use strict";
  113696. __webpack_require__.r(__webpack_exports__);
  113697. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  113698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  113699. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  113700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  113701. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  113702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  113703. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  113704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  113705. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  113706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  113707. /***/ }),
  113708. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  113709. /*!*************************************************************************!*\
  113710. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  113711. \*************************************************************************/
  113712. /*! exports provided: LensRenderingPipeline */
  113713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113714. "use strict";
  113715. __webpack_require__.r(__webpack_exports__);
  113716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  113717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113718. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113719. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113720. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113721. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113722. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113723. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  113724. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  113725. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  113726. /**
  113727. * BABYLON.JS Chromatic Aberration GLSL Shader
  113728. * Author: Olivier Guyot
  113729. * Separates very slightly R, G and B colors on the edges of the screen
  113730. * Inspired by Francois Tarlier & Martins Upitis
  113731. */
  113732. var LensRenderingPipeline = /** @class */ (function (_super) {
  113733. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  113734. /**
  113735. * @constructor
  113736. *
  113737. * Effect parameters are as follow:
  113738. * {
  113739. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113740. * edge_blur: number; // from 0 to x (1 for realism)
  113741. * distortion: number; // from 0 to x (1 for realism)
  113742. * grain_amount: number; // from 0 to 1
  113743. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113744. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113745. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113746. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113747. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113748. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113749. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113750. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113751. * }
  113752. * Note: if an effect parameter is unset, effect is disabled
  113753. *
  113754. * @param name The rendering pipeline name
  113755. * @param parameters - An object containing all parameters (see above)
  113756. * @param scene The scene linked to this pipeline
  113757. * @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)
  113758. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113759. */
  113760. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  113761. if (ratio === void 0) { ratio = 1.0; }
  113762. var _this = _super.call(this, scene.getEngine(), name) || this;
  113763. // Lens effects can be of the following:
  113764. // - chromatic aberration (slight shift of RGB colors)
  113765. // - blur on the edge of the lens
  113766. // - lens distortion
  113767. // - depth-of-field blur & highlights enhancing
  113768. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  113769. // - grain effect (noise or custom texture)
  113770. // Two additional texture samplers are needed:
  113771. // - depth map (for depth-of-field)
  113772. // - grain texture
  113773. /**
  113774. * @ignore
  113775. * The chromatic aberration PostProcess id in the pipeline
  113776. */
  113777. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  113778. /**
  113779. * @ignore
  113780. * The highlights enhancing PostProcess id in the pipeline
  113781. */
  113782. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  113783. /**
  113784. * @ignore
  113785. * The depth-of-field PostProcess id in the pipeline
  113786. */
  113787. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  113788. _this._scene = scene;
  113789. // Fetch texture samplers
  113790. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  113791. if (parameters.grain_texture) {
  113792. _this._grainTexture = parameters.grain_texture;
  113793. }
  113794. else {
  113795. _this._createGrainTexture();
  113796. }
  113797. // save parameters
  113798. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  113799. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  113800. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  113801. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  113802. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  113803. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  113804. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  113805. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  113806. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  113807. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  113808. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  113809. // Create effects
  113810. _this._createChromaticAberrationPostProcess(ratio);
  113811. _this._createHighlightsPostProcess(ratio);
  113812. _this._createDepthOfFieldPostProcess(ratio / 4);
  113813. // Set up pipeline
  113814. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  113815. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  113816. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  113817. if (_this._highlightsGain === -1) {
  113818. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  113819. }
  113820. // Finish
  113821. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113822. if (cameras) {
  113823. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113824. }
  113825. return _this;
  113826. }
  113827. // public methods (self explanatory)
  113828. /**
  113829. * Sets the amount of blur at the edges
  113830. * @param amount blur amount
  113831. */
  113832. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  113833. /**
  113834. * Sets edge blur to 0
  113835. */
  113836. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  113837. /**
  113838. * Sets the amout of grain
  113839. * @param amount Amount of grain
  113840. */
  113841. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  113842. /**
  113843. * Set grain amount to 0
  113844. */
  113845. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  113846. /**
  113847. * Sets the chromatic aberration amount
  113848. * @param amount amount of chromatic aberration
  113849. */
  113850. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  113851. /**
  113852. * Sets chromatic aberration amount to 0
  113853. */
  113854. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  113855. /**
  113856. * Sets the EdgeDistortion amount
  113857. * @param amount amount of EdgeDistortion
  113858. */
  113859. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  113860. /**
  113861. * Sets edge distortion to 0
  113862. */
  113863. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  113864. /**
  113865. * Sets the FocusDistance amount
  113866. * @param amount amount of FocusDistance
  113867. */
  113868. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  113869. /**
  113870. * Disables depth of field
  113871. */
  113872. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  113873. /**
  113874. * Sets the Aperture amount
  113875. * @param amount amount of Aperture
  113876. */
  113877. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  113878. /**
  113879. * Sets the DarkenOutOfFocus amount
  113880. * @param amount amount of DarkenOutOfFocus
  113881. */
  113882. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  113883. /**
  113884. * Creates a pentagon bokeh effect
  113885. */
  113886. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  113887. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  113888. };
  113889. /**
  113890. * Disables the pentagon bokeh effect
  113891. */
  113892. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  113893. this._highlightsPostProcess.updateEffect();
  113894. };
  113895. /**
  113896. * Enables noise blur
  113897. */
  113898. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  113899. /**
  113900. * Disables noise blur
  113901. */
  113902. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  113903. /**
  113904. * Sets the HighlightsGain amount
  113905. * @param amount amount of HighlightsGain
  113906. */
  113907. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  113908. this._highlightsGain = amount;
  113909. };
  113910. /**
  113911. * Sets the HighlightsThreshold amount
  113912. * @param amount amount of HighlightsThreshold
  113913. */
  113914. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  113915. if (this._highlightsGain === -1) {
  113916. this._highlightsGain = 1.0;
  113917. }
  113918. this._highlightsThreshold = amount;
  113919. };
  113920. /**
  113921. * Disables highlights
  113922. */
  113923. LensRenderingPipeline.prototype.disableHighlights = function () {
  113924. this._highlightsGain = -1;
  113925. };
  113926. /**
  113927. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113928. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113929. */
  113930. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  113931. if (disableDepthRender === void 0) { disableDepthRender = false; }
  113932. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113933. this._chromaticAberrationPostProcess = null;
  113934. this._highlightsPostProcess = null;
  113935. this._depthOfFieldPostProcess = null;
  113936. this._grainTexture.dispose();
  113937. if (disableDepthRender) {
  113938. this._scene.disableDepthRenderer();
  113939. }
  113940. };
  113941. // colors shifting and distortion
  113942. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  113943. var _this = this;
  113944. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  113945. [], // samplers
  113946. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113947. this._chromaticAberrationPostProcess.onApply = function (effect) {
  113948. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  113949. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113950. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113951. effect.setFloat('radialIntensity', 1);
  113952. effect.setFloat2('direction', 17, 17);
  113953. effect.setFloat2('centerPosition', 0.5, 0.5);
  113954. };
  113955. };
  113956. // highlights enhancing
  113957. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  113958. var _this = this;
  113959. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  113960. [], // samplers
  113961. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  113962. this._highlightsPostProcess.onApply = function (effect) {
  113963. effect.setFloat('gain', _this._highlightsGain);
  113964. effect.setFloat('threshold', _this._highlightsThreshold);
  113965. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  113966. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113967. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113968. };
  113969. };
  113970. // colors shifting and distortion
  113971. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  113972. var _this = this;
  113973. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  113974. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  113975. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  113976. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113977. this._depthOfFieldPostProcess.onApply = function (effect) {
  113978. effect.setTexture("depthSampler", _this._depthTexture);
  113979. effect.setTexture("grainSampler", _this._grainTexture);
  113980. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  113981. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  113982. effect.setFloat('grain_amount', _this._grainAmount);
  113983. effect.setBool('blur_noise', _this._blurNoise);
  113984. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113985. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113986. effect.setFloat('distortion', _this._distortion);
  113987. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  113988. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  113989. effect.setFloat('aperture', _this._dofAperture);
  113990. effect.setFloat('darken', _this._dofDarken);
  113991. effect.setFloat('edge_blur', _this._edgeBlur);
  113992. effect.setBool('highlights', (_this._highlightsGain !== -1));
  113993. if (_this._scene.activeCamera) {
  113994. effect.setFloat('near', _this._scene.activeCamera.minZ);
  113995. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  113996. }
  113997. };
  113998. };
  113999. // creates a black and white random noise texture, 512x512
  114000. LensRenderingPipeline.prototype._createGrainTexture = function () {
  114001. var size = 512;
  114002. 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);
  114003. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  114004. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  114005. var context = this._grainTexture.getContext();
  114006. var rand = function (min, max) {
  114007. return Math.random() * (max - min) + min;
  114008. };
  114009. var value;
  114010. for (var x = 0; x < size; x++) {
  114011. for (var y = 0; y < size; y++) {
  114012. value = Math.floor(rand(0.42, 0.58) * 255);
  114013. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  114014. context.fillRect(x, y, 1, 1);
  114015. }
  114016. }
  114017. this._grainTexture.update(false);
  114018. };
  114019. return LensRenderingPipeline;
  114020. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  114021. /***/ }),
  114022. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  114023. /*!**************************************************************************!*\
  114024. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  114025. \**************************************************************************/
  114026. /*! exports provided: SSAO2RenderingPipeline */
  114027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114028. "use strict";
  114029. __webpack_require__.r(__webpack_exports__);
  114030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  114031. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114032. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114033. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114034. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114035. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114036. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114037. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114038. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114039. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114040. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114042. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  114043. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  114044. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114045. /**
  114046. * Render pipeline to produce ssao effect
  114047. */
  114048. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  114049. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  114050. /**
  114051. * @constructor
  114052. * @param name The rendering pipeline name
  114053. * @param scene The scene linked to this pipeline
  114054. * @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 }
  114055. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114056. */
  114057. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  114058. var _this = _super.call(this, scene.getEngine(), name) || this;
  114059. // Members
  114060. /**
  114061. * @ignore
  114062. * The PassPostProcess id in the pipeline that contains the original scene color
  114063. */
  114064. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114065. /**
  114066. * @ignore
  114067. * The SSAO PostProcess id in the pipeline
  114068. */
  114069. _this.SSAORenderEffect = "SSAORenderEffect";
  114070. /**
  114071. * @ignore
  114072. * The horizontal blur PostProcess id in the pipeline
  114073. */
  114074. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114075. /**
  114076. * @ignore
  114077. * The vertical blur PostProcess id in the pipeline
  114078. */
  114079. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114080. /**
  114081. * @ignore
  114082. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114083. */
  114084. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114085. /**
  114086. * The output strength of the SSAO post-process. Default value is 1.0.
  114087. */
  114088. _this.totalStrength = 1.0;
  114089. /**
  114090. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  114091. */
  114092. _this.maxZ = 100.0;
  114093. /**
  114094. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  114095. */
  114096. _this.minZAspect = 0.2;
  114097. _this._samples = 8;
  114098. _this._textureSamples = 1;
  114099. _this._expensiveBlur = true;
  114100. /**
  114101. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  114102. */
  114103. _this.radius = 2.0;
  114104. /**
  114105. * The base color of the SSAO post-process
  114106. * The final result is "base + ssao" between [0, 1]
  114107. */
  114108. _this.base = 0;
  114109. _this._firstUpdate = true;
  114110. _this._bits = new Uint32Array(1);
  114111. _this._scene = scene;
  114112. _this._ratio = ratio;
  114113. if (!_this.isSupported) {
  114114. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  114115. return _this;
  114116. }
  114117. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  114118. var blurRatio = _this._ratio.blurRatio || ratio;
  114119. // Set up assets
  114120. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  114121. _this._createRandomTexture();
  114122. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  114123. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  114124. _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);
  114125. _this._originalColorPostProcess.samples = _this.textureSamples;
  114126. _this._createSSAOPostProcess(1.0);
  114127. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  114128. _this._createSSAOCombinePostProcess(blurRatio);
  114129. // Set up pipeline
  114130. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114131. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114132. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114133. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114134. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114135. // Finish
  114136. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114137. if (cameras) {
  114138. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114139. }
  114140. return _this;
  114141. }
  114142. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  114143. get: function () {
  114144. return this._samples;
  114145. },
  114146. /**
  114147. * Number of samples used for the SSAO calculations. Default value is 8
  114148. */
  114149. set: function (n) {
  114150. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  114151. this._samples = n;
  114152. this._sampleSphere = this._generateHemisphere();
  114153. this._firstUpdate = true;
  114154. },
  114155. enumerable: true,
  114156. configurable: true
  114157. });
  114158. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  114159. get: function () {
  114160. return this._textureSamples;
  114161. },
  114162. /**
  114163. * Number of samples to use for antialiasing
  114164. */
  114165. set: function (n) {
  114166. this._textureSamples = n;
  114167. this._originalColorPostProcess.samples = n;
  114168. this._blurHPostProcess.samples = n;
  114169. this._blurVPostProcess.samples = n;
  114170. this._ssaoPostProcess.samples = n;
  114171. this._ssaoCombinePostProcess.samples = n;
  114172. },
  114173. enumerable: true,
  114174. configurable: true
  114175. });
  114176. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  114177. get: function () {
  114178. return this._expensiveBlur;
  114179. },
  114180. /**
  114181. * If bilateral blur should be used
  114182. */
  114183. set: function (b) {
  114184. 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"]);
  114185. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  114186. this._expensiveBlur = b;
  114187. this._firstUpdate = true;
  114188. },
  114189. enumerable: true,
  114190. configurable: true
  114191. });
  114192. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  114193. /**
  114194. * Support test.
  114195. */
  114196. get: function () {
  114197. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  114198. if (!engine) {
  114199. return false;
  114200. }
  114201. return engine.getCaps().drawBuffersExtension;
  114202. },
  114203. enumerable: true,
  114204. configurable: true
  114205. });
  114206. // Public Methods
  114207. /**
  114208. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114209. */
  114210. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  114211. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  114212. for (var i = 0; i < this._scene.cameras.length; i++) {
  114213. var camera = this._scene.cameras[i];
  114214. this._originalColorPostProcess.dispose(camera);
  114215. this._ssaoPostProcess.dispose(camera);
  114216. this._blurHPostProcess.dispose(camera);
  114217. this._blurVPostProcess.dispose(camera);
  114218. this._ssaoCombinePostProcess.dispose(camera);
  114219. }
  114220. this._randomTexture.dispose();
  114221. if (disableGeometryBufferRenderer) {
  114222. this._scene.disableGeometryBufferRenderer();
  114223. }
  114224. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114225. _super.prototype.dispose.call(this);
  114226. };
  114227. // Private Methods
  114228. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  114229. var _this = this;
  114230. this._samplerOffsets = [];
  114231. var expensive = this.expensiveBlur;
  114232. for (var i = -8; i < 8; i++) {
  114233. this._samplerOffsets.push(i * 2 + 0.5);
  114234. }
  114235. 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");
  114236. this._blurHPostProcess.onApply = function (effect) {
  114237. if (!_this._scene.activeCamera) {
  114238. return;
  114239. }
  114240. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  114241. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114242. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114243. effect.setFloat("radius", _this.radius);
  114244. effect.setTexture("depthSampler", _this._depthTexture);
  114245. if (_this._firstUpdate) {
  114246. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114247. }
  114248. };
  114249. 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");
  114250. this._blurVPostProcess.onApply = function (effect) {
  114251. if (!_this._scene.activeCamera) {
  114252. return;
  114253. }
  114254. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  114255. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114256. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114257. effect.setFloat("radius", _this.radius);
  114258. effect.setTexture("depthSampler", _this._depthTexture);
  114259. if (_this._firstUpdate) {
  114260. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114261. _this._firstUpdate = false;
  114262. }
  114263. };
  114264. this._blurHPostProcess.samples = this.textureSamples;
  114265. this._blurVPostProcess.samples = this.textureSamples;
  114266. };
  114267. /** @hidden */
  114268. SSAO2RenderingPipeline.prototype._rebuild = function () {
  114269. this._firstUpdate = true;
  114270. _super.prototype._rebuild.call(this);
  114271. };
  114272. //Van der Corput radical inverse
  114273. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  114274. this._bits[0] = i;
  114275. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  114276. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  114277. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  114278. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  114279. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  114280. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  114281. };
  114282. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  114283. return [i / n, this._radicalInverse_VdC(i)];
  114284. };
  114285. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  114286. var phi = v * 2.0 * Math.PI;
  114287. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  114288. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  114289. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  114290. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  114291. };
  114292. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  114293. var numSamples = this.samples;
  114294. var result = [];
  114295. var vector;
  114296. var i = 0;
  114297. while (i < numSamples) {
  114298. if (numSamples < 16) {
  114299. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  114300. }
  114301. else {
  114302. var rand = this._hammersley(i, numSamples);
  114303. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  114304. }
  114305. result.push(vector.x, vector.y, vector.z);
  114306. i++;
  114307. }
  114308. return result;
  114309. };
  114310. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114311. var _this = this;
  114312. var numSamples = this.samples;
  114313. this._sampleSphere = this._generateHemisphere();
  114314. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  114315. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114316. "base", "range", "projection", "near", "far", "texelSize",
  114317. "xViewport", "yViewport", "maxZ", "minZAspect"
  114318. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114319. this._ssaoPostProcess.onApply = function (effect) {
  114320. if (_this._firstUpdate) {
  114321. effect.setArray3("sampleSphere", _this._sampleSphere);
  114322. effect.setFloat("randTextureTiles", 32.0);
  114323. }
  114324. if (!_this._scene.activeCamera) {
  114325. return;
  114326. }
  114327. effect.setFloat("samplesFactor", 1 / _this.samples);
  114328. effect.setFloat("totalStrength", _this.totalStrength);
  114329. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  114330. effect.setFloat("radius", _this.radius);
  114331. effect.setFloat("maxZ", _this.maxZ);
  114332. effect.setFloat("minZAspect", _this.minZAspect);
  114333. effect.setFloat("base", _this.base);
  114334. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114335. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114336. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  114337. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  114338. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  114339. effect.setTexture("textureSampler", _this._depthTexture);
  114340. effect.setTexture("normalSampler", _this._normalTexture);
  114341. effect.setTexture("randomSampler", _this._randomTexture);
  114342. };
  114343. this._ssaoPostProcess.samples = this.textureSamples;
  114344. };
  114345. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114346. var _this = this;
  114347. 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);
  114348. this._ssaoCombinePostProcess.onApply = function (effect) {
  114349. var viewport = _this._scene.activeCamera.viewport;
  114350. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  114351. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114352. };
  114353. this._ssaoCombinePostProcess.samples = this.textureSamples;
  114354. };
  114355. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  114356. var size = 128;
  114357. 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);
  114358. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  114359. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  114360. var context = this._randomTexture.getContext();
  114361. var rand = function (min, max) {
  114362. return Math.random() * (max - min) + min;
  114363. };
  114364. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  114365. for (var x = 0; x < size; x++) {
  114366. for (var y = 0; y < size; y++) {
  114367. randVector.x = rand(0.0, 1.0);
  114368. randVector.y = rand(0.0, 1.0);
  114369. randVector.z = 0.0;
  114370. randVector.normalize();
  114371. randVector.scaleInPlace(255);
  114372. randVector.x = Math.floor(randVector.x);
  114373. randVector.y = Math.floor(randVector.y);
  114374. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114375. context.fillRect(x, y, 1, 1);
  114376. }
  114377. }
  114378. this._randomTexture.update(false);
  114379. };
  114380. /**
  114381. * Serialize the rendering pipeline (Used when exporting)
  114382. * @returns the serialized object
  114383. */
  114384. SSAO2RenderingPipeline.prototype.serialize = function () {
  114385. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  114386. serializationObject.customType = "SSAO2RenderingPipeline";
  114387. return serializationObject;
  114388. };
  114389. /**
  114390. * Parse the serialized pipeline
  114391. * @param source Source pipeline.
  114392. * @param scene The scene to load the pipeline to.
  114393. * @param rootUrl The URL of the serialized pipeline.
  114394. * @returns An instantiated pipeline from the serialized object.
  114395. */
  114396. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  114397. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  114398. };
  114399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114401. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  114402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114404. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  114405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114407. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  114408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  114410. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  114411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  114413. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  114414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114416. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  114417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  114419. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  114420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114422. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  114423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114425. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  114426. return SSAO2RenderingPipeline;
  114427. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  114428. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  114429. /***/ }),
  114430. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  114431. /*!*************************************************************************!*\
  114432. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  114433. \*************************************************************************/
  114434. /*! exports provided: SSAORenderingPipeline */
  114435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114436. "use strict";
  114437. __webpack_require__.r(__webpack_exports__);
  114438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  114439. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114440. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114441. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114442. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114443. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114444. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114445. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114446. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114447. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114448. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114449. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114450. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  114451. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114452. /**
  114453. * Render pipeline to produce ssao effect
  114454. */
  114455. var SSAORenderingPipeline = /** @class */ (function (_super) {
  114456. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  114457. /**
  114458. * @constructor
  114459. * @param name - The rendering pipeline name
  114460. * @param scene - The scene linked to this pipeline
  114461. * @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 }
  114462. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114463. */
  114464. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  114465. var _this = _super.call(this, scene.getEngine(), name) || this;
  114466. // Members
  114467. /**
  114468. * @ignore
  114469. * The PassPostProcess id in the pipeline that contains the original scene color
  114470. */
  114471. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114472. /**
  114473. * @ignore
  114474. * The SSAO PostProcess id in the pipeline
  114475. */
  114476. _this.SSAORenderEffect = "SSAORenderEffect";
  114477. /**
  114478. * @ignore
  114479. * The horizontal blur PostProcess id in the pipeline
  114480. */
  114481. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114482. /**
  114483. * @ignore
  114484. * The vertical blur PostProcess id in the pipeline
  114485. */
  114486. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114487. /**
  114488. * @ignore
  114489. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114490. */
  114491. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114492. /**
  114493. * The output strength of the SSAO post-process. Default value is 1.0.
  114494. */
  114495. _this.totalStrength = 1.0;
  114496. /**
  114497. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114498. */
  114499. _this.radius = 0.0001;
  114500. /**
  114501. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114502. * Must not be equal to fallOff and superior to fallOff.
  114503. * Default value is 0.975
  114504. */
  114505. _this.area = 0.0075;
  114506. /**
  114507. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114508. * Must not be equal to area and inferior to area.
  114509. * Default value is 0.0
  114510. */
  114511. _this.fallOff = 0.000001;
  114512. /**
  114513. * The base color of the SSAO post-process
  114514. * The final result is "base + ssao" between [0, 1]
  114515. */
  114516. _this.base = 0.5;
  114517. _this._firstUpdate = true;
  114518. _this._scene = scene;
  114519. // Set up assets
  114520. _this._createRandomTexture();
  114521. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  114522. var ssaoRatio = ratio.ssaoRatio || ratio;
  114523. var combineRatio = ratio.combineRatio || ratio;
  114524. _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);
  114525. _this._createSSAOPostProcess(ssaoRatio);
  114526. _this._createBlurPostProcess(ssaoRatio);
  114527. _this._createSSAOCombinePostProcess(combineRatio);
  114528. // Set up pipeline
  114529. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114530. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114531. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114532. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114533. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114534. // Finish
  114535. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114536. if (cameras) {
  114537. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114538. }
  114539. return _this;
  114540. }
  114541. // Public Methods
  114542. /**
  114543. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114544. */
  114545. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  114546. if (disableDepthRender === void 0) { disableDepthRender = false; }
  114547. for (var i = 0; i < this._scene.cameras.length; i++) {
  114548. var camera = this._scene.cameras[i];
  114549. this._originalColorPostProcess.dispose(camera);
  114550. this._ssaoPostProcess.dispose(camera);
  114551. this._blurHPostProcess.dispose(camera);
  114552. this._blurVPostProcess.dispose(camera);
  114553. this._ssaoCombinePostProcess.dispose(camera);
  114554. }
  114555. this._randomTexture.dispose();
  114556. if (disableDepthRender) {
  114557. this._scene.disableDepthRenderer();
  114558. }
  114559. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114560. _super.prototype.dispose.call(this);
  114561. };
  114562. // Private Methods
  114563. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  114564. var _this = this;
  114565. var size = 16;
  114566. 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);
  114567. 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);
  114568. this._blurHPostProcess.onActivateObservable.add(function () {
  114569. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  114570. _this._blurHPostProcess.kernel = size * dw;
  114571. });
  114572. this._blurVPostProcess.onActivateObservable.add(function () {
  114573. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  114574. _this._blurVPostProcess.kernel = size * dw;
  114575. });
  114576. };
  114577. /** @hidden */
  114578. SSAORenderingPipeline.prototype._rebuild = function () {
  114579. this._firstUpdate = true;
  114580. _super.prototype._rebuild.call(this);
  114581. };
  114582. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114583. var _this = this;
  114584. var numSamples = 16;
  114585. var sampleSphere = [
  114586. 0.5381, 0.1856, -0.4319,
  114587. 0.1379, 0.2486, 0.4430,
  114588. 0.3371, 0.5679, -0.0057,
  114589. -0.6999, -0.0451, -0.0019,
  114590. 0.0689, -0.1598, -0.8547,
  114591. 0.0560, 0.0069, -0.1843,
  114592. -0.0146, 0.1402, 0.0762,
  114593. 0.0100, -0.1924, -0.0344,
  114594. -0.3577, -0.5301, -0.4358,
  114595. -0.3169, 0.1063, 0.0158,
  114596. 0.0103, -0.5869, 0.0046,
  114597. -0.0897, -0.4940, 0.3287,
  114598. 0.7119, -0.0154, -0.0918,
  114599. -0.0533, 0.0596, -0.5411,
  114600. 0.0352, -0.0631, 0.5460,
  114601. -0.4776, 0.2847, -0.0271
  114602. ];
  114603. var samplesFactor = 1.0 / numSamples;
  114604. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  114605. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114606. "area", "fallOff", "base", "range", "viewport"
  114607. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114608. this._ssaoPostProcess.onApply = function (effect) {
  114609. if (_this._firstUpdate) {
  114610. effect.setArray3("sampleSphere", sampleSphere);
  114611. effect.setFloat("samplesFactor", samplesFactor);
  114612. effect.setFloat("randTextureTiles", 4.0);
  114613. }
  114614. effect.setFloat("totalStrength", _this.totalStrength);
  114615. effect.setFloat("radius", _this.radius);
  114616. effect.setFloat("area", _this.area);
  114617. effect.setFloat("fallOff", _this.fallOff);
  114618. effect.setFloat("base", _this.base);
  114619. effect.setTexture("textureSampler", _this._depthTexture);
  114620. effect.setTexture("randomSampler", _this._randomTexture);
  114621. };
  114622. };
  114623. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114624. var _this = this;
  114625. 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);
  114626. this._ssaoCombinePostProcess.onApply = function (effect) {
  114627. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  114628. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114629. };
  114630. };
  114631. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  114632. var size = 512;
  114633. 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);
  114634. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114635. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114636. var context = this._randomTexture.getContext();
  114637. var rand = function (min, max) {
  114638. return Math.random() * (max - min) + min;
  114639. };
  114640. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  114641. for (var x = 0; x < size; x++) {
  114642. for (var y = 0; y < size; y++) {
  114643. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  114644. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  114645. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  114646. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114647. context.fillRect(x, y, 1, 1);
  114648. }
  114649. }
  114650. this._randomTexture.update(false);
  114651. };
  114652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114654. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  114655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114657. ], SSAORenderingPipeline.prototype, "radius", void 0);
  114658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114660. ], SSAORenderingPipeline.prototype, "area", void 0);
  114661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114663. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  114664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114666. ], SSAORenderingPipeline.prototype, "base", void 0);
  114667. return SSAORenderingPipeline;
  114668. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  114669. /***/ }),
  114670. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  114671. /*!*****************************************************************************!*\
  114672. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  114673. \*****************************************************************************/
  114674. /*! exports provided: StandardRenderingPipeline */
  114675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114676. "use strict";
  114677. __webpack_require__.r(__webpack_exports__);
  114678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  114679. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114680. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114681. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114682. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114683. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  114684. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114685. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114686. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114687. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114688. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114689. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  114690. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114691. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114692. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  114693. /**
  114694. * Standard rendering pipeline
  114695. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114696. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114697. */
  114698. var StandardRenderingPipeline = /** @class */ (function (_super) {
  114699. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  114700. /**
  114701. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114702. * @constructor
  114703. * @param name The rendering pipeline name
  114704. * @param scene The scene linked to this pipeline
  114705. * @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)
  114706. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114707. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114708. */
  114709. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  114710. if (originalPostProcess === void 0) { originalPostProcess = null; }
  114711. var _this = _super.call(this, scene.getEngine(), name) || this;
  114712. /**
  114713. * Post-process used to down scale an image x4
  114714. */
  114715. _this.downSampleX4PostProcess = null;
  114716. /**
  114717. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114718. */
  114719. _this.brightPassPostProcess = null;
  114720. /**
  114721. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114722. */
  114723. _this.blurHPostProcesses = [];
  114724. /**
  114725. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114726. */
  114727. _this.blurVPostProcesses = [];
  114728. /**
  114729. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114730. */
  114731. _this.textureAdderPostProcess = null;
  114732. /**
  114733. * Post-process used to create volumetric lighting effect
  114734. */
  114735. _this.volumetricLightPostProcess = null;
  114736. /**
  114737. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114738. */
  114739. _this.volumetricLightSmoothXPostProcess = null;
  114740. /**
  114741. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114742. */
  114743. _this.volumetricLightSmoothYPostProcess = null;
  114744. /**
  114745. * Post-process used to merge the volumetric light effect and the real scene color
  114746. */
  114747. _this.volumetricLightMergePostProces = null;
  114748. /**
  114749. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114750. */
  114751. _this.volumetricLightFinalPostProcess = null;
  114752. /**
  114753. * Base post-process used to calculate the average luminance of the final image for HDR
  114754. */
  114755. _this.luminancePostProcess = null;
  114756. /**
  114757. * Post-processes used to create down sample post-processes in order to get
  114758. * the average luminance of the final image for HDR
  114759. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114760. */
  114761. _this.luminanceDownSamplePostProcesses = [];
  114762. /**
  114763. * Post-process used to create a HDR effect (light adaptation)
  114764. */
  114765. _this.hdrPostProcess = null;
  114766. /**
  114767. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114768. */
  114769. _this.textureAdderFinalPostProcess = null;
  114770. /**
  114771. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114772. */
  114773. _this.lensFlareFinalPostProcess = null;
  114774. /**
  114775. * Post-process used to merge the final HDR post-process and the real scene color
  114776. */
  114777. _this.hdrFinalPostProcess = null;
  114778. /**
  114779. * Post-process used to create a lens flare effect
  114780. */
  114781. _this.lensFlarePostProcess = null;
  114782. /**
  114783. * Post-process that merges the result of the lens flare post-process and the real scene color
  114784. */
  114785. _this.lensFlareComposePostProcess = null;
  114786. /**
  114787. * Post-process used to create a motion blur effect
  114788. */
  114789. _this.motionBlurPostProcess = null;
  114790. /**
  114791. * Post-process used to create a depth of field effect
  114792. */
  114793. _this.depthOfFieldPostProcess = null;
  114794. /**
  114795. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114796. */
  114797. _this.fxaaPostProcess = null;
  114798. // Values
  114799. /**
  114800. * Represents the brightness threshold in order to configure the illuminated surfaces
  114801. */
  114802. _this.brightThreshold = 1.0;
  114803. /**
  114804. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114805. */
  114806. _this.blurWidth = 512.0;
  114807. /**
  114808. * Sets if the blur for highlighted surfaces must be only horizontal
  114809. */
  114810. _this.horizontalBlur = false;
  114811. /**
  114812. * Sets the overall exposure used by the pipeline
  114813. */
  114814. _this.exposure = 1.0;
  114815. /**
  114816. * Texture used typically to simulate "dirty" on camera lens
  114817. */
  114818. _this.lensTexture = null;
  114819. /**
  114820. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114821. */
  114822. _this.volumetricLightCoefficient = 0.2;
  114823. /**
  114824. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114825. */
  114826. _this.volumetricLightPower = 4.0;
  114827. /**
  114828. * Used the set the blur intensity to smooth the volumetric lights
  114829. */
  114830. _this.volumetricLightBlurScale = 64.0;
  114831. /**
  114832. * Light (spot or directional) used to generate the volumetric lights rays
  114833. * The source light must have a shadow generate so the pipeline can get its
  114834. * depth map
  114835. */
  114836. _this.sourceLight = null;
  114837. /**
  114838. * For eye adaptation, represents the minimum luminance the eye can see
  114839. */
  114840. _this.hdrMinimumLuminance = 1.0;
  114841. /**
  114842. * For eye adaptation, represents the decrease luminance speed
  114843. */
  114844. _this.hdrDecreaseRate = 0.5;
  114845. /**
  114846. * For eye adaptation, represents the increase luminance speed
  114847. */
  114848. _this.hdrIncreaseRate = 0.5;
  114849. /**
  114850. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114851. */
  114852. _this.lensColorTexture = null;
  114853. /**
  114854. * The overall strengh for the lens flare effect
  114855. */
  114856. _this.lensFlareStrength = 20.0;
  114857. /**
  114858. * Dispersion coefficient for lens flare ghosts
  114859. */
  114860. _this.lensFlareGhostDispersal = 1.4;
  114861. /**
  114862. * Main lens flare halo width
  114863. */
  114864. _this.lensFlareHaloWidth = 0.7;
  114865. /**
  114866. * Based on the lens distortion effect, defines how much the lens flare result
  114867. * is distorted
  114868. */
  114869. _this.lensFlareDistortionStrength = 16.0;
  114870. /**
  114871. * Lens star texture must be used to simulate rays on the flares and is available
  114872. * in the documentation
  114873. */
  114874. _this.lensStarTexture = null;
  114875. /**
  114876. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114877. * flare effect by taking account of the dirt texture
  114878. */
  114879. _this.lensFlareDirtTexture = null;
  114880. /**
  114881. * Represents the focal length for the depth of field effect
  114882. */
  114883. _this.depthOfFieldDistance = 10.0;
  114884. /**
  114885. * Represents the blur intensity for the blurred part of the depth of field effect
  114886. */
  114887. _this.depthOfFieldBlurWidth = 64.0;
  114888. /**
  114889. * For motion blur, defines how much the image is blurred by the movement
  114890. */
  114891. _this.motionStrength = 1.0;
  114892. /**
  114893. * List of animations for the pipeline (IAnimatable implementation)
  114894. */
  114895. _this.animations = [];
  114896. _this._currentDepthOfFieldSource = null;
  114897. _this._hdrCurrentLuminance = 1.0;
  114898. // Getters and setters
  114899. _this._bloomEnabled = false;
  114900. _this._depthOfFieldEnabled = false;
  114901. _this._vlsEnabled = false;
  114902. _this._lensFlareEnabled = false;
  114903. _this._hdrEnabled = false;
  114904. _this._motionBlurEnabled = false;
  114905. _this._fxaaEnabled = false;
  114906. _this._motionBlurSamples = 64.0;
  114907. _this._volumetricLightStepsCount = 50.0;
  114908. _this._samples = 1;
  114909. _this._cameras = cameras || [];
  114910. // Initialize
  114911. _this._scene = scene;
  114912. _this._basePostProcess = originalPostProcess;
  114913. _this._ratio = ratio;
  114914. // Misc
  114915. _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;
  114916. // Finish
  114917. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114918. _this._buildPipeline();
  114919. return _this;
  114920. }
  114921. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  114922. /**
  114923. * @ignore
  114924. * Specifies if the bloom pipeline is enabled
  114925. */
  114926. get: function () {
  114927. return this._bloomEnabled;
  114928. },
  114929. set: function (enabled) {
  114930. if (this._bloomEnabled === enabled) {
  114931. return;
  114932. }
  114933. this._bloomEnabled = enabled;
  114934. this._buildPipeline();
  114935. },
  114936. enumerable: true,
  114937. configurable: true
  114938. });
  114939. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  114940. /**
  114941. * @ignore
  114942. * Specifies if the depth of field pipeline is enabed
  114943. */
  114944. get: function () {
  114945. return this._depthOfFieldEnabled;
  114946. },
  114947. set: function (enabled) {
  114948. if (this._depthOfFieldEnabled === enabled) {
  114949. return;
  114950. }
  114951. this._depthOfFieldEnabled = enabled;
  114952. this._buildPipeline();
  114953. },
  114954. enumerable: true,
  114955. configurable: true
  114956. });
  114957. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  114958. /**
  114959. * @ignore
  114960. * Specifies if the lens flare pipeline is enabed
  114961. */
  114962. get: function () {
  114963. return this._lensFlareEnabled;
  114964. },
  114965. set: function (enabled) {
  114966. if (this._lensFlareEnabled === enabled) {
  114967. return;
  114968. }
  114969. this._lensFlareEnabled = enabled;
  114970. this._buildPipeline();
  114971. },
  114972. enumerable: true,
  114973. configurable: true
  114974. });
  114975. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  114976. /**
  114977. * @ignore
  114978. * Specifies if the HDR pipeline is enabled
  114979. */
  114980. get: function () {
  114981. return this._hdrEnabled;
  114982. },
  114983. set: function (enabled) {
  114984. if (this._hdrEnabled === enabled) {
  114985. return;
  114986. }
  114987. this._hdrEnabled = enabled;
  114988. this._buildPipeline();
  114989. },
  114990. enumerable: true,
  114991. configurable: true
  114992. });
  114993. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  114994. /**
  114995. * @ignore
  114996. * Specifies if the volumetric lights scattering effect is enabled
  114997. */
  114998. get: function () {
  114999. return this._vlsEnabled;
  115000. },
  115001. set: function (enabled) {
  115002. if (this._vlsEnabled === enabled) {
  115003. return;
  115004. }
  115005. if (enabled) {
  115006. var geometry = this._scene.enableGeometryBufferRenderer();
  115007. if (!geometry) {
  115008. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  115009. return;
  115010. }
  115011. }
  115012. this._vlsEnabled = enabled;
  115013. this._buildPipeline();
  115014. },
  115015. enumerable: true,
  115016. configurable: true
  115017. });
  115018. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  115019. /**
  115020. * @ignore
  115021. * Specifies if the motion blur effect is enabled
  115022. */
  115023. get: function () {
  115024. return this._motionBlurEnabled;
  115025. },
  115026. set: function (enabled) {
  115027. if (this._motionBlurEnabled === enabled) {
  115028. return;
  115029. }
  115030. this._motionBlurEnabled = enabled;
  115031. this._buildPipeline();
  115032. },
  115033. enumerable: true,
  115034. configurable: true
  115035. });
  115036. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  115037. /**
  115038. * Specifies if anti-aliasing is enabled
  115039. */
  115040. get: function () {
  115041. return this._fxaaEnabled;
  115042. },
  115043. set: function (enabled) {
  115044. if (this._fxaaEnabled === enabled) {
  115045. return;
  115046. }
  115047. this._fxaaEnabled = enabled;
  115048. this._buildPipeline();
  115049. },
  115050. enumerable: true,
  115051. configurable: true
  115052. });
  115053. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  115054. /**
  115055. * Specifies the number of steps used to calculate the volumetric lights
  115056. * Typically in interval [50, 200]
  115057. */
  115058. get: function () {
  115059. return this._volumetricLightStepsCount;
  115060. },
  115061. set: function (count) {
  115062. if (this.volumetricLightPostProcess) {
  115063. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  115064. }
  115065. this._volumetricLightStepsCount = count;
  115066. },
  115067. enumerable: true,
  115068. configurable: true
  115069. });
  115070. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  115071. /**
  115072. * Specifies the number of samples used for the motion blur effect
  115073. * Typically in interval [16, 64]
  115074. */
  115075. get: function () {
  115076. return this._motionBlurSamples;
  115077. },
  115078. set: function (samples) {
  115079. if (this.motionBlurPostProcess) {
  115080. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  115081. }
  115082. this._motionBlurSamples = samples;
  115083. },
  115084. enumerable: true,
  115085. configurable: true
  115086. });
  115087. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  115088. /**
  115089. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  115090. */
  115091. get: function () {
  115092. return this._samples;
  115093. },
  115094. set: function (sampleCount) {
  115095. if (this._samples === sampleCount) {
  115096. return;
  115097. }
  115098. this._samples = sampleCount;
  115099. this._buildPipeline();
  115100. },
  115101. enumerable: true,
  115102. configurable: true
  115103. });
  115104. StandardRenderingPipeline.prototype._buildPipeline = function () {
  115105. var _this = this;
  115106. var ratio = this._ratio;
  115107. var scene = this._scene;
  115108. this._disposePostProcesses();
  115109. this._reset();
  115110. // Create pass post-process
  115111. if (!this._basePostProcess) {
  115112. 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);
  115113. this.originalPostProcess.onApply = function () {
  115114. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  115115. };
  115116. }
  115117. else {
  115118. this.originalPostProcess = this._basePostProcess;
  115119. }
  115120. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  115121. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  115122. }
  115123. this._currentDepthOfFieldSource = this.originalPostProcess;
  115124. if (this._bloomEnabled) {
  115125. // Create down sample X4 post-process
  115126. this._createDownSampleX4PostProcess(scene, ratio / 2);
  115127. // Create bright pass post-process
  115128. this._createBrightPassPostProcess(scene, ratio / 2);
  115129. // Create gaussian blur post-processes (down sampling blurs)
  115130. this._createBlurPostProcesses(scene, ratio / 4, 1);
  115131. // Create texture adder post-process
  115132. this._createTextureAdderPostProcess(scene, ratio);
  115133. // Create depth-of-field source post-process
  115134. 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);
  115135. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  115136. }
  115137. if (this._vlsEnabled) {
  115138. // Create volumetric light
  115139. this._createVolumetricLightPostProcess(scene, ratio);
  115140. // Create volumetric light final post-process
  115141. 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);
  115142. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  115143. }
  115144. if (this._lensFlareEnabled) {
  115145. // Create lens flare post-process
  115146. this._createLensFlarePostProcess(scene, ratio);
  115147. // Create depth-of-field source post-process post lens-flare and disable it now
  115148. 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);
  115149. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  115150. }
  115151. if (this._hdrEnabled) {
  115152. // Create luminance
  115153. this._createLuminancePostProcesses(scene, this._floatTextureType);
  115154. // Create HDR
  115155. this._createHdrPostProcess(scene, ratio);
  115156. // Create depth-of-field source post-process post hdr and disable it now
  115157. 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);
  115158. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  115159. }
  115160. if (this._depthOfFieldEnabled) {
  115161. // Create gaussian blur used by depth-of-field
  115162. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  115163. // Create depth-of-field post-process
  115164. this._createDepthOfFieldPostProcess(scene, ratio);
  115165. }
  115166. if (this._motionBlurEnabled) {
  115167. // Create motion blur post-process
  115168. this._createMotionBlurPostProcess(scene, ratio);
  115169. }
  115170. if (this._fxaaEnabled) {
  115171. // Create fxaa post-process
  115172. 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);
  115173. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  115174. }
  115175. if (this._cameras !== null) {
  115176. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  115177. }
  115178. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  115179. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  115180. }
  115181. };
  115182. // Down Sample X4 Post-Processs
  115183. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  115184. var _this = this;
  115185. var downSampleX4Offsets = new Array(32);
  115186. 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);
  115187. this.downSampleX4PostProcess.onApply = function (effect) {
  115188. var id = 0;
  115189. var width = _this.downSampleX4PostProcess.width;
  115190. var height = _this.downSampleX4PostProcess.height;
  115191. for (var i = -2; i < 2; i++) {
  115192. for (var j = -2; j < 2; j++) {
  115193. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  115194. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  115195. id += 2;
  115196. }
  115197. }
  115198. effect.setArray2("dsOffsets", downSampleX4Offsets);
  115199. };
  115200. // Add to pipeline
  115201. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  115202. };
  115203. // Brightpass Post-Process
  115204. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  115205. var _this = this;
  115206. var brightOffsets = new Array(8);
  115207. 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);
  115208. this.brightPassPostProcess.onApply = function (effect) {
  115209. var sU = (1.0 / _this.brightPassPostProcess.width);
  115210. var sV = (1.0 / _this.brightPassPostProcess.height);
  115211. brightOffsets[0] = -0.5 * sU;
  115212. brightOffsets[1] = 0.5 * sV;
  115213. brightOffsets[2] = 0.5 * sU;
  115214. brightOffsets[3] = 0.5 * sV;
  115215. brightOffsets[4] = -0.5 * sU;
  115216. brightOffsets[5] = -0.5 * sV;
  115217. brightOffsets[6] = 0.5 * sU;
  115218. brightOffsets[7] = -0.5 * sV;
  115219. effect.setArray2("dsOffsets", brightOffsets);
  115220. effect.setFloat("brightThreshold", _this.brightThreshold);
  115221. };
  115222. // Add to pipeline
  115223. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  115224. };
  115225. // Create blur H&V post-processes
  115226. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  115227. var _this = this;
  115228. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  115229. var engine = scene.getEngine();
  115230. 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);
  115231. 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);
  115232. blurX.onActivateObservable.add(function () {
  115233. var dw = blurX.width / engine.getRenderWidth();
  115234. blurX.kernel = _this[blurWidthKey] * dw;
  115235. });
  115236. blurY.onActivateObservable.add(function () {
  115237. var dw = blurY.height / engine.getRenderHeight();
  115238. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  115239. });
  115240. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  115241. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  115242. this.blurHPostProcesses.push(blurX);
  115243. this.blurVPostProcesses.push(blurY);
  115244. };
  115245. // Create texture adder post-process
  115246. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  115247. var _this = this;
  115248. 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);
  115249. this.textureAdderPostProcess.onApply = function (effect) {
  115250. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  115251. effect.setTexture("lensSampler", _this.lensTexture);
  115252. effect.setFloat("exposure", _this.exposure);
  115253. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  115254. };
  115255. // Add to pipeline
  115256. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  115257. };
  115258. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  115259. var _this = this;
  115260. var geometryRenderer = scene.enableGeometryBufferRenderer();
  115261. geometryRenderer.enablePosition = true;
  115262. var geometry = geometryRenderer.getGBuffer();
  115263. // Base post-process
  115264. 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));
  115265. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115266. this.volumetricLightPostProcess.onApply = function (effect) {
  115267. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  115268. var generator = _this.sourceLight.getShadowGenerator();
  115269. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  115270. effect.setTexture("positionSampler", geometry.textures[2]);
  115271. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  115272. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  115273. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  115274. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  115275. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  115276. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  115277. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  115278. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  115279. effect.setVector2("depthValues", depthValues);
  115280. }
  115281. };
  115282. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  115283. // Smooth
  115284. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  115285. // Merge
  115286. 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");
  115287. this.volumetricLightMergePostProces.onApply = function (effect) {
  115288. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  115289. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  115290. };
  115291. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  115292. };
  115293. // Create luminance
  115294. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  115295. var _this = this;
  115296. // Create luminance
  115297. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  115298. 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);
  115299. var offsets = [];
  115300. this.luminancePostProcess.onApply = function (effect) {
  115301. var sU = (1.0 / _this.luminancePostProcess.width);
  115302. var sV = (1.0 / _this.luminancePostProcess.height);
  115303. offsets[0] = -0.5 * sU;
  115304. offsets[1] = 0.5 * sV;
  115305. offsets[2] = 0.5 * sU;
  115306. offsets[3] = 0.5 * sV;
  115307. offsets[4] = -0.5 * sU;
  115308. offsets[5] = -0.5 * sV;
  115309. offsets[6] = 0.5 * sU;
  115310. offsets[7] = -0.5 * sV;
  115311. effect.setArray2("lumOffsets", offsets);
  115312. };
  115313. // Add to pipeline
  115314. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  115315. // Create down sample luminance
  115316. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  115317. var size = Math.pow(3, i);
  115318. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  115319. if (i === 0) {
  115320. defines += "#define FINAL_DOWN_SAMPLER";
  115321. }
  115322. 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);
  115323. this.luminanceDownSamplePostProcesses.push(postProcess);
  115324. }
  115325. // Create callbacks and add effects
  115326. var lastLuminance = this.luminancePostProcess;
  115327. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  115328. var downSampleOffsets = new Array(18);
  115329. pp.onApply = function (effect) {
  115330. if (!lastLuminance) {
  115331. return;
  115332. }
  115333. var id = 0;
  115334. for (var x = -1; x < 2; x++) {
  115335. for (var y = -1; y < 2; y++) {
  115336. downSampleOffsets[id] = x / lastLuminance.width;
  115337. downSampleOffsets[id + 1] = y / lastLuminance.height;
  115338. id += 2;
  115339. }
  115340. }
  115341. effect.setArray2("dsOffsets", downSampleOffsets);
  115342. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  115343. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  115344. lastLuminance = _this.luminancePostProcess;
  115345. }
  115346. else {
  115347. lastLuminance = pp;
  115348. }
  115349. };
  115350. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  115351. pp.onAfterRender = function () {
  115352. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  115353. 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);
  115354. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  115355. };
  115356. }
  115357. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  115358. });
  115359. };
  115360. // Create HDR post-process
  115361. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  115362. var _this = this;
  115363. 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);
  115364. var outputLiminance = 1;
  115365. var time = 0;
  115366. var lastTime = 0;
  115367. this.hdrPostProcess.onApply = function (effect) {
  115368. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  115369. time += scene.getEngine().getDeltaTime();
  115370. if (outputLiminance < 0) {
  115371. outputLiminance = _this._hdrCurrentLuminance;
  115372. }
  115373. else {
  115374. var dt = (lastTime - time) / 1000.0;
  115375. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  115376. outputLiminance += _this.hdrDecreaseRate * dt;
  115377. }
  115378. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  115379. outputLiminance -= _this.hdrIncreaseRate * dt;
  115380. }
  115381. else {
  115382. outputLiminance = _this._hdrCurrentLuminance;
  115383. }
  115384. }
  115385. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  115386. effect.setFloat("averageLuminance", outputLiminance);
  115387. lastTime = time;
  115388. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  115389. };
  115390. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  115391. };
  115392. // Create lens flare post-process
  115393. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  115394. var _this = this;
  115395. 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);
  115396. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  115397. this._createBlurPostProcesses(scene, ratio / 4, 2);
  115398. 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);
  115399. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  115400. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  115401. // Lens flare
  115402. this.lensFlarePostProcess.onApply = function (effect) {
  115403. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  115404. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  115405. effect.setFloat("strength", _this.lensFlareStrength);
  115406. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  115407. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  115408. // Shift
  115409. resolution.x = _this.lensFlarePostProcess.width;
  115410. resolution.y = _this.lensFlarePostProcess.height;
  115411. effect.setVector2("resolution", resolution);
  115412. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  115413. };
  115414. // Compose
  115415. 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);
  115416. 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);
  115417. this.lensFlareComposePostProcess.onApply = function (effect) {
  115418. if (!_this._scene.activeCamera) {
  115419. return;
  115420. }
  115421. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115422. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  115423. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  115424. // Lens start rotation matrix
  115425. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  115426. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  115427. 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));
  115428. camRot *= 4.0;
  115429. 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);
  115430. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  115431. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  115432. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  115433. };
  115434. };
  115435. // Create depth-of-field post-process
  115436. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  115437. var _this = this;
  115438. 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);
  115439. this.depthOfFieldPostProcess.onApply = function (effect) {
  115440. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115441. effect.setTexture("depthSampler", _this._getDepthTexture());
  115442. effect.setFloat("distance", _this.depthOfFieldDistance);
  115443. };
  115444. // Add to pipeline
  115445. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  115446. };
  115447. // Create motion blur post-process
  115448. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  115449. var _this = this;
  115450. 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);
  115451. var motionScale = 0;
  115452. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115453. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115454. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115455. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115456. this.motionBlurPostProcess.onApply = function (effect) {
  115457. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  115458. viewProjection.invertToRef(invViewProjection);
  115459. effect.setMatrix("inverseViewProjection", invViewProjection);
  115460. effect.setMatrix("prevViewProjection", prevViewProjection);
  115461. prevViewProjection = viewProjection;
  115462. screenSize.x = _this.motionBlurPostProcess.width;
  115463. screenSize.y = _this.motionBlurPostProcess.height;
  115464. effect.setVector2("screenSize", screenSize);
  115465. motionScale = scene.getEngine().getFps() / 60.0;
  115466. effect.setFloat("motionScale", motionScale);
  115467. effect.setFloat("motionStrength", _this.motionStrength);
  115468. effect.setTexture("depthSampler", _this._getDepthTexture());
  115469. };
  115470. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  115471. };
  115472. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  115473. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  115474. var renderer = this._scene.enableGeometryBufferRenderer();
  115475. return renderer.getGBuffer().textures[0];
  115476. }
  115477. return this._scene.enableDepthRenderer().getDepthMap();
  115478. };
  115479. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  115480. for (var i = 0; i < this._cameras.length; i++) {
  115481. var camera = this._cameras[i];
  115482. if (this.originalPostProcess) {
  115483. this.originalPostProcess.dispose(camera);
  115484. }
  115485. if (this.downSampleX4PostProcess) {
  115486. this.downSampleX4PostProcess.dispose(camera);
  115487. }
  115488. if (this.brightPassPostProcess) {
  115489. this.brightPassPostProcess.dispose(camera);
  115490. }
  115491. if (this.textureAdderPostProcess) {
  115492. this.textureAdderPostProcess.dispose(camera);
  115493. }
  115494. if (this.textureAdderFinalPostProcess) {
  115495. this.textureAdderFinalPostProcess.dispose(camera);
  115496. }
  115497. if (this.volumetricLightPostProcess) {
  115498. this.volumetricLightPostProcess.dispose(camera);
  115499. }
  115500. if (this.volumetricLightSmoothXPostProcess) {
  115501. this.volumetricLightSmoothXPostProcess.dispose(camera);
  115502. }
  115503. if (this.volumetricLightSmoothYPostProcess) {
  115504. this.volumetricLightSmoothYPostProcess.dispose(camera);
  115505. }
  115506. if (this.volumetricLightMergePostProces) {
  115507. this.volumetricLightMergePostProces.dispose(camera);
  115508. }
  115509. if (this.volumetricLightFinalPostProcess) {
  115510. this.volumetricLightFinalPostProcess.dispose(camera);
  115511. }
  115512. if (this.lensFlarePostProcess) {
  115513. this.lensFlarePostProcess.dispose(camera);
  115514. }
  115515. if (this.lensFlareComposePostProcess) {
  115516. this.lensFlareComposePostProcess.dispose(camera);
  115517. }
  115518. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  115519. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  115520. }
  115521. if (this.luminancePostProcess) {
  115522. this.luminancePostProcess.dispose(camera);
  115523. }
  115524. if (this.hdrPostProcess) {
  115525. this.hdrPostProcess.dispose(camera);
  115526. }
  115527. if (this.hdrFinalPostProcess) {
  115528. this.hdrFinalPostProcess.dispose(camera);
  115529. }
  115530. if (this.depthOfFieldPostProcess) {
  115531. this.depthOfFieldPostProcess.dispose(camera);
  115532. }
  115533. if (this.motionBlurPostProcess) {
  115534. this.motionBlurPostProcess.dispose(camera);
  115535. }
  115536. if (this.fxaaPostProcess) {
  115537. this.fxaaPostProcess.dispose(camera);
  115538. }
  115539. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  115540. this.blurHPostProcesses[j].dispose(camera);
  115541. }
  115542. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  115543. this.blurVPostProcesses[j].dispose(camera);
  115544. }
  115545. }
  115546. this.originalPostProcess = null;
  115547. this.downSampleX4PostProcess = null;
  115548. this.brightPassPostProcess = null;
  115549. this.textureAdderPostProcess = null;
  115550. this.textureAdderFinalPostProcess = null;
  115551. this.volumetricLightPostProcess = null;
  115552. this.volumetricLightSmoothXPostProcess = null;
  115553. this.volumetricLightSmoothYPostProcess = null;
  115554. this.volumetricLightMergePostProces = null;
  115555. this.volumetricLightFinalPostProcess = null;
  115556. this.lensFlarePostProcess = null;
  115557. this.lensFlareComposePostProcess = null;
  115558. this.luminancePostProcess = null;
  115559. this.hdrPostProcess = null;
  115560. this.hdrFinalPostProcess = null;
  115561. this.depthOfFieldPostProcess = null;
  115562. this.motionBlurPostProcess = null;
  115563. this.fxaaPostProcess = null;
  115564. this.luminanceDownSamplePostProcesses = [];
  115565. this.blurHPostProcesses = [];
  115566. this.blurVPostProcesses = [];
  115567. };
  115568. /**
  115569. * Dispose of the pipeline and stop all post processes
  115570. */
  115571. StandardRenderingPipeline.prototype.dispose = function () {
  115572. this._disposePostProcesses();
  115573. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115574. _super.prototype.dispose.call(this);
  115575. };
  115576. /**
  115577. * Serialize the rendering pipeline (Used when exporting)
  115578. * @returns the serialized object
  115579. */
  115580. StandardRenderingPipeline.prototype.serialize = function () {
  115581. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  115582. if (this.sourceLight) {
  115583. serializationObject.sourceLightId = this.sourceLight.id;
  115584. }
  115585. serializationObject.customType = "StandardRenderingPipeline";
  115586. return serializationObject;
  115587. };
  115588. /**
  115589. * Parse the serialized pipeline
  115590. * @param source Source pipeline.
  115591. * @param scene The scene to load the pipeline to.
  115592. * @param rootUrl The URL of the serialized pipeline.
  115593. * @returns An instantiated pipeline from the serialized object.
  115594. */
  115595. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  115596. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  115597. if (source.sourceLightId) {
  115598. p.sourceLight = scene.getLightByID(source.sourceLightId);
  115599. }
  115600. return p;
  115601. };
  115602. /**
  115603. * Luminance steps
  115604. */
  115605. StandardRenderingPipeline.LuminanceSteps = 6;
  115606. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115608. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  115609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115611. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  115612. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115613. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115614. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  115615. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115616. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115617. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  115618. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  115620. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  115621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115623. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  115624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115626. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  115627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115629. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  115630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115632. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  115633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115635. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  115636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115638. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  115639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  115641. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  115642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115644. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  115645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115647. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  115648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115650. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  115651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115653. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  115654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  115656. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  115657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  115659. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  115660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115662. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  115663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115665. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  115666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115668. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  115669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115671. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  115672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115674. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  115675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115677. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  115678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115680. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  115681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115683. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  115684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115686. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  115687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115689. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  115690. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115692. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  115693. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115694. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115695. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  115696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115698. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  115699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115701. ], StandardRenderingPipeline.prototype, "samples", null);
  115702. return StandardRenderingPipeline;
  115703. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  115704. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  115705. /***/ }),
  115706. /***/ "./PostProcesses/RenderPipeline/index.ts":
  115707. /*!***********************************************!*\
  115708. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  115709. \***********************************************/
  115710. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  115711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115712. "use strict";
  115713. __webpack_require__.r(__webpack_exports__);
  115714. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  115715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  115716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  115717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  115718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  115719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  115720. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  115722. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  115724. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  115725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  115726. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  115727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  115728. /***/ }),
  115729. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  115730. /*!*****************************************************************!*\
  115731. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  115732. \*****************************************************************/
  115733. /*! exports provided: PostProcessRenderEffect */
  115734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115735. "use strict";
  115736. __webpack_require__.r(__webpack_exports__);
  115737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  115738. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115739. /**
  115740. * This represents a set of one or more post processes in Babylon.
  115741. * A post process can be used to apply a shader to a texture after it is rendered.
  115742. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115743. */
  115744. var PostProcessRenderEffect = /** @class */ (function () {
  115745. /**
  115746. * Instantiates a post process render effect.
  115747. * A post process can be used to apply a shader to a texture after it is rendered.
  115748. * @param engine The engine the effect is tied to
  115749. * @param name The name of the effect
  115750. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  115751. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  115752. */
  115753. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  115754. this._name = name;
  115755. this._singleInstance = singleInstance || true;
  115756. this._getPostProcesses = getPostProcesses;
  115757. this._cameras = {};
  115758. this._indicesForCamera = {};
  115759. this._postProcesses = {};
  115760. }
  115761. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  115762. /**
  115763. * Checks if all the post processes in the effect are supported.
  115764. */
  115765. get: function () {
  115766. for (var index in this._postProcesses) {
  115767. if (this._postProcesses.hasOwnProperty(index)) {
  115768. var pps = this._postProcesses[index];
  115769. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  115770. if (!pps[ppIndex].isSupported) {
  115771. return false;
  115772. }
  115773. }
  115774. }
  115775. }
  115776. return true;
  115777. },
  115778. enumerable: true,
  115779. configurable: true
  115780. });
  115781. /**
  115782. * Updates the current state of the effect
  115783. * @hidden
  115784. */
  115785. PostProcessRenderEffect.prototype._update = function () {
  115786. };
  115787. /**
  115788. * Attaches the effect on cameras
  115789. * @param cameras The camera to attach to.
  115790. * @hidden
  115791. */
  115792. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  115793. var _this = this;
  115794. var cameraKey;
  115795. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115796. if (!cams) {
  115797. return;
  115798. }
  115799. for (var i = 0; i < cams.length; i++) {
  115800. var camera = cams[i];
  115801. var cameraName = camera.name;
  115802. if (this._singleInstance) {
  115803. cameraKey = 0;
  115804. }
  115805. else {
  115806. cameraKey = cameraName;
  115807. }
  115808. if (!this._postProcesses[cameraKey]) {
  115809. var postProcess = this._getPostProcesses();
  115810. if (postProcess) {
  115811. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  115812. }
  115813. }
  115814. if (!this._indicesForCamera[cameraName]) {
  115815. this._indicesForCamera[cameraName] = [];
  115816. }
  115817. this._postProcesses[cameraKey].forEach(function (postProcess) {
  115818. var index = camera.attachPostProcess(postProcess);
  115819. _this._indicesForCamera[cameraName].push(index);
  115820. });
  115821. if (!this._cameras[cameraName]) {
  115822. this._cameras[cameraName] = camera;
  115823. }
  115824. }
  115825. };
  115826. /**
  115827. * Detatches the effect on cameras
  115828. * @param cameras The camera to detatch from.
  115829. * @hidden
  115830. */
  115831. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  115832. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115833. if (!cams) {
  115834. return;
  115835. }
  115836. for (var i = 0; i < cams.length; i++) {
  115837. var camera = cams[i];
  115838. var cameraName = camera.name;
  115839. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  115840. if (postProcesses) {
  115841. postProcesses.forEach(function (postProcess) {
  115842. camera.detachPostProcess(postProcess);
  115843. });
  115844. }
  115845. if (this._cameras[cameraName]) {
  115846. this._cameras[cameraName] = null;
  115847. }
  115848. }
  115849. };
  115850. /**
  115851. * Enables the effect on given cameras
  115852. * @param cameras The camera to enable.
  115853. * @hidden
  115854. */
  115855. PostProcessRenderEffect.prototype._enable = function (cameras) {
  115856. var _this = this;
  115857. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115858. if (!cams) {
  115859. return;
  115860. }
  115861. for (var i = 0; i < cams.length; i++) {
  115862. var camera = cams[i];
  115863. var cameraName = camera.name;
  115864. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  115865. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  115866. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115867. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  115868. });
  115869. }
  115870. }
  115871. }
  115872. };
  115873. /**
  115874. * Disables the effect on the given cameras
  115875. * @param cameras The camera to disable.
  115876. * @hidden
  115877. */
  115878. PostProcessRenderEffect.prototype._disable = function (cameras) {
  115879. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115880. if (!cams) {
  115881. return;
  115882. }
  115883. for (var i = 0; i < cams.length; i++) {
  115884. var camera = cams[i];
  115885. var cameraName = camera.name;
  115886. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115887. camera.detachPostProcess(postProcess);
  115888. });
  115889. }
  115890. };
  115891. /**
  115892. * Gets a list of the post processes contained in the effect.
  115893. * @param camera The camera to get the post processes on.
  115894. * @returns The list of the post processes in the effect.
  115895. */
  115896. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  115897. if (this._singleInstance) {
  115898. return this._postProcesses[0];
  115899. }
  115900. else {
  115901. if (!camera) {
  115902. return null;
  115903. }
  115904. return this._postProcesses[camera.name];
  115905. }
  115906. };
  115907. return PostProcessRenderEffect;
  115908. }());
  115909. /***/ }),
  115910. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  115911. /*!*******************************************************************!*\
  115912. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  115913. \*******************************************************************/
  115914. /*! exports provided: PostProcessRenderPipeline */
  115915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115916. "use strict";
  115917. __webpack_require__.r(__webpack_exports__);
  115918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  115919. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115920. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115921. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  115922. /**
  115923. * PostProcessRenderPipeline
  115924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115925. */
  115926. var PostProcessRenderPipeline = /** @class */ (function () {
  115927. /**
  115928. * Initializes a PostProcessRenderPipeline
  115929. * @param engine engine to add the pipeline to
  115930. * @param name name of the pipeline
  115931. */
  115932. function PostProcessRenderPipeline(engine, name) {
  115933. this.engine = engine;
  115934. this._name = name;
  115935. this._renderEffects = {};
  115936. this._renderEffectsForIsolatedPass = new Array();
  115937. this._cameras = [];
  115938. }
  115939. /**
  115940. * "PostProcessRenderPipeline"
  115941. * @returns "PostProcessRenderPipeline"
  115942. */
  115943. PostProcessRenderPipeline.prototype.getClassName = function () {
  115944. return "PostProcessRenderPipeline";
  115945. };
  115946. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  115947. /**
  115948. * If all the render effects in the pipeline are support
  115949. */
  115950. get: function () {
  115951. for (var renderEffectName in this._renderEffects) {
  115952. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115953. if (!this._renderEffects[renderEffectName].isSupported) {
  115954. return false;
  115955. }
  115956. }
  115957. }
  115958. return true;
  115959. },
  115960. enumerable: true,
  115961. configurable: true
  115962. });
  115963. /**
  115964. * Adds an effect to the pipeline
  115965. * @param renderEffect the effect to add
  115966. */
  115967. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  115968. this._renderEffects[renderEffect._name] = renderEffect;
  115969. };
  115970. // private
  115971. /** @hidden */
  115972. PostProcessRenderPipeline.prototype._rebuild = function () {
  115973. };
  115974. /** @hidden */
  115975. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  115976. var renderEffects = this._renderEffects[renderEffectName];
  115977. if (!renderEffects) {
  115978. return;
  115979. }
  115980. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  115981. };
  115982. /** @hidden */
  115983. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  115984. var renderEffects = this._renderEffects[renderEffectName];
  115985. if (!renderEffects) {
  115986. return;
  115987. }
  115988. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  115989. };
  115990. /** @hidden */
  115991. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  115992. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  115993. if (!cams) {
  115994. return;
  115995. }
  115996. var indicesToDelete = [];
  115997. var i;
  115998. for (i = 0; i < cams.length; i++) {
  115999. var camera = cams[i];
  116000. var cameraName = camera.name;
  116001. if (this._cameras.indexOf(camera) === -1) {
  116002. this._cameras[cameraName] = camera;
  116003. }
  116004. else if (unique) {
  116005. indicesToDelete.push(i);
  116006. }
  116007. }
  116008. for (i = 0; i < indicesToDelete.length; i++) {
  116009. cameras.splice(indicesToDelete[i], 1);
  116010. }
  116011. for (var renderEffectName in this._renderEffects) {
  116012. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116013. this._renderEffects[renderEffectName]._attachCameras(cams);
  116014. }
  116015. }
  116016. };
  116017. /** @hidden */
  116018. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  116019. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  116020. if (!cams) {
  116021. return;
  116022. }
  116023. for (var renderEffectName in this._renderEffects) {
  116024. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116025. this._renderEffects[renderEffectName]._detachCameras(cams);
  116026. }
  116027. }
  116028. for (var i = 0; i < cams.length; i++) {
  116029. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  116030. }
  116031. };
  116032. /** @hidden */
  116033. PostProcessRenderPipeline.prototype._update = function () {
  116034. for (var renderEffectName in this._renderEffects) {
  116035. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116036. this._renderEffects[renderEffectName]._update();
  116037. }
  116038. }
  116039. for (var i = 0; i < this._cameras.length; i++) {
  116040. var cameraName = this._cameras[i].name;
  116041. if (this._renderEffectsForIsolatedPass[cameraName]) {
  116042. this._renderEffectsForIsolatedPass[cameraName]._update();
  116043. }
  116044. }
  116045. };
  116046. /** @hidden */
  116047. PostProcessRenderPipeline.prototype._reset = function () {
  116048. this._renderEffects = {};
  116049. this._renderEffectsForIsolatedPass = new Array();
  116050. };
  116051. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  116052. // 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)
  116053. var effectKeys = Object.keys(this._renderEffects);
  116054. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  116055. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  116056. if (postProcesses) {
  116057. postProcesses[0].samples = sampleCount;
  116058. return true;
  116059. }
  116060. }
  116061. return false;
  116062. };
  116063. /**
  116064. * Disposes of the pipeline
  116065. */
  116066. PostProcessRenderPipeline.prototype.dispose = function () {
  116067. // Must be implemented by children
  116068. };
  116069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116071. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  116072. return PostProcessRenderPipeline;
  116073. }());
  116074. /***/ }),
  116075. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  116076. /*!**************************************************************************!*\
  116077. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  116078. \**************************************************************************/
  116079. /*! exports provided: PostProcessRenderPipelineManager */
  116080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116081. "use strict";
  116082. __webpack_require__.r(__webpack_exports__);
  116083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  116084. /**
  116085. * PostProcessRenderPipelineManager class
  116086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116087. */
  116088. var PostProcessRenderPipelineManager = /** @class */ (function () {
  116089. /**
  116090. * Initializes a PostProcessRenderPipelineManager
  116091. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116092. */
  116093. function PostProcessRenderPipelineManager() {
  116094. this._renderPipelines = {};
  116095. }
  116096. /**
  116097. * Adds a pipeline to the manager
  116098. * @param renderPipeline The pipeline to add
  116099. */
  116100. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  116101. this._renderPipelines[renderPipeline._name] = renderPipeline;
  116102. };
  116103. /**
  116104. * Attaches a camera to the pipeline
  116105. * @param renderPipelineName The name of the pipeline to attach to
  116106. * @param cameras the camera to attach
  116107. * @param unique if the camera can be attached multiple times to the pipeline
  116108. */
  116109. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  116110. if (unique === void 0) { unique = false; }
  116111. var renderPipeline = this._renderPipelines[renderPipelineName];
  116112. if (!renderPipeline) {
  116113. return;
  116114. }
  116115. renderPipeline._attachCameras(cameras, unique);
  116116. };
  116117. /**
  116118. * Detaches a camera from the pipeline
  116119. * @param renderPipelineName The name of the pipeline to detach from
  116120. * @param cameras the camera to detach
  116121. */
  116122. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  116123. var renderPipeline = this._renderPipelines[renderPipelineName];
  116124. if (!renderPipeline) {
  116125. return;
  116126. }
  116127. renderPipeline._detachCameras(cameras);
  116128. };
  116129. /**
  116130. * Enables an effect by name on a pipeline
  116131. * @param renderPipelineName the name of the pipeline to enable the effect in
  116132. * @param renderEffectName the name of the effect to enable
  116133. * @param cameras the cameras that the effect should be enabled on
  116134. */
  116135. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  116136. var renderPipeline = this._renderPipelines[renderPipelineName];
  116137. if (!renderPipeline) {
  116138. return;
  116139. }
  116140. renderPipeline._enableEffect(renderEffectName, cameras);
  116141. };
  116142. /**
  116143. * Disables an effect by name on a pipeline
  116144. * @param renderPipelineName the name of the pipeline to disable the effect in
  116145. * @param renderEffectName the name of the effect to disable
  116146. * @param cameras the cameras that the effect should be disabled on
  116147. */
  116148. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  116149. var renderPipeline = this._renderPipelines[renderPipelineName];
  116150. if (!renderPipeline) {
  116151. return;
  116152. }
  116153. renderPipeline._disableEffect(renderEffectName, cameras);
  116154. };
  116155. /**
  116156. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  116157. */
  116158. PostProcessRenderPipelineManager.prototype.update = function () {
  116159. for (var renderPipelineName in this._renderPipelines) {
  116160. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116161. var pipeline = this._renderPipelines[renderPipelineName];
  116162. if (!pipeline.isSupported) {
  116163. pipeline.dispose();
  116164. delete this._renderPipelines[renderPipelineName];
  116165. }
  116166. else {
  116167. pipeline._update();
  116168. }
  116169. }
  116170. }
  116171. };
  116172. /** @hidden */
  116173. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  116174. for (var renderPipelineName in this._renderPipelines) {
  116175. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116176. var pipeline = this._renderPipelines[renderPipelineName];
  116177. pipeline._rebuild();
  116178. }
  116179. }
  116180. };
  116181. /**
  116182. * Disposes of the manager and pipelines
  116183. */
  116184. PostProcessRenderPipelineManager.prototype.dispose = function () {
  116185. for (var renderPipelineName in this._renderPipelines) {
  116186. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116187. var pipeline = this._renderPipelines[renderPipelineName];
  116188. pipeline.dispose();
  116189. }
  116190. }
  116191. };
  116192. return PostProcessRenderPipelineManager;
  116193. }());
  116194. /***/ }),
  116195. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  116196. /*!****************************************************************************************!*\
  116197. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  116198. \****************************************************************************************/
  116199. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  116200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116201. "use strict";
  116202. __webpack_require__.r(__webpack_exports__);
  116203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  116204. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  116205. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  116206. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  116207. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  116208. get: function () {
  116209. if (!this._postProcessRenderPipelineManager) {
  116210. // Register the G Buffer component to the scene.
  116211. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  116212. if (!component) {
  116213. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  116214. this._addComponent(component);
  116215. }
  116216. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  116217. }
  116218. return this._postProcessRenderPipelineManager;
  116219. },
  116220. enumerable: true,
  116221. configurable: true
  116222. });
  116223. /**
  116224. * Defines the Render Pipeline scene component responsible to rendering pipelines
  116225. */
  116226. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  116227. /**
  116228. * Creates a new instance of the component for the given scene
  116229. * @param scene Defines the scene to register the component in
  116230. */
  116231. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  116232. /**
  116233. * The component name helpfull to identify the component in the list of scene components.
  116234. */
  116235. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  116236. this.scene = scene;
  116237. }
  116238. /**
  116239. * Registers the component in a given scene
  116240. */
  116241. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  116242. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  116243. };
  116244. /**
  116245. * Rebuilds the elements related to this component in case of
  116246. * context lost for instance.
  116247. */
  116248. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  116249. if (this.scene._postProcessRenderPipelineManager) {
  116250. this.scene._postProcessRenderPipelineManager._rebuild();
  116251. }
  116252. };
  116253. /**
  116254. * Disposes the component and the associated ressources
  116255. */
  116256. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  116257. if (this.scene._postProcessRenderPipelineManager) {
  116258. this.scene._postProcessRenderPipelineManager.dispose();
  116259. }
  116260. };
  116261. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  116262. if (this.scene._postProcessRenderPipelineManager) {
  116263. this.scene._postProcessRenderPipelineManager.update();
  116264. }
  116265. };
  116266. return PostProcessRenderPipelineManagerSceneComponent;
  116267. }());
  116268. /***/ }),
  116269. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  116270. /*!**********************************************!*\
  116271. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  116272. \**********************************************/
  116273. /*! exports provided: AnaglyphPostProcess */
  116274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116275. "use strict";
  116276. __webpack_require__.r(__webpack_exports__);
  116277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  116278. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116279. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116280. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  116281. /**
  116282. * Postprocess used to generate anaglyphic rendering
  116283. */
  116284. var AnaglyphPostProcess = /** @class */ (function (_super) {
  116285. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  116286. /**
  116287. * Creates a new AnaglyphPostProcess
  116288. * @param name defines postprocess name
  116289. * @param options defines creation options or target ratio scale
  116290. * @param rigCameras defines cameras using this postprocess
  116291. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116292. * @param engine defines hosting engine
  116293. * @param reusable defines if the postprocess will be reused multiple times per frame
  116294. */
  116295. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  116296. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  116297. _this._passedProcess = rigCameras[0]._rigPostProcess;
  116298. _this.onApplyObservable.add(function (effect) {
  116299. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  116300. });
  116301. return _this;
  116302. }
  116303. return AnaglyphPostProcess;
  116304. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116305. /***/ }),
  116306. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  116307. /*!***************************************************!*\
  116308. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  116309. \***************************************************/
  116310. /*! exports provided: BlackAndWhitePostProcess */
  116311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116312. "use strict";
  116313. __webpack_require__.r(__webpack_exports__);
  116314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  116315. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116316. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116317. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  116318. /**
  116319. * Post process used to render in black and white
  116320. */
  116321. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  116322. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  116323. /**
  116324. * Creates a black and white post process
  116325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116326. * @param name The name of the effect.
  116327. * @param options The required width/height ratio to downsize to before computing the render pass.
  116328. * @param camera The camera to apply the render pass to.
  116329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116330. * @param engine The engine which the post process will be applied. (default: current engine)
  116331. * @param reusable If the post process can be reused on the same frame. (default: false)
  116332. */
  116333. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  116334. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  116335. /**
  116336. * Linear about to convert he result to black and white (default: 1)
  116337. */
  116338. _this.degree = 1;
  116339. _this.onApplyObservable.add(function (effect) {
  116340. effect.setFloat("degree", _this.degree);
  116341. });
  116342. return _this;
  116343. }
  116344. return BlackAndWhitePostProcess;
  116345. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116346. /***/ }),
  116347. /***/ "./PostProcesses/bloomEffect.ts":
  116348. /*!**************************************!*\
  116349. !*** ./PostProcesses/bloomEffect.ts ***!
  116350. \**************************************/
  116351. /*! exports provided: BloomEffect */
  116352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116353. "use strict";
  116354. __webpack_require__.r(__webpack_exports__);
  116355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  116356. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116357. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116358. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  116359. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116360. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  116361. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116362. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116363. /**
  116364. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  116365. */
  116366. var BloomEffect = /** @class */ (function (_super) {
  116367. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  116368. /**
  116369. * Creates a new instance of @see BloomEffect
  116370. * @param scene The scene the effect belongs to.
  116371. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  116372. * @param bloomKernel The size of the kernel to be used when applying the blur.
  116373. * @param bloomWeight The the strength of bloom.
  116374. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116375. * @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)
  116376. */
  116377. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  116378. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  116379. if (blockCompilation === void 0) { blockCompilation = false; }
  116380. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  116381. return _this._effects;
  116382. }, true) || this;
  116383. _this.bloomScale = bloomScale;
  116384. /**
  116385. * @hidden Internal
  116386. */
  116387. _this._effects = [];
  116388. _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);
  116389. _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);
  116390. _this._blurX.alwaysForcePOT = true;
  116391. _this._blurX.autoClear = false;
  116392. _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);
  116393. _this._blurY.alwaysForcePOT = true;
  116394. _this._blurY.autoClear = false;
  116395. _this.kernel = bloomKernel;
  116396. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  116397. _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);
  116398. _this._merge.autoClear = false;
  116399. _this._effects.push(_this._merge);
  116400. return _this;
  116401. }
  116402. Object.defineProperty(BloomEffect.prototype, "threshold", {
  116403. /**
  116404. * The luminance threshold to find bright areas of the image to bloom.
  116405. */
  116406. get: function () {
  116407. return this._downscale.threshold;
  116408. },
  116409. set: function (value) {
  116410. this._downscale.threshold = value;
  116411. },
  116412. enumerable: true,
  116413. configurable: true
  116414. });
  116415. Object.defineProperty(BloomEffect.prototype, "weight", {
  116416. /**
  116417. * The strength of the bloom.
  116418. */
  116419. get: function () {
  116420. return this._merge.weight;
  116421. },
  116422. set: function (value) {
  116423. this._merge.weight = value;
  116424. },
  116425. enumerable: true,
  116426. configurable: true
  116427. });
  116428. Object.defineProperty(BloomEffect.prototype, "kernel", {
  116429. /**
  116430. * Specifies the size of the bloom blur kernel, relative to the final output size
  116431. */
  116432. get: function () {
  116433. return this._blurX.kernel / this.bloomScale;
  116434. },
  116435. set: function (value) {
  116436. this._blurX.kernel = value * this.bloomScale;
  116437. this._blurY.kernel = value * this.bloomScale;
  116438. },
  116439. enumerable: true,
  116440. configurable: true
  116441. });
  116442. /**
  116443. * Disposes each of the internal effects for a given camera.
  116444. * @param camera The camera to dispose the effect on.
  116445. */
  116446. BloomEffect.prototype.disposeEffects = function (camera) {
  116447. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116448. this._effects[effectIndex].dispose(camera);
  116449. }
  116450. };
  116451. /**
  116452. * @hidden Internal
  116453. */
  116454. BloomEffect.prototype._updateEffects = function () {
  116455. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116456. this._effects[effectIndex].updateEffect();
  116457. }
  116458. };
  116459. /**
  116460. * Internal
  116461. * @returns if all the contained post processes are ready.
  116462. * @hidden
  116463. */
  116464. BloomEffect.prototype._isReady = function () {
  116465. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116466. if (!this._effects[effectIndex].isReady()) {
  116467. return false;
  116468. }
  116469. }
  116470. return true;
  116471. };
  116472. return BloomEffect;
  116473. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  116474. /***/ }),
  116475. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  116476. /*!************************************************!*\
  116477. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  116478. \************************************************/
  116479. /*! exports provided: BloomMergePostProcess */
  116480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116481. "use strict";
  116482. __webpack_require__.r(__webpack_exports__);
  116483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  116484. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116485. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116486. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116487. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  116488. /**
  116489. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116490. */
  116491. var BloomMergePostProcess = /** @class */ (function (_super) {
  116492. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  116493. /**
  116494. * Creates a new instance of @see BloomMergePostProcess
  116495. * @param name The name of the effect.
  116496. * @param originalFromInput Post process which's input will be used for the merge.
  116497. * @param blurred Blurred highlights post process which's output will be used.
  116498. * @param weight Weight of the bloom to be added to the original input.
  116499. * @param options The required width/height ratio to downsize to before computing the render pass.
  116500. * @param camera The camera to apply the render pass to.
  116501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116502. * @param engine The engine which the post process will be applied. (default: current engine)
  116503. * @param reusable If the post process can be reused on the same frame. (default: false)
  116504. * @param textureType Type of textures used when performing the post process. (default: 0)
  116505. * @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)
  116506. */
  116507. function BloomMergePostProcess(name, originalFromInput, blurred,
  116508. /** Weight of the bloom to be added to the original input. */
  116509. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116510. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116511. if (blockCompilation === void 0) { blockCompilation = false; }
  116512. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116513. _this.weight = weight;
  116514. _this.onApplyObservable.add(function (effect) {
  116515. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116516. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  116517. effect.setFloat("bloomWeight", _this.weight);
  116518. });
  116519. if (!blockCompilation) {
  116520. _this.updateEffect();
  116521. }
  116522. return _this;
  116523. }
  116524. return BloomMergePostProcess;
  116525. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116526. /***/ }),
  116527. /***/ "./PostProcesses/blurPostProcess.ts":
  116528. /*!******************************************!*\
  116529. !*** ./PostProcesses/blurPostProcess.ts ***!
  116530. \******************************************/
  116531. /*! exports provided: BlurPostProcess */
  116532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116533. "use strict";
  116534. __webpack_require__.r(__webpack_exports__);
  116535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  116536. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116537. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116538. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116539. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116540. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  116541. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  116542. /**
  116543. * The Blur Post Process which blurs an image based on a kernel and direction.
  116544. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  116545. */
  116546. var BlurPostProcess = /** @class */ (function (_super) {
  116547. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  116548. /**
  116549. * Creates a new instance BlurPostProcess
  116550. * @param name The name of the effect.
  116551. * @param direction The direction in which to blur the image.
  116552. * @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.
  116553. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  116554. * @param camera The camera to apply the render pass to.
  116555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116556. * @param engine The engine which the post process will be applied. (default: current engine)
  116557. * @param reusable If the post process can be reused on the same frame. (default: false)
  116558. * @param textureType Type of textures used when performing the post process. (default: 0)
  116559. * @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)
  116560. */
  116561. function BlurPostProcess(name,
  116562. /** The direction in which to blur the image. */
  116563. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  116564. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  116565. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116566. if (defines === void 0) { defines = ""; }
  116567. if (blockCompilation === void 0) { blockCompilation = false; }
  116568. 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;
  116569. _this.direction = direction;
  116570. _this.blockCompilation = blockCompilation;
  116571. _this._packedFloat = false;
  116572. _this._staticDefines = "";
  116573. _this._staticDefines = defines;
  116574. _this.onApplyObservable.add(function (effect) {
  116575. if (_this._outputTexture) {
  116576. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  116577. }
  116578. else {
  116579. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  116580. }
  116581. });
  116582. _this.kernel = kernel;
  116583. return _this;
  116584. }
  116585. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  116586. /**
  116587. * Gets the length in pixels of the blur sample region
  116588. */
  116589. get: function () {
  116590. return this._idealKernel;
  116591. },
  116592. /**
  116593. * Sets the length in pixels of the blur sample region
  116594. */
  116595. set: function (v) {
  116596. if (this._idealKernel === v) {
  116597. return;
  116598. }
  116599. v = Math.max(v, 1);
  116600. this._idealKernel = v;
  116601. this._kernel = this._nearestBestKernel(v);
  116602. if (!this.blockCompilation) {
  116603. this._updateParameters();
  116604. }
  116605. },
  116606. enumerable: true,
  116607. configurable: true
  116608. });
  116609. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  116610. /**
  116611. * Gets wether or not the blur is unpacking/repacking floats
  116612. */
  116613. get: function () {
  116614. return this._packedFloat;
  116615. },
  116616. /**
  116617. * Sets wether or not the blur needs to unpack/repack floats
  116618. */
  116619. set: function (v) {
  116620. if (this._packedFloat === v) {
  116621. return;
  116622. }
  116623. this._packedFloat = v;
  116624. if (!this.blockCompilation) {
  116625. this._updateParameters();
  116626. }
  116627. },
  116628. enumerable: true,
  116629. configurable: true
  116630. });
  116631. /**
  116632. * Updates the effect with the current post process compile time values and recompiles the shader.
  116633. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116634. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116635. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116636. * @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
  116637. * @param onCompiled Called when the shader has been compiled.
  116638. * @param onError Called if there is an error when compiling a shader.
  116639. */
  116640. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116641. if (defines === void 0) { defines = null; }
  116642. if (uniforms === void 0) { uniforms = null; }
  116643. if (samplers === void 0) { samplers = null; }
  116644. this._updateParameters(onCompiled, onError);
  116645. };
  116646. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  116647. // Generate sampling offsets and weights
  116648. var N = this._kernel;
  116649. var centerIndex = (N - 1) / 2;
  116650. // Generate Gaussian sampling weights over kernel
  116651. var offsets = [];
  116652. var weights = [];
  116653. var totalWeight = 0;
  116654. for (var i = 0; i < N; i++) {
  116655. var u = i / (N - 1);
  116656. var w = this._gaussianWeight(u * 2.0 - 1);
  116657. offsets[i] = (i - centerIndex);
  116658. weights[i] = w;
  116659. totalWeight += w;
  116660. }
  116661. // Normalize weights
  116662. for (var i = 0; i < weights.length; i++) {
  116663. weights[i] /= totalWeight;
  116664. }
  116665. // Optimize: combine samples to take advantage of hardware linear sampling
  116666. // Walk from left to center, combining pairs (symmetrically)
  116667. var linearSamplingWeights = [];
  116668. var linearSamplingOffsets = [];
  116669. var linearSamplingMap = [];
  116670. for (var i = 0; i <= centerIndex; i += 2) {
  116671. var j = Math.min(i + 1, Math.floor(centerIndex));
  116672. var singleCenterSample = i === j;
  116673. if (singleCenterSample) {
  116674. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116675. }
  116676. else {
  116677. var sharedCell = j === centerIndex;
  116678. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  116679. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  116680. if (offsetLinear === 0) {
  116681. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116682. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  116683. }
  116684. else {
  116685. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  116686. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  116687. }
  116688. }
  116689. }
  116690. for (var i = 0; i < linearSamplingMap.length; i++) {
  116691. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  116692. linearSamplingWeights[i] = linearSamplingMap[i].w;
  116693. }
  116694. // Replace with optimized
  116695. offsets = linearSamplingOffsets;
  116696. weights = linearSamplingWeights;
  116697. // Generate shaders
  116698. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  116699. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  116700. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  116701. var defines = "";
  116702. defines += this._staticDefines;
  116703. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  116704. if (this._staticDefines.indexOf("DOF") != -1) {
  116705. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  116706. varyingCount--;
  116707. }
  116708. for (var i = 0; i < varyingCount; i++) {
  116709. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  116710. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  116711. }
  116712. var depCount = 0;
  116713. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  116714. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  116715. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  116716. depCount++;
  116717. }
  116718. if (this.packedFloat) {
  116719. defines += "#define PACKEDFLOAT 1";
  116720. }
  116721. this.blockCompilation = false;
  116722. _super.prototype.updateEffect.call(this, defines, null, null, {
  116723. varyingCount: varyingCount,
  116724. depCount: depCount
  116725. }, onCompiled, onError);
  116726. };
  116727. /**
  116728. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  116729. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  116730. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  116731. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  116732. * The gaps between physical kernels are compensated for in the weighting of the samples
  116733. * @param idealKernel Ideal blur kernel.
  116734. * @return Nearest best kernel.
  116735. */
  116736. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  116737. var v = Math.round(idealKernel);
  116738. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  116739. var k = _a[_i];
  116740. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  116741. return Math.max(k, 3);
  116742. }
  116743. }
  116744. return Math.max(v, 3);
  116745. };
  116746. /**
  116747. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  116748. * @param x The point on the Gaussian distribution to sample.
  116749. * @return the value of the Gaussian function at x.
  116750. */
  116751. BlurPostProcess.prototype._gaussianWeight = function (x) {
  116752. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  116753. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  116754. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  116755. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  116756. // truncated at around 1.3% of peak strength.
  116757. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  116758. var sigma = (1 / 3);
  116759. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  116760. var exponent = -((x * x) / (2.0 * sigma * sigma));
  116761. var weight = (1.0 / denominator) * Math.exp(exponent);
  116762. return weight;
  116763. };
  116764. /**
  116765. * Generates a string that can be used as a floating point number in GLSL.
  116766. * @param x Value to print.
  116767. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  116768. * @return GLSL float string.
  116769. */
  116770. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  116771. if (decimalFigures === void 0) { decimalFigures = 8; }
  116772. return x.toFixed(decimalFigures).replace(/0+$/, '');
  116773. };
  116774. return BlurPostProcess;
  116775. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116776. /***/ }),
  116777. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  116778. /*!*********************************************************!*\
  116779. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  116780. \*********************************************************/
  116781. /*! exports provided: ChromaticAberrationPostProcess */
  116782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116783. "use strict";
  116784. __webpack_require__.r(__webpack_exports__);
  116785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  116786. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116788. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116789. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116790. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  116791. /**
  116792. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  116793. */
  116794. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  116795. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  116796. /**
  116797. * Creates a new instance ChromaticAberrationPostProcess
  116798. * @param name The name of the effect.
  116799. * @param screenWidth The width of the screen to apply the effect on.
  116800. * @param screenHeight The height of the screen to apply the effect on.
  116801. * @param options The required width/height ratio to downsize to before computing the render pass.
  116802. * @param camera The camera to apply the render pass to.
  116803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116804. * @param engine The engine which the post process will be applied. (default: current engine)
  116805. * @param reusable If the post process can be reused on the same frame. (default: false)
  116806. * @param textureType Type of textures used when performing the post process. (default: 0)
  116807. * @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)
  116808. */
  116809. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116810. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116811. if (blockCompilation === void 0) { blockCompilation = false; }
  116812. 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;
  116813. /**
  116814. * The amount of seperation of rgb channels (default: 30)
  116815. */
  116816. _this.aberrationAmount = 30;
  116817. /**
  116818. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  116819. */
  116820. _this.radialIntensity = 0;
  116821. /**
  116822. * 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))
  116823. */
  116824. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  116825. /**
  116826. * 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))
  116827. */
  116828. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  116829. _this.onApplyObservable.add(function (effect) {
  116830. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  116831. effect.setFloat('screen_width', screenWidth);
  116832. effect.setFloat('screen_height', screenHeight);
  116833. effect.setFloat('radialIntensity', _this.radialIntensity);
  116834. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  116835. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  116836. });
  116837. return _this;
  116838. }
  116839. return ChromaticAberrationPostProcess;
  116840. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116841. /***/ }),
  116842. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  116843. /*!*******************************************************!*\
  116844. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  116845. \*******************************************************/
  116846. /*! exports provided: CircleOfConfusionPostProcess */
  116847. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116848. "use strict";
  116849. __webpack_require__.r(__webpack_exports__);
  116850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  116851. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116852. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116853. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116854. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116855. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  116856. /**
  116857. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  116858. */
  116859. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  116860. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  116861. /**
  116862. * Creates a new instance CircleOfConfusionPostProcess
  116863. * @param name The name of the effect.
  116864. * @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.
  116865. * @param options The required width/height ratio to downsize to before computing the render pass.
  116866. * @param camera The camera to apply the render pass to.
  116867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116868. * @param engine The engine which the post process will be applied. (default: current engine)
  116869. * @param reusable If the post process can be reused on the same frame. (default: false)
  116870. * @param textureType Type of textures used when performing the post process. (default: 0)
  116871. * @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)
  116872. */
  116873. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116874. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116875. if (blockCompilation === void 0) { blockCompilation = false; }
  116876. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116877. /**
  116878. * 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.
  116879. */
  116880. _this.lensSize = 50;
  116881. /**
  116882. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116883. */
  116884. _this.fStop = 1.4;
  116885. /**
  116886. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116887. */
  116888. _this.focusDistance = 2000;
  116889. /**
  116890. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  116891. */
  116892. _this.focalLength = 50;
  116893. _this._depthTexture = null;
  116894. _this._depthTexture = depthTexture;
  116895. _this.onApplyObservable.add(function (effect) {
  116896. if (!_this._depthTexture) {
  116897. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  116898. return;
  116899. }
  116900. effect.setTexture("depthSampler", _this._depthTexture);
  116901. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  116902. var aperture = _this.lensSize / _this.fStop;
  116903. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  116904. effect.setFloat('focusDistance', _this.focusDistance);
  116905. effect.setFloat('cocPrecalculation', cocPrecalculation);
  116906. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  116907. });
  116908. return _this;
  116909. }
  116910. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  116911. /**
  116912. * 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.
  116913. */
  116914. set: function (value) {
  116915. this._depthTexture = value;
  116916. },
  116917. enumerable: true,
  116918. configurable: true
  116919. });
  116920. return CircleOfConfusionPostProcess;
  116921. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116922. /***/ }),
  116923. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  116924. /*!*****************************************************!*\
  116925. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  116926. \*****************************************************/
  116927. /*! exports provided: ColorCorrectionPostProcess */
  116928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116929. "use strict";
  116930. __webpack_require__.r(__webpack_exports__);
  116931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  116932. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116933. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116934. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116935. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  116936. /**
  116937. *
  116938. * This post-process allows the modification of rendered colors by using
  116939. * a 'look-up table' (LUT). This effect is also called Color Grading.
  116940. *
  116941. * The object needs to be provided an url to a texture containing the color
  116942. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  116943. * Use an image editing software to tweak the LUT to match your needs.
  116944. *
  116945. * For an example of a color LUT, see here:
  116946. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  116947. * For explanations on color grading, see here:
  116948. * @see http://udn.epicgames.com/Three/ColorGrading.html
  116949. *
  116950. */
  116951. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  116952. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  116953. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  116954. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  116955. _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);
  116956. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  116957. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  116958. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  116959. _this.onApply = function (effect) {
  116960. effect.setTexture("colorTable", _this._colorTableTexture);
  116961. };
  116962. return _this;
  116963. }
  116964. return ColorCorrectionPostProcess;
  116965. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116966. /***/ }),
  116967. /***/ "./PostProcesses/convolutionPostProcess.ts":
  116968. /*!*************************************************!*\
  116969. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  116970. \*************************************************/
  116971. /*! exports provided: ConvolutionPostProcess */
  116972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116973. "use strict";
  116974. __webpack_require__.r(__webpack_exports__);
  116975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  116976. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116977. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116978. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116979. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  116980. /**
  116981. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  116982. * input texture to perform effects such as edge detection or sharpening
  116983. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  116984. */
  116985. var ConvolutionPostProcess = /** @class */ (function (_super) {
  116986. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  116987. /**
  116988. * Creates a new instance ConvolutionPostProcess
  116989. * @param name The name of the effect.
  116990. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  116991. * @param options The required width/height ratio to downsize to before computing the render pass.
  116992. * @param camera The camera to apply the render pass to.
  116993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116994. * @param engine The engine which the post process will be applied. (default: current engine)
  116995. * @param reusable If the post process can be reused on the same frame. (default: false)
  116996. * @param textureType Type of textures used when performing the post process. (default: 0)
  116997. */
  116998. function ConvolutionPostProcess(name,
  116999. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117000. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  117001. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117002. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117003. _this.kernel = kernel;
  117004. _this.onApply = function (effect) {
  117005. effect.setFloat2("screenSize", _this.width, _this.height);
  117006. effect.setArray("kernel", _this.kernel);
  117007. };
  117008. return _this;
  117009. }
  117010. // Statics
  117011. /**
  117012. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117013. */
  117014. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  117015. /**
  117016. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117017. */
  117018. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  117019. /**
  117020. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117021. */
  117022. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  117023. /**
  117024. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117025. */
  117026. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  117027. /**
  117028. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117029. */
  117030. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  117031. /**
  117032. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117033. */
  117034. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  117035. return ConvolutionPostProcess;
  117036. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117037. /***/ }),
  117038. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  117039. /*!******************************************************!*\
  117040. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  117041. \******************************************************/
  117042. /*! exports provided: DepthOfFieldBlurPostProcess */
  117043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117044. "use strict";
  117045. __webpack_require__.r(__webpack_exports__);
  117046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  117047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117048. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117049. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  117050. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117051. /**
  117052. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117053. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117054. * based on samples that have a large difference in distance than the center pixel.
  117055. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117056. */
  117057. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  117058. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  117059. /**
  117060. * Creates a new instance CircleOfConfusionPostProcess
  117061. * @param name The name of the effect.
  117062. * @param scene The scene the effect belongs to.
  117063. * @param direction The direction the blur should be applied.
  117064. * @param kernel The size of the kernel used to blur.
  117065. * @param options The required width/height ratio to downsize to before computing the render pass.
  117066. * @param camera The camera to apply the render pass to.
  117067. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117068. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117070. * @param engine The engine which the post process will be applied. (default: current engine)
  117071. * @param reusable If the post process can be reused on the same frame. (default: false)
  117072. * @param textureType Type of textures used when performing the post process. (default: 0)
  117073. * @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)
  117074. */
  117075. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  117076. if (imageToBlur === void 0) { imageToBlur = null; }
  117077. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  117078. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117079. if (blockCompilation === void 0) { blockCompilation = false; }
  117080. 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;
  117081. _this.direction = direction;
  117082. _this.onApplyObservable.add(function (effect) {
  117083. if (imageToBlur != null) {
  117084. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  117085. }
  117086. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  117087. if (scene.activeCamera) {
  117088. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  117089. }
  117090. });
  117091. return _this;
  117092. }
  117093. return DepthOfFieldBlurPostProcess;
  117094. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  117095. /***/ }),
  117096. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  117097. /*!*********************************************!*\
  117098. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  117099. \*********************************************/
  117100. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  117101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117102. "use strict";
  117103. __webpack_require__.r(__webpack_exports__);
  117104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  117105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  117106. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117107. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117108. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117109. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117110. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  117111. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  117112. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  117113. /**
  117114. * Specifies the level of max blur that should be applied when using the depth of field effect
  117115. */
  117116. var DepthOfFieldEffectBlurLevel;
  117117. (function (DepthOfFieldEffectBlurLevel) {
  117118. /**
  117119. * Subtle blur
  117120. */
  117121. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  117122. /**
  117123. * Medium blur
  117124. */
  117125. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  117126. /**
  117127. * Large blur
  117128. */
  117129. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  117130. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  117131. /**
  117132. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117133. */
  117134. var DepthOfFieldEffect = /** @class */ (function (_super) {
  117135. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  117136. /**
  117137. * Creates a new instance DepthOfFieldEffect
  117138. * @param scene The scene the effect belongs to.
  117139. * @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.
  117140. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117141. * @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)
  117142. */
  117143. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  117144. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  117145. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  117146. if (blockCompilation === void 0) { blockCompilation = false; }
  117147. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  117148. return _this._effects;
  117149. }, true) || this;
  117150. /**
  117151. * @hidden Internal post processes in depth of field effect
  117152. */
  117153. _this._effects = [];
  117154. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  117155. _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);
  117156. // 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)
  117157. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  117158. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117159. _this._depthOfFieldBlurY = [];
  117160. _this._depthOfFieldBlurX = [];
  117161. var blurCount = 1;
  117162. var kernelSize = 15;
  117163. switch (blurLevel) {
  117164. case DepthOfFieldEffectBlurLevel.High: {
  117165. blurCount = 3;
  117166. kernelSize = 51;
  117167. break;
  117168. }
  117169. case DepthOfFieldEffectBlurLevel.Medium: {
  117170. blurCount = 2;
  117171. kernelSize = 31;
  117172. break;
  117173. }
  117174. default: {
  117175. kernelSize = 15;
  117176. blurCount = 1;
  117177. break;
  117178. }
  117179. }
  117180. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  117181. var ratio = 1.0;
  117182. for (var i = 0; i < blurCount; i++) {
  117183. 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);
  117184. blurY.autoClear = false;
  117185. ratio = 0.75 / Math.pow(2, i);
  117186. 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);
  117187. blurX.autoClear = false;
  117188. _this._depthOfFieldBlurY.push(blurY);
  117189. _this._depthOfFieldBlurX.push(blurX);
  117190. }
  117191. // Set all post processes on the effect.
  117192. _this._effects = [_this._circleOfConfusion];
  117193. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  117194. _this._effects.push(_this._depthOfFieldBlurY[i]);
  117195. _this._effects.push(_this._depthOfFieldBlurX[i]);
  117196. }
  117197. // Merge blurred images with original image based on circleOfConfusion
  117198. _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);
  117199. _this._dofMerge.autoClear = false;
  117200. _this._effects.push(_this._dofMerge);
  117201. return _this;
  117202. }
  117203. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  117204. get: function () {
  117205. return this._circleOfConfusion.focalLength;
  117206. },
  117207. /**
  117208. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117209. */
  117210. set: function (value) {
  117211. this._circleOfConfusion.focalLength = value;
  117212. },
  117213. enumerable: true,
  117214. configurable: true
  117215. });
  117216. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  117217. get: function () {
  117218. return this._circleOfConfusion.fStop;
  117219. },
  117220. /**
  117221. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117222. */
  117223. set: function (value) {
  117224. this._circleOfConfusion.fStop = value;
  117225. },
  117226. enumerable: true,
  117227. configurable: true
  117228. });
  117229. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  117230. get: function () {
  117231. return this._circleOfConfusion.focusDistance;
  117232. },
  117233. /**
  117234. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117235. */
  117236. set: function (value) {
  117237. this._circleOfConfusion.focusDistance = value;
  117238. },
  117239. enumerable: true,
  117240. configurable: true
  117241. });
  117242. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  117243. get: function () {
  117244. return this._circleOfConfusion.lensSize;
  117245. },
  117246. /**
  117247. * 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.
  117248. */
  117249. set: function (value) {
  117250. this._circleOfConfusion.lensSize = value;
  117251. },
  117252. enumerable: true,
  117253. configurable: true
  117254. });
  117255. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  117256. /**
  117257. * 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.
  117258. */
  117259. set: function (value) {
  117260. this._circleOfConfusion.depthTexture = value;
  117261. },
  117262. enumerable: true,
  117263. configurable: true
  117264. });
  117265. /**
  117266. * Disposes each of the internal effects for a given camera.
  117267. * @param camera The camera to dispose the effect on.
  117268. */
  117269. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  117270. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117271. this._effects[effectIndex].dispose(camera);
  117272. }
  117273. };
  117274. /**
  117275. * @hidden Internal
  117276. */
  117277. DepthOfFieldEffect.prototype._updateEffects = function () {
  117278. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117279. this._effects[effectIndex].updateEffect();
  117280. }
  117281. };
  117282. /**
  117283. * Internal
  117284. * @returns if all the contained post processes are ready.
  117285. * @hidden
  117286. */
  117287. DepthOfFieldEffect.prototype._isReady = function () {
  117288. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117289. if (!this._effects[effectIndex].isReady()) {
  117290. return false;
  117291. }
  117292. }
  117293. return true;
  117294. };
  117295. return DepthOfFieldEffect;
  117296. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  117297. /***/ }),
  117298. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  117299. /*!*******************************************************!*\
  117300. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  117301. \*******************************************************/
  117302. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  117303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117304. "use strict";
  117305. __webpack_require__.r(__webpack_exports__);
  117306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  117307. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  117308. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117309. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117310. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117311. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  117312. /**
  117313. * Options to be set when merging outputs from the default pipeline.
  117314. */
  117315. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  117316. function DepthOfFieldMergePostProcessOptions() {
  117317. }
  117318. return DepthOfFieldMergePostProcessOptions;
  117319. }());
  117320. /**
  117321. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117322. */
  117323. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  117324. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  117325. /**
  117326. * Creates a new instance of DepthOfFieldMergePostProcess
  117327. * @param name The name of the effect.
  117328. * @param originalFromInput Post process which's input will be used for the merge.
  117329. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117330. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117331. * @param options The required width/height ratio to downsize to before computing the render pass.
  117332. * @param camera The camera to apply the render pass to.
  117333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117334. * @param engine The engine which the post process will be applied. (default: current engine)
  117335. * @param reusable If the post process can be reused on the same frame. (default: false)
  117336. * @param textureType Type of textures used when performing the post process. (default: 0)
  117337. * @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)
  117338. */
  117339. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117340. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117341. if (blockCompilation === void 0) { blockCompilation = false; }
  117342. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  117343. _this.blurSteps = blurSteps;
  117344. _this.onApplyObservable.add(function (effect) {
  117345. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  117346. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  117347. blurSteps.forEach(function (step, index) {
  117348. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  117349. });
  117350. });
  117351. if (!blockCompilation) {
  117352. _this.updateEffect();
  117353. }
  117354. return _this;
  117355. }
  117356. /**
  117357. * Updates the effect with the current post process compile time values and recompiles the shader.
  117358. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117359. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117360. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117361. * @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
  117362. * @param onCompiled Called when the shader has been compiled.
  117363. * @param onError Called if there is an error when compiling a shader.
  117364. */
  117365. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  117366. if (defines === void 0) { defines = null; }
  117367. if (uniforms === void 0) { uniforms = null; }
  117368. if (samplers === void 0) { samplers = null; }
  117369. if (!defines) {
  117370. defines = "";
  117371. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  117372. }
  117373. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  117374. };
  117375. return DepthOfFieldMergePostProcess;
  117376. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117377. /***/ }),
  117378. /***/ "./PostProcesses/displayPassPostProcess.ts":
  117379. /*!*************************************************!*\
  117380. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  117381. \*************************************************/
  117382. /*! exports provided: DisplayPassPostProcess */
  117383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117384. "use strict";
  117385. __webpack_require__.r(__webpack_exports__);
  117386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  117387. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117388. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117389. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  117390. /**
  117391. * DisplayPassPostProcess which produces an output the same as it's input
  117392. */
  117393. var DisplayPassPostProcess = /** @class */ (function (_super) {
  117394. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  117395. /**
  117396. * Creates the DisplayPassPostProcess
  117397. * @param name The name of the effect.
  117398. * @param options The required width/height ratio to downsize to before computing the render pass.
  117399. * @param camera The camera to apply the render pass to.
  117400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117401. * @param engine The engine which the post process will be applied. (default: current engine)
  117402. * @param reusable If the post process can be reused on the same frame. (default: false)
  117403. */
  117404. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  117405. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  117406. }
  117407. return DisplayPassPostProcess;
  117408. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117409. /***/ }),
  117410. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  117411. /*!*******************************************************!*\
  117412. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  117413. \*******************************************************/
  117414. /*! exports provided: ExtractHighlightsPostProcess */
  117415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117416. "use strict";
  117417. __webpack_require__.r(__webpack_exports__);
  117418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  117419. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117420. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117421. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117422. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117423. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  117424. /**
  117425. * 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.
  117426. */
  117427. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  117428. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  117429. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117430. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117431. if (blockCompilation === void 0) { blockCompilation = false; }
  117432. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117433. /**
  117434. * The luminance threshold, pixels below this value will be set to black.
  117435. */
  117436. _this.threshold = 0.9;
  117437. /** @hidden */
  117438. _this._exposure = 1;
  117439. /**
  117440. * Post process which has the input texture to be used when performing highlight extraction
  117441. * @hidden
  117442. */
  117443. _this._inputPostProcess = null;
  117444. _this.onApplyObservable.add(function (effect) {
  117445. if (_this._inputPostProcess) {
  117446. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  117447. }
  117448. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  117449. effect.setFloat('exposure', _this._exposure);
  117450. });
  117451. return _this;
  117452. }
  117453. return ExtractHighlightsPostProcess;
  117454. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117455. /***/ }),
  117456. /***/ "./PostProcesses/filterPostProcess.ts":
  117457. /*!********************************************!*\
  117458. !*** ./PostProcesses/filterPostProcess.ts ***!
  117459. \********************************************/
  117460. /*! exports provided: FilterPostProcess */
  117461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117462. "use strict";
  117463. __webpack_require__.r(__webpack_exports__);
  117464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  117465. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117466. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117467. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  117468. /**
  117469. * Applies a kernel filter to the image
  117470. */
  117471. var FilterPostProcess = /** @class */ (function (_super) {
  117472. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  117473. /**
  117474. *
  117475. * @param name The name of the effect.
  117476. * @param kernelMatrix The matrix to be applied to the image
  117477. * @param options The required width/height ratio to downsize to before computing the render pass.
  117478. * @param camera The camera to apply the render pass to.
  117479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117480. * @param engine The engine which the post process will be applied. (default: current engine)
  117481. * @param reusable If the post process can be reused on the same frame. (default: false)
  117482. */
  117483. function FilterPostProcess(name,
  117484. /** The matrix to be applied to the image */
  117485. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  117486. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  117487. _this.kernelMatrix = kernelMatrix;
  117488. _this.onApply = function (effect) {
  117489. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  117490. };
  117491. return _this;
  117492. }
  117493. return FilterPostProcess;
  117494. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117495. /***/ }),
  117496. /***/ "./PostProcesses/fxaaPostProcess.ts":
  117497. /*!******************************************!*\
  117498. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  117499. \******************************************/
  117500. /*! exports provided: FxaaPostProcess */
  117501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117502. "use strict";
  117503. __webpack_require__.r(__webpack_exports__);
  117504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  117505. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117506. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117507. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117508. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117509. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  117510. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  117511. /**
  117512. * Fxaa post process
  117513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117514. */
  117515. var FxaaPostProcess = /** @class */ (function (_super) {
  117516. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  117517. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117518. if (camera === void 0) { camera = null; }
  117519. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117520. 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;
  117521. var defines = _this._getDefines();
  117522. _this.updateEffect(defines);
  117523. _this.onApplyObservable.add(function (effect) {
  117524. var texelSize = _this.texelSize;
  117525. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  117526. });
  117527. return _this;
  117528. }
  117529. FxaaPostProcess.prototype._getDefines = function () {
  117530. var engine = this.getEngine();
  117531. if (!engine) {
  117532. return null;
  117533. }
  117534. var glInfo = engine.getGlInfo();
  117535. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  117536. return "#define MALI 1\n";
  117537. }
  117538. return null;
  117539. };
  117540. return FxaaPostProcess;
  117541. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117542. /***/ }),
  117543. /***/ "./PostProcesses/grainPostProcess.ts":
  117544. /*!*******************************************!*\
  117545. !*** ./PostProcesses/grainPostProcess.ts ***!
  117546. \*******************************************/
  117547. /*! exports provided: GrainPostProcess */
  117548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117549. "use strict";
  117550. __webpack_require__.r(__webpack_exports__);
  117551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  117552. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117553. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117554. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117555. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  117556. /**
  117557. * The GrainPostProcess adds noise to the image at mid luminance levels
  117558. */
  117559. var GrainPostProcess = /** @class */ (function (_super) {
  117560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  117561. /**
  117562. * Creates a new instance of @see GrainPostProcess
  117563. * @param name The name of the effect.
  117564. * @param options The required width/height ratio to downsize to before computing the render pass.
  117565. * @param camera The camera to apply the render pass to.
  117566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117567. * @param engine The engine which the post process will be applied. (default: current engine)
  117568. * @param reusable If the post process can be reused on the same frame. (default: false)
  117569. * @param textureType Type of textures used when performing the post process. (default: 0)
  117570. * @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)
  117571. */
  117572. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117573. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117574. if (blockCompilation === void 0) { blockCompilation = false; }
  117575. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117576. /**
  117577. * The intensity of the grain added (default: 30)
  117578. */
  117579. _this.intensity = 30;
  117580. /**
  117581. * If the grain should be randomized on every frame
  117582. */
  117583. _this.animated = false;
  117584. _this.onApplyObservable.add(function (effect) {
  117585. effect.setFloat('intensity', _this.intensity);
  117586. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  117587. });
  117588. return _this;
  117589. }
  117590. return GrainPostProcess;
  117591. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117592. /***/ }),
  117593. /***/ "./PostProcesses/highlightsPostProcess.ts":
  117594. /*!************************************************!*\
  117595. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  117596. \************************************************/
  117597. /*! exports provided: HighlightsPostProcess */
  117598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117599. "use strict";
  117600. __webpack_require__.r(__webpack_exports__);
  117601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  117602. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117603. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117604. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117605. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  117606. /**
  117607. * Extracts highlights from the image
  117608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117609. */
  117610. var HighlightsPostProcess = /** @class */ (function (_super) {
  117611. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  117612. /**
  117613. * Extracts highlights from the image
  117614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117615. * @param name The name of the effect.
  117616. * @param options The required width/height ratio to downsize to before computing the render pass.
  117617. * @param camera The camera to apply the render pass to.
  117618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117619. * @param engine The engine which the post process will be applied. (default: current engine)
  117620. * @param reusable If the post process can be reused on the same frame. (default: false)
  117621. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117622. */
  117623. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117624. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117625. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117626. }
  117627. return HighlightsPostProcess;
  117628. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117629. /***/ }),
  117630. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  117631. /*!*****************************************************!*\
  117632. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  117633. \*****************************************************/
  117634. /*! exports provided: ImageProcessingPostProcess */
  117635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117636. "use strict";
  117637. __webpack_require__.r(__webpack_exports__);
  117638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  117639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117640. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  117641. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  117642. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117643. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  117644. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117645. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  117646. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117647. /**
  117648. * ImageProcessingPostProcess
  117649. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  117650. */
  117651. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  117652. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  117653. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  117654. if (camera === void 0) { camera = null; }
  117655. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117656. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  117657. _this._fromLinearSpace = true;
  117658. /**
  117659. * Defines cache preventing GC.
  117660. */
  117661. _this._defines = {
  117662. IMAGEPROCESSING: false,
  117663. VIGNETTE: false,
  117664. VIGNETTEBLENDMODEMULTIPLY: false,
  117665. VIGNETTEBLENDMODEOPAQUE: false,
  117666. TONEMAPPING: false,
  117667. TONEMAPPING_ACES: false,
  117668. CONTRAST: false,
  117669. COLORCURVES: false,
  117670. COLORGRADING: false,
  117671. COLORGRADING3D: false,
  117672. FROMLINEARSPACE: false,
  117673. SAMPLER3DGREENDEPTH: false,
  117674. SAMPLER3DBGRMAP: false,
  117675. IMAGEPROCESSINGPOSTPROCESS: false,
  117676. EXPOSURE: false,
  117677. };
  117678. // Setup the configuration as forced by the constructor. This would then not force the
  117679. // scene materials output in linear space and let untouched the default forward pass.
  117680. if (imageProcessingConfiguration) {
  117681. imageProcessingConfiguration.applyByPostProcess = true;
  117682. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  117683. // This will cause the shader to be compiled
  117684. _this.fromLinearSpace = false;
  117685. }
  117686. // Setup the default processing configuration to the scene.
  117687. else {
  117688. _this._attachImageProcessingConfiguration(null, true);
  117689. _this.imageProcessingConfiguration.applyByPostProcess = true;
  117690. }
  117691. _this.onApply = function (effect) {
  117692. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  117693. };
  117694. return _this;
  117695. }
  117696. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  117697. /**
  117698. * Gets the image processing configuration used either in this material.
  117699. */
  117700. get: function () {
  117701. return this._imageProcessingConfiguration;
  117702. },
  117703. /**
  117704. * Sets the Default image processing configuration used either in the this material.
  117705. *
  117706. * If sets to null, the scene one is in use.
  117707. */
  117708. set: function (value) {
  117709. this._attachImageProcessingConfiguration(value);
  117710. },
  117711. enumerable: true,
  117712. configurable: true
  117713. });
  117714. /**
  117715. * Attaches a new image processing configuration to the PBR Material.
  117716. * @param configuration
  117717. */
  117718. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  117719. var _this = this;
  117720. if (doNotBuild === void 0) { doNotBuild = false; }
  117721. if (configuration === this._imageProcessingConfiguration) {
  117722. return;
  117723. }
  117724. // Detaches observer.
  117725. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  117726. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  117727. }
  117728. // Pick the scene configuration if needed.
  117729. if (!configuration) {
  117730. var scene = null;
  117731. var engine = this.getEngine();
  117732. var camera = this.getCamera();
  117733. if (camera) {
  117734. scene = camera.getScene();
  117735. }
  117736. else if (engine && engine.scenes) {
  117737. var scenes = engine.scenes;
  117738. scene = scenes[scenes.length - 1];
  117739. }
  117740. else {
  117741. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  117742. }
  117743. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  117744. }
  117745. else {
  117746. this._imageProcessingConfiguration = configuration;
  117747. }
  117748. // Attaches observer.
  117749. if (this._imageProcessingConfiguration) {
  117750. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  117751. _this._updateParameters();
  117752. });
  117753. }
  117754. // Ensure the effect will be rebuilt.
  117755. if (!doNotBuild) {
  117756. this._updateParameters();
  117757. }
  117758. };
  117759. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  117760. /**
  117761. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117762. */
  117763. get: function () {
  117764. return this.imageProcessingConfiguration.colorCurves;
  117765. },
  117766. /**
  117767. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117768. */
  117769. set: function (value) {
  117770. this.imageProcessingConfiguration.colorCurves = value;
  117771. },
  117772. enumerable: true,
  117773. configurable: true
  117774. });
  117775. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  117776. /**
  117777. * Gets wether the color curves effect is enabled.
  117778. */
  117779. get: function () {
  117780. return this.imageProcessingConfiguration.colorCurvesEnabled;
  117781. },
  117782. /**
  117783. * Sets wether the color curves effect is enabled.
  117784. */
  117785. set: function (value) {
  117786. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  117787. },
  117788. enumerable: true,
  117789. configurable: true
  117790. });
  117791. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  117792. /**
  117793. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117794. */
  117795. get: function () {
  117796. return this.imageProcessingConfiguration.colorGradingTexture;
  117797. },
  117798. /**
  117799. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117800. */
  117801. set: function (value) {
  117802. this.imageProcessingConfiguration.colorGradingTexture = value;
  117803. },
  117804. enumerable: true,
  117805. configurable: true
  117806. });
  117807. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  117808. /**
  117809. * Gets wether the color grading effect is enabled.
  117810. */
  117811. get: function () {
  117812. return this.imageProcessingConfiguration.colorGradingEnabled;
  117813. },
  117814. /**
  117815. * Gets wether the color grading effect is enabled.
  117816. */
  117817. set: function (value) {
  117818. this.imageProcessingConfiguration.colorGradingEnabled = value;
  117819. },
  117820. enumerable: true,
  117821. configurable: true
  117822. });
  117823. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  117824. /**
  117825. * Gets exposure used in the effect.
  117826. */
  117827. get: function () {
  117828. return this.imageProcessingConfiguration.exposure;
  117829. },
  117830. /**
  117831. * Sets exposure used in the effect.
  117832. */
  117833. set: function (value) {
  117834. this.imageProcessingConfiguration.exposure = value;
  117835. },
  117836. enumerable: true,
  117837. configurable: true
  117838. });
  117839. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  117840. /**
  117841. * Gets wether tonemapping is enabled or not.
  117842. */
  117843. get: function () {
  117844. return this._imageProcessingConfiguration.toneMappingEnabled;
  117845. },
  117846. /**
  117847. * Sets wether tonemapping is enabled or not
  117848. */
  117849. set: function (value) {
  117850. this._imageProcessingConfiguration.toneMappingEnabled = value;
  117851. },
  117852. enumerable: true,
  117853. configurable: true
  117854. });
  117855. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  117856. /**
  117857. * Gets contrast used in the effect.
  117858. */
  117859. get: function () {
  117860. return this.imageProcessingConfiguration.contrast;
  117861. },
  117862. /**
  117863. * Sets contrast used in the effect.
  117864. */
  117865. set: function (value) {
  117866. this.imageProcessingConfiguration.contrast = value;
  117867. },
  117868. enumerable: true,
  117869. configurable: true
  117870. });
  117871. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  117872. /**
  117873. * Gets Vignette stretch size.
  117874. */
  117875. get: function () {
  117876. return this.imageProcessingConfiguration.vignetteStretch;
  117877. },
  117878. /**
  117879. * Sets Vignette stretch size.
  117880. */
  117881. set: function (value) {
  117882. this.imageProcessingConfiguration.vignetteStretch = value;
  117883. },
  117884. enumerable: true,
  117885. configurable: true
  117886. });
  117887. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  117888. /**
  117889. * Gets Vignette centre X Offset.
  117890. */
  117891. get: function () {
  117892. return this.imageProcessingConfiguration.vignetteCentreX;
  117893. },
  117894. /**
  117895. * Sets Vignette centre X Offset.
  117896. */
  117897. set: function (value) {
  117898. this.imageProcessingConfiguration.vignetteCentreX = value;
  117899. },
  117900. enumerable: true,
  117901. configurable: true
  117902. });
  117903. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  117904. /**
  117905. * Gets Vignette centre Y Offset.
  117906. */
  117907. get: function () {
  117908. return this.imageProcessingConfiguration.vignetteCentreY;
  117909. },
  117910. /**
  117911. * Sets Vignette centre Y Offset.
  117912. */
  117913. set: function (value) {
  117914. this.imageProcessingConfiguration.vignetteCentreY = value;
  117915. },
  117916. enumerable: true,
  117917. configurable: true
  117918. });
  117919. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  117920. /**
  117921. * Gets Vignette weight or intensity of the vignette effect.
  117922. */
  117923. get: function () {
  117924. return this.imageProcessingConfiguration.vignetteWeight;
  117925. },
  117926. /**
  117927. * Sets Vignette weight or intensity of the vignette effect.
  117928. */
  117929. set: function (value) {
  117930. this.imageProcessingConfiguration.vignetteWeight = value;
  117931. },
  117932. enumerable: true,
  117933. configurable: true
  117934. });
  117935. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  117936. /**
  117937. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117938. * if vignetteEnabled is set to true.
  117939. */
  117940. get: function () {
  117941. return this.imageProcessingConfiguration.vignetteColor;
  117942. },
  117943. /**
  117944. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117945. * if vignetteEnabled is set to true.
  117946. */
  117947. set: function (value) {
  117948. this.imageProcessingConfiguration.vignetteColor = value;
  117949. },
  117950. enumerable: true,
  117951. configurable: true
  117952. });
  117953. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  117954. /**
  117955. * Gets Camera field of view used by the Vignette effect.
  117956. */
  117957. get: function () {
  117958. return this.imageProcessingConfiguration.vignetteCameraFov;
  117959. },
  117960. /**
  117961. * Sets Camera field of view used by the Vignette effect.
  117962. */
  117963. set: function (value) {
  117964. this.imageProcessingConfiguration.vignetteCameraFov = value;
  117965. },
  117966. enumerable: true,
  117967. configurable: true
  117968. });
  117969. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  117970. /**
  117971. * Gets the vignette blend mode allowing different kind of effect.
  117972. */
  117973. get: function () {
  117974. return this.imageProcessingConfiguration.vignetteBlendMode;
  117975. },
  117976. /**
  117977. * Sets the vignette blend mode allowing different kind of effect.
  117978. */
  117979. set: function (value) {
  117980. this.imageProcessingConfiguration.vignetteBlendMode = value;
  117981. },
  117982. enumerable: true,
  117983. configurable: true
  117984. });
  117985. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  117986. /**
  117987. * Gets wether the vignette effect is enabled.
  117988. */
  117989. get: function () {
  117990. return this.imageProcessingConfiguration.vignetteEnabled;
  117991. },
  117992. /**
  117993. * Sets wether the vignette effect is enabled.
  117994. */
  117995. set: function (value) {
  117996. this.imageProcessingConfiguration.vignetteEnabled = value;
  117997. },
  117998. enumerable: true,
  117999. configurable: true
  118000. });
  118001. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  118002. /**
  118003. * Gets wether the input of the processing is in Gamma or Linear Space.
  118004. */
  118005. get: function () {
  118006. return this._fromLinearSpace;
  118007. },
  118008. /**
  118009. * Sets wether the input of the processing is in Gamma or Linear Space.
  118010. */
  118011. set: function (value) {
  118012. if (this._fromLinearSpace === value) {
  118013. return;
  118014. }
  118015. this._fromLinearSpace = value;
  118016. this._updateParameters();
  118017. },
  118018. enumerable: true,
  118019. configurable: true
  118020. });
  118021. /**
  118022. * "ImageProcessingPostProcess"
  118023. * @returns "ImageProcessingPostProcess"
  118024. */
  118025. ImageProcessingPostProcess.prototype.getClassName = function () {
  118026. return "ImageProcessingPostProcess";
  118027. };
  118028. ImageProcessingPostProcess.prototype._updateParameters = function () {
  118029. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  118030. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  118031. var defines = "";
  118032. for (var define in this._defines) {
  118033. if (this._defines[define]) {
  118034. defines += "#define " + define + ";\r\n";
  118035. }
  118036. }
  118037. var samplers = ["textureSampler"];
  118038. var uniforms = ["scale"];
  118039. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  118040. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  118041. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  118042. }
  118043. this.updateEffect(defines, uniforms, samplers);
  118044. };
  118045. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  118046. _super.prototype.dispose.call(this, camera);
  118047. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  118048. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  118049. }
  118050. if (this._imageProcessingConfiguration) {
  118051. this.imageProcessingConfiguration.applyByPostProcess = false;
  118052. }
  118053. };
  118054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118056. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  118057. return ImageProcessingPostProcess;
  118058. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118059. /***/ }),
  118060. /***/ "./PostProcesses/index.ts":
  118061. /*!********************************!*\
  118062. !*** ./PostProcesses/index.ts ***!
  118063. \********************************/
  118064. /*! 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 */
  118065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118066. "use strict";
  118067. __webpack_require__.r(__webpack_exports__);
  118068. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  118069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  118070. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  118071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  118072. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  118073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  118074. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  118075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  118076. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  118078. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  118079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  118080. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  118081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  118082. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  118083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  118084. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  118085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  118086. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  118087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  118088. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  118089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  118090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  118091. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  118092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  118093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  118094. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  118095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  118096. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  118097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  118098. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  118099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  118100. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  118101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  118102. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  118103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  118104. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  118105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  118106. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  118107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  118108. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  118109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  118110. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  118111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  118112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  118113. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  118115. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  118116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  118117. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  118118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  118119. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  118120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  118121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  118122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  118123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  118124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  118125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  118126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  118127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  118128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  118129. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  118130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  118131. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  118132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  118133. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  118134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  118135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  118136. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  118137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  118138. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  118139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  118140. /***/ }),
  118141. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  118142. /*!************************************************!*\
  118143. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  118144. \************************************************/
  118145. /*! exports provided: MotionBlurPostProcess */
  118146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118147. "use strict";
  118148. __webpack_require__.r(__webpack_exports__);
  118149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  118150. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118151. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118152. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118153. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118154. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118155. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  118156. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  118157. /**
  118158. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118159. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118160. * As an example, all you have to do is to create the post-process:
  118161. * var mb = new BABYLON.MotionBlurPostProcess(
  118162. * 'mb', // The name of the effect.
  118163. * scene, // The scene containing the objects to blur according to their velocity.
  118164. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118165. * camera // The camera to apply the render pass to.
  118166. * );
  118167. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118168. */
  118169. var MotionBlurPostProcess = /** @class */ (function (_super) {
  118170. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  118171. /**
  118172. * Creates a new instance MotionBlurPostProcess
  118173. * @param name The name of the effect.
  118174. * @param scene The scene containing the objects to blur according to their velocity.
  118175. * @param options The required width/height ratio to downsize to before computing the render pass.
  118176. * @param camera The camera to apply the render pass to.
  118177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118178. * @param engine The engine which the post process will be applied. (default: current engine)
  118179. * @param reusable If the post process can be reused on the same frame. (default: false)
  118180. * @param textureType Type of textures used when performing the post process. (default: 0)
  118181. * @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)
  118182. */
  118183. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118184. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118185. if (blockCompilation === void 0) { blockCompilation = false; }
  118186. 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;
  118187. /**
  118188. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118189. */
  118190. _this.motionStrength = 1;
  118191. _this._motionBlurSamples = 32;
  118192. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  118193. if (!_this._geometryBufferRenderer) {
  118194. // Geometry buffer renderer is not supported. So, work as a passthrough.
  118195. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  118196. _this.updateEffect();
  118197. }
  118198. else {
  118199. // Geometry buffer renderer is supported.
  118200. _this._geometryBufferRenderer.enableVelocity = true;
  118201. _this.onApply = function (effect) {
  118202. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  118203. effect.setFloat("motionScale", scene.getAnimationRatio());
  118204. effect.setFloat("motionStrength", _this.motionStrength);
  118205. if (_this._geometryBufferRenderer) {
  118206. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  118207. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  118208. }
  118209. };
  118210. }
  118211. return _this;
  118212. }
  118213. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  118214. /**
  118215. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118216. */
  118217. get: function () {
  118218. return this._motionBlurSamples;
  118219. },
  118220. /**
  118221. * Sets the number of iterations to be used for motion blur quality
  118222. */
  118223. set: function (samples) {
  118224. this._motionBlurSamples = samples;
  118225. if (this._geometryBufferRenderer) {
  118226. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  118227. }
  118228. },
  118229. enumerable: true,
  118230. configurable: true
  118231. });
  118232. /**
  118233. * Disposes the post process.
  118234. * @param camera The camera to dispose the post process on.
  118235. */
  118236. MotionBlurPostProcess.prototype.dispose = function (camera) {
  118237. if (this._geometryBufferRenderer) {
  118238. // Clear previous transformation matrices dictionary used to compute objects velocities
  118239. this._geometryBufferRenderer._previousTransformationMatrices = {};
  118240. }
  118241. _super.prototype.dispose.call(this, camera);
  118242. };
  118243. return MotionBlurPostProcess;
  118244. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118245. /***/ }),
  118246. /***/ "./PostProcesses/passPostProcess.ts":
  118247. /*!******************************************!*\
  118248. !*** ./PostProcesses/passPostProcess.ts ***!
  118249. \******************************************/
  118250. /*! exports provided: PassPostProcess, PassCubePostProcess */
  118251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118252. "use strict";
  118253. __webpack_require__.r(__webpack_exports__);
  118254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  118255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  118256. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118257. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118258. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118259. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  118260. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  118261. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  118262. /**
  118263. * PassPostProcess which produces an output the same as it's input
  118264. */
  118265. var PassPostProcess = /** @class */ (function (_super) {
  118266. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  118267. /**
  118268. * Creates the PassPostProcess
  118269. * @param name The name of the effect.
  118270. * @param options The required width/height ratio to downsize to before computing the render pass.
  118271. * @param camera The camera to apply the render pass to.
  118272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118273. * @param engine The engine which the post process will be applied. (default: current engine)
  118274. * @param reusable If the post process can be reused on the same frame. (default: false)
  118275. * @param textureType The type of texture to be used when performing the post processing.
  118276. * @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)
  118277. */
  118278. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118279. if (camera === void 0) { camera = null; }
  118280. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118281. if (blockCompilation === void 0) { blockCompilation = false; }
  118282. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  118283. }
  118284. return PassPostProcess;
  118285. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118286. /**
  118287. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118288. */
  118289. var PassCubePostProcess = /** @class */ (function (_super) {
  118290. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  118291. /**
  118292. * Creates the PassCubePostProcess
  118293. * @param name The name of the effect.
  118294. * @param options The required width/height ratio to downsize to before computing the render pass.
  118295. * @param camera The camera to apply the render pass to.
  118296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118297. * @param engine The engine which the post process will be applied. (default: current engine)
  118298. * @param reusable If the post process can be reused on the same frame. (default: false)
  118299. * @param textureType The type of texture to be used when performing the post processing.
  118300. * @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)
  118301. */
  118302. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118303. if (camera === void 0) { camera = null; }
  118304. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118305. if (blockCompilation === void 0) { blockCompilation = false; }
  118306. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  118307. _this._face = 0;
  118308. return _this;
  118309. }
  118310. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  118311. /**
  118312. * Gets or sets the cube face to display.
  118313. * * 0 is +X
  118314. * * 1 is -X
  118315. * * 2 is +Y
  118316. * * 3 is -Y
  118317. * * 4 is +Z
  118318. * * 5 is -Z
  118319. */
  118320. get: function () {
  118321. return this._face;
  118322. },
  118323. set: function (value) {
  118324. if (value < 0 || value > 5) {
  118325. return;
  118326. }
  118327. this._face = value;
  118328. switch (this._face) {
  118329. case 0:
  118330. this.updateEffect("#define POSITIVEX");
  118331. break;
  118332. case 1:
  118333. this.updateEffect("#define NEGATIVEX");
  118334. break;
  118335. case 2:
  118336. this.updateEffect("#define POSITIVEY");
  118337. break;
  118338. case 3:
  118339. this.updateEffect("#define NEGATIVEY");
  118340. break;
  118341. case 4:
  118342. this.updateEffect("#define POSITIVEZ");
  118343. break;
  118344. case 5:
  118345. this.updateEffect("#define NEGATIVEZ");
  118346. break;
  118347. }
  118348. },
  118349. enumerable: true,
  118350. configurable: true
  118351. });
  118352. return PassCubePostProcess;
  118353. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118354. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  118355. 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);
  118356. };
  118357. /***/ }),
  118358. /***/ "./PostProcesses/postProcess.ts":
  118359. /*!**************************************!*\
  118360. !*** ./PostProcesses/postProcess.ts ***!
  118361. \**************************************/
  118362. /*! exports provided: PostProcess */
  118363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118364. "use strict";
  118365. __webpack_require__.r(__webpack_exports__);
  118366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  118367. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  118368. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  118369. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  118370. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118371. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118372. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  118373. /**
  118374. * PostProcess can be used to apply a shader to a texture after it has been rendered
  118375. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118376. */
  118377. var PostProcess = /** @class */ (function () {
  118378. /**
  118379. * Creates a new instance PostProcess
  118380. * @param name The name of the PostProcess.
  118381. * @param fragmentUrl The url of the fragment shader to be used.
  118382. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  118383. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  118384. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  118385. * @param camera The camera to apply the render pass to.
  118386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118387. * @param engine The engine which the post process will be applied. (default: current engine)
  118388. * @param reusable If the post process can be reused on the same frame. (default: false)
  118389. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  118390. * @param textureType Type of textures used when performing the post process. (default: 0)
  118391. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  118392. * @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
  118393. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  118394. */
  118395. function PostProcess(
  118396. /** Name of the PostProcess. */
  118397. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  118398. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  118399. if (defines === void 0) { defines = null; }
  118400. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118401. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  118402. if (blockCompilation === void 0) { blockCompilation = false; }
  118403. this.name = name;
  118404. /**
  118405. * Width of the texture to apply the post process on
  118406. */
  118407. this.width = -1;
  118408. /**
  118409. * Height of the texture to apply the post process on
  118410. */
  118411. this.height = -1;
  118412. /**
  118413. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  118414. * @hidden
  118415. */
  118416. this._outputTexture = null;
  118417. /**
  118418. * If the buffer needs to be cleared before applying the post process. (default: true)
  118419. * Should be set to false if shader will overwrite all previous pixels.
  118420. */
  118421. this.autoClear = true;
  118422. /**
  118423. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  118424. */
  118425. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  118426. /**
  118427. * Animations to be used for the post processing
  118428. */
  118429. this.animations = new Array();
  118430. /**
  118431. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  118432. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  118433. */
  118434. this.enablePixelPerfectMode = false;
  118435. /**
  118436. * Force the postprocess to be applied without taking in account viewport
  118437. */
  118438. this.forceFullscreenViewport = true;
  118439. /**
  118440. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  118441. *
  118442. * | Value | Type | Description |
  118443. * | ----- | ----------------------------------- | ----------- |
  118444. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  118445. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  118446. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  118447. *
  118448. */
  118449. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  118450. /**
  118451. * Force textures to be a power of two (default: false)
  118452. */
  118453. this.alwaysForcePOT = false;
  118454. this._samples = 1;
  118455. /**
  118456. * Modify the scale of the post process to be the same as the viewport (default: false)
  118457. */
  118458. this.adaptScaleToCurrentViewport = false;
  118459. this._reusable = false;
  118460. /**
  118461. * Smart array of input and output textures for the post process.
  118462. * @hidden
  118463. */
  118464. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118465. /**
  118466. * The index in _textures that corresponds to the output texture.
  118467. * @hidden
  118468. */
  118469. this._currentRenderTextureInd = 0;
  118470. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  118471. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  118472. // Events
  118473. /**
  118474. * An event triggered when the postprocess is activated.
  118475. */
  118476. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118477. /**
  118478. * An event triggered when the postprocess changes its size.
  118479. */
  118480. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118481. /**
  118482. * An event triggered when the postprocess applies its effect.
  118483. */
  118484. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118485. /**
  118486. * An event triggered before rendering the postprocess
  118487. */
  118488. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118489. /**
  118490. * An event triggered after rendering the postprocess
  118491. */
  118492. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118493. if (camera != null) {
  118494. this._camera = camera;
  118495. this._scene = camera.getScene();
  118496. camera.attachPostProcess(this);
  118497. this._engine = this._scene.getEngine();
  118498. this._scene.postProcesses.push(this);
  118499. }
  118500. else if (engine) {
  118501. this._engine = engine;
  118502. this._engine.postProcesses.push(this);
  118503. }
  118504. this._options = options;
  118505. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  118506. this._reusable = reusable || false;
  118507. this._textureType = textureType;
  118508. this._samplers = samplers || [];
  118509. this._samplers.push("textureSampler");
  118510. this._fragmentUrl = fragmentUrl;
  118511. this._vertexUrl = vertexUrl;
  118512. this._parameters = parameters || [];
  118513. this._parameters.push("scale");
  118514. this._indexParameters = indexParameters;
  118515. if (!blockCompilation) {
  118516. this.updateEffect(defines);
  118517. }
  118518. }
  118519. Object.defineProperty(PostProcess.prototype, "samples", {
  118520. /**
  118521. * Number of sample textures (default: 1)
  118522. */
  118523. get: function () {
  118524. return this._samples;
  118525. },
  118526. set: function (n) {
  118527. var _this = this;
  118528. this._samples = n;
  118529. this._textures.forEach(function (texture) {
  118530. if (texture.samples !== _this._samples) {
  118531. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  118532. }
  118533. });
  118534. },
  118535. enumerable: true,
  118536. configurable: true
  118537. });
  118538. /**
  118539. * Returns the fragment url or shader name used in the post process.
  118540. * @returns the fragment url or name in the shader store.
  118541. */
  118542. PostProcess.prototype.getEffectName = function () {
  118543. return this._fragmentUrl;
  118544. };
  118545. Object.defineProperty(PostProcess.prototype, "onActivate", {
  118546. /**
  118547. * A function that is added to the onActivateObservable
  118548. */
  118549. set: function (callback) {
  118550. if (this._onActivateObserver) {
  118551. this.onActivateObservable.remove(this._onActivateObserver);
  118552. }
  118553. if (callback) {
  118554. this._onActivateObserver = this.onActivateObservable.add(callback);
  118555. }
  118556. },
  118557. enumerable: true,
  118558. configurable: true
  118559. });
  118560. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  118561. /**
  118562. * A function that is added to the onSizeChangedObservable
  118563. */
  118564. set: function (callback) {
  118565. if (this._onSizeChangedObserver) {
  118566. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  118567. }
  118568. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  118569. },
  118570. enumerable: true,
  118571. configurable: true
  118572. });
  118573. Object.defineProperty(PostProcess.prototype, "onApply", {
  118574. /**
  118575. * A function that is added to the onApplyObservable
  118576. */
  118577. set: function (callback) {
  118578. if (this._onApplyObserver) {
  118579. this.onApplyObservable.remove(this._onApplyObserver);
  118580. }
  118581. this._onApplyObserver = this.onApplyObservable.add(callback);
  118582. },
  118583. enumerable: true,
  118584. configurable: true
  118585. });
  118586. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  118587. /**
  118588. * A function that is added to the onBeforeRenderObservable
  118589. */
  118590. set: function (callback) {
  118591. if (this._onBeforeRenderObserver) {
  118592. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  118593. }
  118594. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  118595. },
  118596. enumerable: true,
  118597. configurable: true
  118598. });
  118599. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  118600. /**
  118601. * A function that is added to the onAfterRenderObservable
  118602. */
  118603. set: function (callback) {
  118604. if (this._onAfterRenderObserver) {
  118605. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  118606. }
  118607. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  118608. },
  118609. enumerable: true,
  118610. configurable: true
  118611. });
  118612. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  118613. /**
  118614. * 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
  118615. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  118616. */
  118617. get: function () {
  118618. return this._textures.data[this._currentRenderTextureInd];
  118619. },
  118620. set: function (value) {
  118621. this._forcedOutputTexture = value;
  118622. },
  118623. enumerable: true,
  118624. configurable: true
  118625. });
  118626. /**
  118627. * Gets the camera which post process is applied to.
  118628. * @returns The camera the post process is applied to.
  118629. */
  118630. PostProcess.prototype.getCamera = function () {
  118631. return this._camera;
  118632. };
  118633. Object.defineProperty(PostProcess.prototype, "texelSize", {
  118634. /**
  118635. * Gets the texel size of the postprocess.
  118636. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  118637. */
  118638. get: function () {
  118639. if (this._shareOutputWithPostProcess) {
  118640. return this._shareOutputWithPostProcess.texelSize;
  118641. }
  118642. if (this._forcedOutputTexture) {
  118643. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  118644. }
  118645. return this._texelSize;
  118646. },
  118647. enumerable: true,
  118648. configurable: true
  118649. });
  118650. /**
  118651. * Gets the engine which this post process belongs to.
  118652. * @returns The engine the post process was enabled with.
  118653. */
  118654. PostProcess.prototype.getEngine = function () {
  118655. return this._engine;
  118656. };
  118657. /**
  118658. * The effect that is created when initializing the post process.
  118659. * @returns The created effect corrisponding the the postprocess.
  118660. */
  118661. PostProcess.prototype.getEffect = function () {
  118662. return this._effect;
  118663. };
  118664. /**
  118665. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  118666. * @param postProcess The post process to share the output with.
  118667. * @returns This post process.
  118668. */
  118669. PostProcess.prototype.shareOutputWith = function (postProcess) {
  118670. this._disposeTextures();
  118671. this._shareOutputWithPostProcess = postProcess;
  118672. return this;
  118673. };
  118674. /**
  118675. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  118676. * This should be called if the post process that shares output with this post process is disabled/disposed.
  118677. */
  118678. PostProcess.prototype.useOwnOutput = function () {
  118679. if (this._textures.length == 0) {
  118680. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118681. }
  118682. this._shareOutputWithPostProcess = null;
  118683. };
  118684. /**
  118685. * Updates the effect with the current post process compile time values and recompiles the shader.
  118686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118689. * @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
  118690. * @param onCompiled Called when the shader has been compiled.
  118691. * @param onError Called if there is an error when compiling a shader.
  118692. */
  118693. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  118694. if (defines === void 0) { defines = null; }
  118695. if (uniforms === void 0) { uniforms = null; }
  118696. if (samplers === void 0) { samplers = null; }
  118697. 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);
  118698. };
  118699. /**
  118700. * The post process is reusable if it can be used multiple times within one frame.
  118701. * @returns If the post process is reusable
  118702. */
  118703. PostProcess.prototype.isReusable = function () {
  118704. return this._reusable;
  118705. };
  118706. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  118707. PostProcess.prototype.markTextureDirty = function () {
  118708. this.width = -1;
  118709. };
  118710. /**
  118711. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  118712. * 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.
  118713. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  118714. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  118715. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  118716. * @returns The target texture that was bound to be written to.
  118717. */
  118718. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  118719. var _this = this;
  118720. if (sourceTexture === void 0) { sourceTexture = null; }
  118721. camera = camera || this._camera;
  118722. var scene = camera.getScene();
  118723. var engine = scene.getEngine();
  118724. var maxSize = engine.getCaps().maxTextureSize;
  118725. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  118726. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  118727. // 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
  118728. var webVRCamera = camera.parent;
  118729. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  118730. requiredWidth /= 2;
  118731. }
  118732. var desiredWidth = (this._options.width || requiredWidth);
  118733. var desiredHeight = this._options.height || requiredHeight;
  118734. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  118735. if (this.adaptScaleToCurrentViewport) {
  118736. var currentViewport = engine.currentViewport;
  118737. if (currentViewport) {
  118738. desiredWidth *= currentViewport.width;
  118739. desiredHeight *= currentViewport.height;
  118740. }
  118741. }
  118742. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  118743. if (!this._options.width) {
  118744. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  118745. }
  118746. if (!this._options.height) {
  118747. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  118748. }
  118749. }
  118750. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  118751. if (this._textures.length > 0) {
  118752. for (var i = 0; i < this._textures.length; i++) {
  118753. this._engine._releaseTexture(this._textures.data[i]);
  118754. }
  118755. this._textures.reset();
  118756. }
  118757. this.width = desiredWidth;
  118758. this.height = desiredHeight;
  118759. var textureSize = { width: this.width, height: this.height };
  118760. var textureOptions = {
  118761. generateMipMaps: false,
  118762. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  118763. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  118764. samplingMode: this.renderTargetSamplingMode,
  118765. type: this._textureType
  118766. };
  118767. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118768. if (this._reusable) {
  118769. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118770. }
  118771. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  118772. this.onSizeChangedObservable.notifyObservers(this);
  118773. }
  118774. this._textures.forEach(function (texture) {
  118775. if (texture.samples !== _this.samples) {
  118776. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  118777. }
  118778. });
  118779. }
  118780. var target;
  118781. if (this._shareOutputWithPostProcess) {
  118782. target = this._shareOutputWithPostProcess.inputTexture;
  118783. }
  118784. else if (this._forcedOutputTexture) {
  118785. target = this._forcedOutputTexture;
  118786. this.width = this._forcedOutputTexture.width;
  118787. this.height = this._forcedOutputTexture.height;
  118788. }
  118789. else {
  118790. target = this.inputTexture;
  118791. }
  118792. // Bind the input of this post process to be used as the output of the previous post process.
  118793. if (this.enablePixelPerfectMode) {
  118794. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  118795. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  118796. }
  118797. else {
  118798. this._scaleRatio.copyFromFloats(1, 1);
  118799. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  118800. }
  118801. this.onActivateObservable.notifyObservers(camera);
  118802. // Clear
  118803. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  118804. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  118805. }
  118806. if (this._reusable) {
  118807. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  118808. }
  118809. return target;
  118810. };
  118811. Object.defineProperty(PostProcess.prototype, "isSupported", {
  118812. /**
  118813. * If the post process is supported.
  118814. */
  118815. get: function () {
  118816. return this._effect.isSupported;
  118817. },
  118818. enumerable: true,
  118819. configurable: true
  118820. });
  118821. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  118822. /**
  118823. * The aspect ratio of the output texture.
  118824. */
  118825. get: function () {
  118826. if (this._shareOutputWithPostProcess) {
  118827. return this._shareOutputWithPostProcess.aspectRatio;
  118828. }
  118829. if (this._forcedOutputTexture) {
  118830. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  118831. }
  118832. return this.width / this.height;
  118833. },
  118834. enumerable: true,
  118835. configurable: true
  118836. });
  118837. /**
  118838. * Get a value indicating if the post-process is ready to be used
  118839. * @returns true if the post-process is ready (shader is compiled)
  118840. */
  118841. PostProcess.prototype.isReady = function () {
  118842. return this._effect && this._effect.isReady();
  118843. };
  118844. /**
  118845. * Binds all textures and uniforms to the shader, this will be run on every pass.
  118846. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  118847. */
  118848. PostProcess.prototype.apply = function () {
  118849. // Check
  118850. if (!this._effect || !this._effect.isReady()) {
  118851. return null;
  118852. }
  118853. // States
  118854. this._engine.enableEffect(this._effect);
  118855. this._engine.setState(false);
  118856. this._engine.setDepthBuffer(false);
  118857. this._engine.setDepthWrite(false);
  118858. // Alpha
  118859. this._engine.setAlphaMode(this.alphaMode);
  118860. if (this.alphaConstants) {
  118861. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  118862. }
  118863. // Bind the output texture of the preivous post process as the input to this post process.
  118864. var source;
  118865. if (this._shareOutputWithPostProcess) {
  118866. source = this._shareOutputWithPostProcess.inputTexture;
  118867. }
  118868. else if (this._forcedOutputTexture) {
  118869. source = this._forcedOutputTexture;
  118870. }
  118871. else {
  118872. source = this.inputTexture;
  118873. }
  118874. this._effect._bindTexture("textureSampler", source);
  118875. // Parameters
  118876. this._effect.setVector2("scale", this._scaleRatio);
  118877. this.onApplyObservable.notifyObservers(this._effect);
  118878. return this._effect;
  118879. };
  118880. PostProcess.prototype._disposeTextures = function () {
  118881. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  118882. return;
  118883. }
  118884. if (this._textures.length > 0) {
  118885. for (var i = 0; i < this._textures.length; i++) {
  118886. this._engine._releaseTexture(this._textures.data[i]);
  118887. }
  118888. }
  118889. this._textures.dispose();
  118890. };
  118891. /**
  118892. * Disposes the post process.
  118893. * @param camera The camera to dispose the post process on.
  118894. */
  118895. PostProcess.prototype.dispose = function (camera) {
  118896. camera = camera || this._camera;
  118897. this._disposeTextures();
  118898. if (this._scene) {
  118899. var index_1 = this._scene.postProcesses.indexOf(this);
  118900. if (index_1 !== -1) {
  118901. this._scene.postProcesses.splice(index_1, 1);
  118902. }
  118903. }
  118904. else {
  118905. var index_2 = this._engine.postProcesses.indexOf(this);
  118906. if (index_2 !== -1) {
  118907. this._engine.postProcesses.splice(index_2, 1);
  118908. }
  118909. }
  118910. if (!camera) {
  118911. return;
  118912. }
  118913. camera.detachPostProcess(this);
  118914. var index = camera._postProcesses.indexOf(this);
  118915. if (index === 0 && camera._postProcesses.length > 0) {
  118916. var firstPostProcess = this._camera._getFirstPostProcess();
  118917. if (firstPostProcess) {
  118918. firstPostProcess.markTextureDirty();
  118919. }
  118920. }
  118921. this.onActivateObservable.clear();
  118922. this.onAfterRenderObservable.clear();
  118923. this.onApplyObservable.clear();
  118924. this.onBeforeRenderObservable.clear();
  118925. this.onSizeChangedObservable.clear();
  118926. };
  118927. return PostProcess;
  118928. }());
  118929. /***/ }),
  118930. /***/ "./PostProcesses/postProcessManager.ts":
  118931. /*!*********************************************!*\
  118932. !*** ./PostProcesses/postProcessManager.ts ***!
  118933. \*********************************************/
  118934. /*! exports provided: PostProcessManager */
  118935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118936. "use strict";
  118937. __webpack_require__.r(__webpack_exports__);
  118938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  118939. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118940. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118941. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118942. /**
  118943. * PostProcessManager is used to manage one or more post processes or post process pipelines
  118944. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118945. */
  118946. var PostProcessManager = /** @class */ (function () {
  118947. /**
  118948. * Creates a new instance PostProcess
  118949. * @param scene The scene that the post process is associated with.
  118950. */
  118951. function PostProcessManager(scene) {
  118952. this._vertexBuffers = {};
  118953. this._scene = scene;
  118954. }
  118955. PostProcessManager.prototype._prepareBuffers = function () {
  118956. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  118957. return;
  118958. }
  118959. // VBO
  118960. var vertices = [];
  118961. vertices.push(1, 1);
  118962. vertices.push(-1, 1);
  118963. vertices.push(-1, -1);
  118964. vertices.push(1, -1);
  118965. 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);
  118966. this._buildIndexBuffer();
  118967. };
  118968. PostProcessManager.prototype._buildIndexBuffer = function () {
  118969. // Indices
  118970. var indices = [];
  118971. indices.push(0);
  118972. indices.push(1);
  118973. indices.push(2);
  118974. indices.push(0);
  118975. indices.push(2);
  118976. indices.push(3);
  118977. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  118978. };
  118979. /**
  118980. * Rebuilds the vertex buffers of the manager.
  118981. * @hidden
  118982. */
  118983. PostProcessManager.prototype._rebuild = function () {
  118984. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  118985. if (!vb) {
  118986. return;
  118987. }
  118988. vb._rebuild();
  118989. this._buildIndexBuffer();
  118990. };
  118991. // Methods
  118992. /**
  118993. * Prepares a frame to be run through a post process.
  118994. * @param sourceTexture The input texture to the post procesess. (default: null)
  118995. * @param postProcesses An array of post processes to be run. (default: null)
  118996. * @returns True if the post processes were able to be run.
  118997. * @hidden
  118998. */
  118999. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  119000. if (sourceTexture === void 0) { sourceTexture = null; }
  119001. if (postProcesses === void 0) { postProcesses = null; }
  119002. var camera = this._scene.activeCamera;
  119003. if (!camera) {
  119004. return false;
  119005. }
  119006. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  119007. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  119008. return false;
  119009. }
  119010. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  119011. return true;
  119012. };
  119013. /**
  119014. * Manually render a set of post processes to a texture.
  119015. * @param postProcesses An array of post processes to be run.
  119016. * @param targetTexture The target texture to render to.
  119017. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119018. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119019. * @param lodLevel defines which lod of the texture to render to
  119020. */
  119021. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  119022. if (targetTexture === void 0) { targetTexture = null; }
  119023. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  119024. if (faceIndex === void 0) { faceIndex = 0; }
  119025. if (lodLevel === void 0) { lodLevel = 0; }
  119026. var engine = this._scene.getEngine();
  119027. for (var index = 0; index < postProcesses.length; index++) {
  119028. if (index < postProcesses.length - 1) {
  119029. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  119030. }
  119031. else {
  119032. if (targetTexture) {
  119033. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  119034. }
  119035. else {
  119036. engine.restoreDefaultFramebuffer();
  119037. }
  119038. }
  119039. var pp = postProcesses[index];
  119040. var effect = pp.apply();
  119041. if (effect) {
  119042. pp.onBeforeRenderObservable.notifyObservers(effect);
  119043. // VBOs
  119044. this._prepareBuffers();
  119045. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  119046. // Draw order
  119047. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  119048. pp.onAfterRenderObservable.notifyObservers(effect);
  119049. }
  119050. }
  119051. // Restore depth buffer
  119052. engine.setDepthBuffer(true);
  119053. engine.setDepthWrite(true);
  119054. };
  119055. /**
  119056. * Finalize the result of the output of the postprocesses.
  119057. * @param doNotPresent If true the result will not be displayed to the screen.
  119058. * @param targetTexture The target texture to render to.
  119059. * @param faceIndex The index of the face to bind the target texture to.
  119060. * @param postProcesses The array of post processes to render.
  119061. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119062. * @hidden
  119063. */
  119064. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  119065. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  119066. var camera = this._scene.activeCamera;
  119067. if (!camera) {
  119068. return;
  119069. }
  119070. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  119071. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  119072. return;
  119073. }
  119074. var engine = this._scene.getEngine();
  119075. for (var index = 0, len = postProcesses.length; index < len; index++) {
  119076. var pp = postProcesses[index];
  119077. if (index < len - 1) {
  119078. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  119079. }
  119080. else {
  119081. if (targetTexture) {
  119082. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  119083. pp._outputTexture = targetTexture;
  119084. }
  119085. else {
  119086. engine.restoreDefaultFramebuffer();
  119087. pp._outputTexture = null;
  119088. }
  119089. }
  119090. if (doNotPresent) {
  119091. break;
  119092. }
  119093. var effect = pp.apply();
  119094. if (effect) {
  119095. pp.onBeforeRenderObservable.notifyObservers(effect);
  119096. // VBOs
  119097. this._prepareBuffers();
  119098. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  119099. // Draw order
  119100. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  119101. pp.onAfterRenderObservable.notifyObservers(effect);
  119102. }
  119103. }
  119104. // Restore states
  119105. engine.setDepthBuffer(true);
  119106. engine.setDepthWrite(true);
  119107. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  119108. };
  119109. /**
  119110. * Disposes of the post process manager.
  119111. */
  119112. PostProcessManager.prototype.dispose = function () {
  119113. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119114. if (buffer) {
  119115. buffer.dispose();
  119116. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119117. }
  119118. if (this._indexBuffer) {
  119119. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  119120. this._indexBuffer = null;
  119121. }
  119122. };
  119123. return PostProcessManager;
  119124. }());
  119125. /***/ }),
  119126. /***/ "./PostProcesses/refractionPostProcess.ts":
  119127. /*!************************************************!*\
  119128. !*** ./PostProcesses/refractionPostProcess.ts ***!
  119129. \************************************************/
  119130. /*! exports provided: RefractionPostProcess */
  119131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119132. "use strict";
  119133. __webpack_require__.r(__webpack_exports__);
  119134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  119135. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119136. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119137. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119138. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  119139. /**
  119140. * Post process which applies a refractin texture
  119141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119142. */
  119143. var RefractionPostProcess = /** @class */ (function (_super) {
  119144. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  119145. /**
  119146. * Initializes the RefractionPostProcess
  119147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119148. * @param name The name of the effect.
  119149. * @param refractionTextureUrl Url of the refraction texture to use
  119150. * @param color the base color of the refraction (used to taint the rendering)
  119151. * @param depth simulated refraction depth
  119152. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  119153. * @param camera The camera to apply the render pass to.
  119154. * @param options The required width/height ratio to downsize to before computing the render pass.
  119155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119156. * @param engine The engine which the post process will be applied. (default: current engine)
  119157. * @param reusable If the post process can be reused on the same frame. (default: false)
  119158. */
  119159. function RefractionPostProcess(name, refractionTextureUrl,
  119160. /** the base color of the refraction (used to taint the rendering) */
  119161. color,
  119162. /** simulated refraction depth */
  119163. depth,
  119164. /** the coefficient of the base color (0 to remove base color tainting) */
  119165. colorLevel, options, camera, samplingMode, engine, reusable) {
  119166. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  119167. _this.color = color;
  119168. _this.depth = depth;
  119169. _this.colorLevel = colorLevel;
  119170. _this._ownRefractionTexture = true;
  119171. _this.onActivateObservable.add(function (cam) {
  119172. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  119173. });
  119174. _this.onApplyObservable.add(function (effect) {
  119175. effect.setColor3("baseColor", _this.color);
  119176. effect.setFloat("depth", _this.depth);
  119177. effect.setFloat("colorLevel", _this.colorLevel);
  119178. effect.setTexture("refractionSampler", _this._refTexture);
  119179. });
  119180. return _this;
  119181. }
  119182. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  119183. /**
  119184. * Gets or sets the refraction texture
  119185. * Please note that you are responsible for disposing the texture if you set it manually
  119186. */
  119187. get: function () {
  119188. return this._refTexture;
  119189. },
  119190. set: function (value) {
  119191. if (this._refTexture && this._ownRefractionTexture) {
  119192. this._refTexture.dispose();
  119193. }
  119194. this._refTexture = value;
  119195. this._ownRefractionTexture = false;
  119196. },
  119197. enumerable: true,
  119198. configurable: true
  119199. });
  119200. // Methods
  119201. /**
  119202. * Disposes of the post process
  119203. * @param camera Camera to dispose post process on
  119204. */
  119205. RefractionPostProcess.prototype.dispose = function (camera) {
  119206. if (this._refTexture && this._ownRefractionTexture) {
  119207. this._refTexture.dispose();
  119208. this._refTexture = null;
  119209. }
  119210. _super.prototype.dispose.call(this, camera);
  119211. };
  119212. return RefractionPostProcess;
  119213. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119214. /***/ }),
  119215. /***/ "./PostProcesses/sharpenPostProcess.ts":
  119216. /*!*********************************************!*\
  119217. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  119218. \*********************************************/
  119219. /*! exports provided: SharpenPostProcess */
  119220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119221. "use strict";
  119222. __webpack_require__.r(__webpack_exports__);
  119223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  119224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119225. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119226. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119227. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  119228. /**
  119229. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119230. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119231. */
  119232. var SharpenPostProcess = /** @class */ (function (_super) {
  119233. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  119234. /**
  119235. * Creates a new instance ConvolutionPostProcess
  119236. * @param name The name of the effect.
  119237. * @param options The required width/height ratio to downsize to before computing the render pass.
  119238. * @param camera The camera to apply the render pass to.
  119239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119240. * @param engine The engine which the post process will be applied. (default: current engine)
  119241. * @param reusable If the post process can be reused on the same frame. (default: false)
  119242. * @param textureType Type of textures used when performing the post process. (default: 0)
  119243. * @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)
  119244. */
  119245. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119246. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119247. if (blockCompilation === void 0) { blockCompilation = false; }
  119248. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119249. /**
  119250. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119251. */
  119252. _this.colorAmount = 1.0;
  119253. /**
  119254. * How much sharpness should be applied (default: 0.3)
  119255. */
  119256. _this.edgeAmount = 0.3;
  119257. _this.onApply = function (effect) {
  119258. effect.setFloat2("screenSize", _this.width, _this.height);
  119259. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  119260. };
  119261. return _this;
  119262. }
  119263. return SharpenPostProcess;
  119264. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119265. /***/ }),
  119266. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  119267. /*!***********************************************************!*\
  119268. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  119269. \***********************************************************/
  119270. /*! exports provided: StereoscopicInterlacePostProcess */
  119271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119272. "use strict";
  119273. __webpack_require__.r(__webpack_exports__);
  119274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  119275. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119276. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119277. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119278. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  119279. /**
  119280. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  119281. */
  119282. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  119283. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  119284. /**
  119285. * Initializes a StereoscopicInterlacePostProcess
  119286. * @param name The name of the effect.
  119287. * @param rigCameras The rig cameras to be appled to the post process
  119288. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  119289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119290. * @param engine The engine which the post process will be applied. (default: current engine)
  119291. * @param reusable If the post process can be reused on the same frame. (default: false)
  119292. */
  119293. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  119294. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  119295. _this._passedProcess = rigCameras[0]._rigPostProcess;
  119296. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  119297. _this.onSizeChangedObservable.add(function () {
  119298. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  119299. });
  119300. _this.onApplyObservable.add(function (effect) {
  119301. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  119302. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  119303. });
  119304. return _this;
  119305. }
  119306. return StereoscopicInterlacePostProcess;
  119307. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119308. /***/ }),
  119309. /***/ "./PostProcesses/tonemapPostProcess.ts":
  119310. /*!*********************************************!*\
  119311. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  119312. \*********************************************/
  119313. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  119314. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119315. "use strict";
  119316. __webpack_require__.r(__webpack_exports__);
  119317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  119318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  119319. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119320. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119321. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119322. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  119323. /** Defines operator used for tonemapping */
  119324. var TonemappingOperator;
  119325. (function (TonemappingOperator) {
  119326. /** Hable */
  119327. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  119328. /** Reinhard */
  119329. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  119330. /** HejiDawson */
  119331. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  119332. /** Photographic */
  119333. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  119334. })(TonemappingOperator || (TonemappingOperator = {}));
  119335. /**
  119336. * Defines a post process to apply tone mapping
  119337. */
  119338. var TonemapPostProcess = /** @class */ (function (_super) {
  119339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  119340. /**
  119341. * Creates a new TonemapPostProcess
  119342. * @param name defines the name of the postprocess
  119343. * @param _operator defines the operator to use
  119344. * @param exposureAdjustment defines the required exposure adjustement
  119345. * @param camera defines the camera to use (can be null)
  119346. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119347. * @param engine defines the hosting engine (can be ignore if camera is set)
  119348. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119349. */
  119350. function TonemapPostProcess(name, _operator,
  119351. /** Defines the required exposure adjustement */
  119352. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  119353. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  119354. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119355. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  119356. _this._operator = _operator;
  119357. _this.exposureAdjustment = exposureAdjustment;
  119358. var defines = "#define ";
  119359. if (_this._operator === TonemappingOperator.Hable) {
  119360. defines += "HABLE_TONEMAPPING";
  119361. }
  119362. else if (_this._operator === TonemappingOperator.Reinhard) {
  119363. defines += "REINHARD_TONEMAPPING";
  119364. }
  119365. else if (_this._operator === TonemappingOperator.HejiDawson) {
  119366. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  119367. }
  119368. else if (_this._operator === TonemappingOperator.Photographic) {
  119369. defines += "PHOTOGRAPHIC_TONEMAPPING";
  119370. }
  119371. //sadly a second call to create the effect.
  119372. _this.updateEffect(defines);
  119373. _this.onApply = function (effect) {
  119374. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  119375. };
  119376. return _this;
  119377. }
  119378. return TonemapPostProcess;
  119379. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119380. /***/ }),
  119381. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  119382. /*!***************************************************************!*\
  119383. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  119384. \***************************************************************/
  119385. /*! exports provided: VolumetricLightScatteringPostProcess */
  119386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119387. "use strict";
  119388. __webpack_require__.r(__webpack_exports__);
  119389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  119390. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119391. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119392. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  119393. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119394. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119395. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119396. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  119397. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119398. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  119399. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119400. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119401. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119402. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119403. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  119404. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119405. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  119406. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  119407. /**
  119408. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119409. */
  119410. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  119411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  119412. /**
  119413. * @constructor
  119414. * @param name The post-process name
  119415. * @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)
  119416. * @param camera The camera that the post-process will be attached to
  119417. * @param mesh The mesh used to create the light scattering
  119418. * @param samples The post-process quality, default 100
  119419. * @param samplingModeThe post-process filtering mode
  119420. * @param engine The babylon engine
  119421. * @param reusable If the post-process is reusable
  119422. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119423. */
  119424. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  119425. if (samples === void 0) { samples = 100; }
  119426. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  119427. 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;
  119428. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119429. /**
  119430. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119431. */
  119432. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119433. /**
  119434. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119435. */
  119436. _this.useCustomMeshPosition = false;
  119437. /**
  119438. * If the post-process should inverse the light scattering direction
  119439. */
  119440. _this.invert = true;
  119441. /**
  119442. * Array containing the excluded meshes not rendered in the internal pass
  119443. */
  119444. _this.excludedMeshes = new Array();
  119445. /**
  119446. * Controls the overall intensity of the post-process
  119447. */
  119448. _this.exposure = 0.3;
  119449. /**
  119450. * Dissipates each sample's contribution in range [0, 1]
  119451. */
  119452. _this.decay = 0.96815;
  119453. /**
  119454. * Controls the overall intensity of each sample
  119455. */
  119456. _this.weight = 0.58767;
  119457. /**
  119458. * Controls the density of each sample
  119459. */
  119460. _this.density = 0.926;
  119461. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  119462. engine = scene.getEngine();
  119463. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  119464. // Configure mesh
  119465. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  119466. // Configure
  119467. _this._createPass(scene, ratio.passRatio || ratio);
  119468. _this.onActivate = function (camera) {
  119469. if (!_this.isSupported) {
  119470. _this.dispose(camera);
  119471. }
  119472. _this.onActivate = null;
  119473. };
  119474. _this.onApplyObservable.add(function (effect) {
  119475. _this._updateMeshScreenCoordinates(scene);
  119476. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  119477. effect.setFloat("exposure", _this.exposure);
  119478. effect.setFloat("decay", _this.decay);
  119479. effect.setFloat("weight", _this.weight);
  119480. effect.setFloat("density", _this.density);
  119481. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  119482. });
  119483. return _this;
  119484. }
  119485. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  119486. /**
  119487. * @hidden
  119488. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119489. */
  119490. get: function () {
  119491. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119492. return false;
  119493. },
  119494. set: function (useDiffuseColor) {
  119495. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119496. },
  119497. enumerable: true,
  119498. configurable: true
  119499. });
  119500. /**
  119501. * Returns the string "VolumetricLightScatteringPostProcess"
  119502. * @returns "VolumetricLightScatteringPostProcess"
  119503. */
  119504. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  119505. return "VolumetricLightScatteringPostProcess";
  119506. };
  119507. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  119508. var mesh = subMesh.getMesh();
  119509. // Render this.mesh as default
  119510. if (mesh === this.mesh && mesh.material) {
  119511. return mesh.material.isReady(mesh);
  119512. }
  119513. var defines = [];
  119514. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  119515. var material = subMesh.getMaterial();
  119516. // Alpha test
  119517. if (material) {
  119518. if (material.needAlphaTesting()) {
  119519. defines.push("#define ALPHATEST");
  119520. }
  119521. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  119522. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  119523. defines.push("#define UV1");
  119524. }
  119525. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  119526. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  119527. defines.push("#define UV2");
  119528. }
  119529. }
  119530. // Bones
  119531. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119532. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  119533. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  119534. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119535. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  119536. }
  119537. else {
  119538. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119539. }
  119540. // Instances
  119541. if (useInstances) {
  119542. defines.push("#define INSTANCES");
  119543. attribs.push("world0");
  119544. attribs.push("world1");
  119545. attribs.push("world2");
  119546. attribs.push("world3");
  119547. }
  119548. // Get correct effect
  119549. var join = defines.join("\n");
  119550. if (this._cachedDefines !== join) {
  119551. this._cachedDefines = join;
  119552. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  119553. }
  119554. return this._volumetricLightScatteringPass.isReady();
  119555. };
  119556. /**
  119557. * Sets the new light position for light scattering effect
  119558. * @param position The new custom light position
  119559. */
  119560. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  119561. this.customMeshPosition = position;
  119562. };
  119563. /**
  119564. * Returns the light position for light scattering effect
  119565. * @return Vector3 The custom light position
  119566. */
  119567. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  119568. return this.customMeshPosition;
  119569. };
  119570. /**
  119571. * Disposes the internal assets and detaches the post-process from the camera
  119572. */
  119573. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  119574. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  119575. if (rttIndex !== -1) {
  119576. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  119577. }
  119578. this._volumetricLightScatteringRTT.dispose();
  119579. _super.prototype.dispose.call(this, camera);
  119580. };
  119581. /**
  119582. * Returns the render target texture used by the post-process
  119583. * @return the render target texture used by the post-process
  119584. */
  119585. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  119586. return this._volumetricLightScatteringRTT;
  119587. };
  119588. // Private methods
  119589. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  119590. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  119591. return true;
  119592. }
  119593. return false;
  119594. };
  119595. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  119596. var _this = this;
  119597. var engine = scene.getEngine();
  119598. 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);
  119599. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119600. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119601. this._volumetricLightScatteringRTT.renderList = null;
  119602. this._volumetricLightScatteringRTT.renderParticles = false;
  119603. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  119604. var camera = this.getCamera();
  119605. if (camera) {
  119606. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119607. }
  119608. else {
  119609. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119610. }
  119611. // Custom render function for submeshes
  119612. var renderSubMesh = function (subMesh) {
  119613. var mesh = subMesh.getRenderingMesh();
  119614. if (_this._meshExcluded(mesh)) {
  119615. return;
  119616. }
  119617. var material = subMesh.getMaterial();
  119618. if (!material) {
  119619. return;
  119620. }
  119621. var scene = mesh.getScene();
  119622. var engine = scene.getEngine();
  119623. // Culling
  119624. engine.setState(material.backFaceCulling);
  119625. // Managing instances
  119626. var batch = mesh._getInstancesRenderList(subMesh._id);
  119627. if (batch.mustReturn) {
  119628. return;
  119629. }
  119630. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119631. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  119632. var effect = _this._volumetricLightScatteringPass;
  119633. if (mesh === _this.mesh) {
  119634. if (subMesh.effect) {
  119635. effect = subMesh.effect;
  119636. }
  119637. else {
  119638. effect = material.getEffect();
  119639. }
  119640. }
  119641. engine.enableEffect(effect);
  119642. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  119643. if (mesh === _this.mesh) {
  119644. material.bind(mesh.getWorldMatrix(), mesh);
  119645. }
  119646. else {
  119647. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  119648. // Alpha test
  119649. if (material && material.needAlphaTesting()) {
  119650. var alphaTexture = material.getAlphaTestTexture();
  119651. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  119652. if (alphaTexture) {
  119653. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119654. }
  119655. }
  119656. // Bones
  119657. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119658. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119659. }
  119660. }
  119661. // Draw
  119662. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  119663. }
  119664. };
  119665. // Render target texture callbacks
  119666. var savedSceneClearColor;
  119667. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  119668. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  119669. savedSceneClearColor = scene.clearColor;
  119670. scene.clearColor = sceneClearColor;
  119671. });
  119672. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  119673. scene.clearColor = savedSceneClearColor;
  119674. });
  119675. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  119676. var engine = scene.getEngine();
  119677. var index;
  119678. if (depthOnlySubMeshes.length) {
  119679. engine.setColorWrite(false);
  119680. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  119681. renderSubMesh(depthOnlySubMeshes.data[index]);
  119682. }
  119683. engine.setColorWrite(true);
  119684. }
  119685. for (index = 0; index < opaqueSubMeshes.length; index++) {
  119686. renderSubMesh(opaqueSubMeshes.data[index]);
  119687. }
  119688. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  119689. renderSubMesh(alphaTestSubMeshes.data[index]);
  119690. }
  119691. if (transparentSubMeshes.length) {
  119692. // Sort sub meshes
  119693. for (index = 0; index < transparentSubMeshes.length; index++) {
  119694. var submesh = transparentSubMeshes.data[index];
  119695. var boundingInfo = submesh.getBoundingInfo();
  119696. if (boundingInfo && scene.activeCamera) {
  119697. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  119698. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  119699. }
  119700. }
  119701. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  119702. sortedArray.sort(function (a, b) {
  119703. // Alpha index first
  119704. if (a._alphaIndex > b._alphaIndex) {
  119705. return 1;
  119706. }
  119707. if (a._alphaIndex < b._alphaIndex) {
  119708. return -1;
  119709. }
  119710. // Then distance to camera
  119711. if (a._distanceToCamera < b._distanceToCamera) {
  119712. return 1;
  119713. }
  119714. if (a._distanceToCamera > b._distanceToCamera) {
  119715. return -1;
  119716. }
  119717. return 0;
  119718. });
  119719. // Render sub meshes
  119720. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  119721. for (index = 0; index < sortedArray.length; index++) {
  119722. renderSubMesh(sortedArray[index]);
  119723. }
  119724. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  119725. }
  119726. };
  119727. };
  119728. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  119729. var transform = scene.getTransformMatrix();
  119730. var meshPosition;
  119731. if (this.useCustomMeshPosition) {
  119732. meshPosition = this.customMeshPosition;
  119733. }
  119734. else if (this.attachedNode) {
  119735. meshPosition = this.attachedNode.position;
  119736. }
  119737. else {
  119738. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  119739. }
  119740. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  119741. this._screenCoordinates.x = pos.x / this._viewPort.width;
  119742. this._screenCoordinates.y = pos.y / this._viewPort.height;
  119743. if (this.invert) {
  119744. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  119745. }
  119746. };
  119747. // Static methods
  119748. /**
  119749. * Creates a default mesh for the Volumeric Light Scattering post-process
  119750. * @param name The mesh name
  119751. * @param scene The scene where to create the mesh
  119752. * @return the default mesh
  119753. */
  119754. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  119755. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  119756. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  119757. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  119758. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  119759. mesh.material = material;
  119760. return mesh;
  119761. };
  119762. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119763. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  119764. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  119765. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119766. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119767. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  119768. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119770. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  119771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  119773. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  119774. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119775. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119776. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  119777. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119778. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119779. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  119780. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119782. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  119783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119785. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  119786. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119787. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119788. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  119789. return VolumetricLightScatteringPostProcess;
  119790. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  119791. /***/ }),
  119792. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  119793. /*!************************************************************!*\
  119794. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  119795. \************************************************************/
  119796. /*! exports provided: VRDistortionCorrectionPostProcess */
  119797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119798. "use strict";
  119799. __webpack_require__.r(__webpack_exports__);
  119800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  119801. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119802. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119803. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119804. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119805. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  119806. /**
  119807. * VRDistortionCorrectionPostProcess used for mobile VR
  119808. */
  119809. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  119810. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  119811. /**
  119812. * Initializes the VRDistortionCorrectionPostProcess
  119813. * @param name The name of the effect.
  119814. * @param camera The camera to apply the render pass to.
  119815. * @param isRightEye If this is for the right eye distortion
  119816. * @param vrMetrics All the required metrics for the VR camera
  119817. */
  119818. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  119819. var _this = _super.call(this, name, "vrDistortionCorrection", [
  119820. 'LensCenter',
  119821. 'Scale',
  119822. 'ScaleIn',
  119823. 'HmdWarpParam'
  119824. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  119825. _this._isRightEye = isRightEye;
  119826. _this._distortionFactors = vrMetrics.distortionK;
  119827. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  119828. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  119829. _this.adaptScaleToCurrentViewport = true;
  119830. _this.onSizeChangedObservable.add(function () {
  119831. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  119832. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  119833. _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);
  119834. });
  119835. _this.onApplyObservable.add(function (effect) {
  119836. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  119837. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  119838. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  119839. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  119840. });
  119841. return _this;
  119842. }
  119843. return VRDistortionCorrectionPostProcess;
  119844. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  119845. /***/ }),
  119846. /***/ "./Probes/index.ts":
  119847. /*!*************************!*\
  119848. !*** ./Probes/index.ts ***!
  119849. \*************************/
  119850. /*! exports provided: ReflectionProbe */
  119851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119852. "use strict";
  119853. __webpack_require__.r(__webpack_exports__);
  119854. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  119855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  119856. /***/ }),
  119857. /***/ "./Probes/reflectionProbe.ts":
  119858. /*!***********************************!*\
  119859. !*** ./Probes/reflectionProbe.ts ***!
  119860. \***********************************/
  119861. /*! exports provided: ReflectionProbe */
  119862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119863. "use strict";
  119864. __webpack_require__.r(__webpack_exports__);
  119865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  119866. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119867. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119868. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119869. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119870. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  119871. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119872. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  119873. if (!this.reflectionProbes) {
  119874. return -1;
  119875. }
  119876. var index = this.reflectionProbes.indexOf(toRemove);
  119877. if (index !== -1) {
  119878. this.reflectionProbes.splice(index, 1);
  119879. }
  119880. return index;
  119881. };
  119882. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  119883. if (!this.reflectionProbes) {
  119884. this.reflectionProbes = [];
  119885. }
  119886. this.reflectionProbes.push(newReflectionProbe);
  119887. };
  119888. /**
  119889. * Class used to generate realtime reflection / refraction cube textures
  119890. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119891. */
  119892. var ReflectionProbe = /** @class */ (function () {
  119893. /**
  119894. * Creates a new reflection probe
  119895. * @param name defines the name of the probe
  119896. * @param size defines the texture resolution (for each face)
  119897. * @param scene defines the hosting scene
  119898. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119899. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119900. */
  119901. function ReflectionProbe(
  119902. /** defines the name of the probe */
  119903. name, size, scene, generateMipMaps, useFloat) {
  119904. if (generateMipMaps === void 0) { generateMipMaps = true; }
  119905. if (useFloat === void 0) { useFloat = false; }
  119906. var _this = this;
  119907. this.name = name;
  119908. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  119909. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119910. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119911. this._invertYAxis = false;
  119912. /** Gets or sets probe position (center of the cube map) */
  119913. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119914. this._scene = scene;
  119915. // Create the scene field if not exist.
  119916. if (!this._scene.reflectionProbes) {
  119917. this._scene.reflectionProbes = new Array();
  119918. }
  119919. this._scene.reflectionProbes.push(this);
  119920. 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);
  119921. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  119922. switch (faceIndex) {
  119923. case 0:
  119924. _this._add.copyFromFloats(1, 0, 0);
  119925. break;
  119926. case 1:
  119927. _this._add.copyFromFloats(-1, 0, 0);
  119928. break;
  119929. case 2:
  119930. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  119931. break;
  119932. case 3:
  119933. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  119934. break;
  119935. case 4:
  119936. _this._add.copyFromFloats(0, 0, 1);
  119937. break;
  119938. case 5:
  119939. _this._add.copyFromFloats(0, 0, -1);
  119940. break;
  119941. }
  119942. if (_this._attachedMesh) {
  119943. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  119944. }
  119945. _this.position.addToRef(_this._add, _this._target);
  119946. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  119947. if (scene.activeCamera) {
  119948. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  119949. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  119950. }
  119951. scene._forcedViewPosition = _this.position;
  119952. });
  119953. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  119954. scene._forcedViewPosition = null;
  119955. scene.updateTransformMatrix(true);
  119956. });
  119957. }
  119958. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  119959. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119960. get: function () {
  119961. return this._renderTargetTexture.samples;
  119962. },
  119963. set: function (value) {
  119964. this._renderTargetTexture.samples = value;
  119965. },
  119966. enumerable: true,
  119967. configurable: true
  119968. });
  119969. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  119970. /** Gets or sets the refresh rate to use (on every frame by default) */
  119971. get: function () {
  119972. return this._renderTargetTexture.refreshRate;
  119973. },
  119974. set: function (value) {
  119975. this._renderTargetTexture.refreshRate = value;
  119976. },
  119977. enumerable: true,
  119978. configurable: true
  119979. });
  119980. /**
  119981. * Gets the hosting scene
  119982. * @returns a Scene
  119983. */
  119984. ReflectionProbe.prototype.getScene = function () {
  119985. return this._scene;
  119986. };
  119987. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  119988. /** Gets the internal CubeTexture used to render to */
  119989. get: function () {
  119990. return this._renderTargetTexture;
  119991. },
  119992. enumerable: true,
  119993. configurable: true
  119994. });
  119995. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  119996. /** Gets the list of meshes to render */
  119997. get: function () {
  119998. return this._renderTargetTexture.renderList;
  119999. },
  120000. enumerable: true,
  120001. configurable: true
  120002. });
  120003. /**
  120004. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120005. * @param mesh defines the mesh to attach to
  120006. */
  120007. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  120008. this._attachedMesh = mesh;
  120009. };
  120010. /**
  120011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120012. * @param renderingGroupId The rendering group id corresponding to its index
  120013. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120014. */
  120015. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  120016. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  120017. };
  120018. /**
  120019. * Clean all associated resources
  120020. */
  120021. ReflectionProbe.prototype.dispose = function () {
  120022. var index = this._scene.reflectionProbes.indexOf(this);
  120023. if (index !== -1) {
  120024. // Remove from the scene if found
  120025. this._scene.reflectionProbes.splice(index, 1);
  120026. }
  120027. if (this._renderTargetTexture) {
  120028. this._renderTargetTexture.dispose();
  120029. this._renderTargetTexture = null;
  120030. }
  120031. };
  120032. /**
  120033. * Converts the reflection probe information to a readable string for debug purpose.
  120034. * @param fullDetails Supports for multiple levels of logging within scene loading
  120035. * @returns the human readable reflection probe info
  120036. */
  120037. ReflectionProbe.prototype.toString = function (fullDetails) {
  120038. var ret = "Name: " + this.name;
  120039. if (fullDetails) {
  120040. ret += ", position: " + this.position.toString();
  120041. if (this._attachedMesh) {
  120042. ret += ", attached mesh: " + this._attachedMesh.name;
  120043. }
  120044. }
  120045. return ret;
  120046. };
  120047. /**
  120048. * Get the class name of the relfection probe.
  120049. * @returns "ReflectionProbe"
  120050. */
  120051. ReflectionProbe.prototype.getClassName = function () {
  120052. return "ReflectionProbe";
  120053. };
  120054. /**
  120055. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120056. * @returns The JSON representation of the texture
  120057. */
  120058. ReflectionProbe.prototype.serialize = function () {
  120059. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  120060. serializationObject.isReflectionProbe = true;
  120061. return serializationObject;
  120062. };
  120063. /**
  120064. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120065. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120066. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120067. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120068. * @returns The parsed reflection probe if successful
  120069. */
  120070. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  120071. var reflectionProbe = null;
  120072. if (scene.reflectionProbes) {
  120073. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  120074. var rp = scene.reflectionProbes[index];
  120075. if (rp.name === parsedReflectionProbe.name) {
  120076. reflectionProbe = rp;
  120077. break;
  120078. }
  120079. }
  120080. }
  120081. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  120082. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  120083. if (parsedReflectionProbe._attachedMesh) {
  120084. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  120085. }
  120086. return reflectionProbe;
  120087. };
  120088. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120089. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  120090. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  120091. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  120093. ], ReflectionProbe.prototype, "position", void 0);
  120094. return ReflectionProbe;
  120095. }());
  120096. /***/ }),
  120097. /***/ "./Rendering/boundingBoxRenderer.ts":
  120098. /*!******************************************!*\
  120099. !*** ./Rendering/boundingBoxRenderer.ts ***!
  120100. \******************************************/
  120101. /*! exports provided: BoundingBoxRenderer */
  120102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120103. "use strict";
  120104. __webpack_require__.r(__webpack_exports__);
  120105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  120106. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120107. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120108. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120109. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  120110. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120111. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120112. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120113. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120114. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120115. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  120116. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  120117. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  120118. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  120119. get: function () {
  120120. return this._forceShowBoundingBoxes || false;
  120121. },
  120122. set: function (value) {
  120123. this._forceShowBoundingBoxes = value;
  120124. // Lazyly creates a BB renderer if needed.
  120125. if (value) {
  120126. this.getBoundingBoxRenderer();
  120127. }
  120128. },
  120129. enumerable: true,
  120130. configurable: true
  120131. });
  120132. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  120133. if (!this._boundingBoxRenderer) {
  120134. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  120135. }
  120136. return this._boundingBoxRenderer;
  120137. };
  120138. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  120139. get: function () {
  120140. return this._showBoundingBox || false;
  120141. },
  120142. set: function (value) {
  120143. this._showBoundingBox = value;
  120144. // Lazyly creates a BB renderer if needed.
  120145. if (value) {
  120146. this.getScene().getBoundingBoxRenderer();
  120147. }
  120148. },
  120149. enumerable: true,
  120150. configurable: true
  120151. });
  120152. /**
  120153. * Component responsible of rendering the bounding box of the meshes in a scene.
  120154. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120155. */
  120156. var BoundingBoxRenderer = /** @class */ (function () {
  120157. /**
  120158. * Instantiates a new bounding box renderer in a scene.
  120159. * @param scene the scene the renderer renders in
  120160. */
  120161. function BoundingBoxRenderer(scene) {
  120162. /**
  120163. * The component name helpfull to identify the component in the list of scene components.
  120164. */
  120165. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  120166. /**
  120167. * Color of the bounding box lines placed in front of an object
  120168. */
  120169. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  120170. /**
  120171. * Color of the bounding box lines placed behind an object
  120172. */
  120173. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  120174. /**
  120175. * Defines if the renderer should show the back lines or not
  120176. */
  120177. this.showBackLines = true;
  120178. /**
  120179. * @hidden
  120180. */
  120181. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  120182. this._vertexBuffers = {};
  120183. this.scene = scene;
  120184. scene._addComponent(this);
  120185. }
  120186. /**
  120187. * Registers the component in a given scene
  120188. */
  120189. BoundingBoxRenderer.prototype.register = function () {
  120190. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  120191. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  120192. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  120193. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  120194. };
  120195. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  120196. if (mesh.showSubMeshesBoundingBox) {
  120197. var boundingInfo = subMesh.getBoundingInfo();
  120198. if (boundingInfo !== null && boundingInfo !== undefined) {
  120199. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120200. this.renderList.push(boundingInfo.boundingBox);
  120201. }
  120202. }
  120203. };
  120204. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  120205. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  120206. var boundingInfo = sourceMesh.getBoundingInfo();
  120207. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120208. this.renderList.push(boundingInfo.boundingBox);
  120209. }
  120210. };
  120211. BoundingBoxRenderer.prototype._prepareRessources = function () {
  120212. if (this._colorShader) {
  120213. return;
  120214. }
  120215. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  120216. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  120217. uniforms: ["world", "viewProjection", "color"]
  120218. });
  120219. var engine = this.scene.getEngine();
  120220. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  120221. 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);
  120222. this._createIndexBuffer();
  120223. };
  120224. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  120225. var engine = this.scene.getEngine();
  120226. 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]);
  120227. };
  120228. /**
  120229. * Rebuilds the elements related to this component in case of
  120230. * context lost for instance.
  120231. */
  120232. BoundingBoxRenderer.prototype.rebuild = function () {
  120233. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120234. if (vb) {
  120235. vb._rebuild();
  120236. }
  120237. this._createIndexBuffer();
  120238. };
  120239. /**
  120240. * @hidden
  120241. */
  120242. BoundingBoxRenderer.prototype.reset = function () {
  120243. this.renderList.reset();
  120244. };
  120245. /**
  120246. * Render the bounding boxes of a specific rendering group
  120247. * @param renderingGroupId defines the rendering group to render
  120248. */
  120249. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  120250. if (this.renderList.length === 0) {
  120251. return;
  120252. }
  120253. this._prepareRessources();
  120254. if (!this._colorShader.isReady()) {
  120255. return;
  120256. }
  120257. var engine = this.scene.getEngine();
  120258. engine.setDepthWrite(false);
  120259. this._colorShader._preBind();
  120260. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  120261. var boundingBox = this.renderList.data[boundingBoxIndex];
  120262. if (boundingBox._tag !== renderingGroupId) {
  120263. continue;
  120264. }
  120265. var min = boundingBox.minimum;
  120266. var max = boundingBox.maximum;
  120267. var diff = max.subtract(min);
  120268. var median = min.add(diff.scale(0.5));
  120269. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  120270. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  120271. .multiply(boundingBox.getWorldMatrix());
  120272. // VBOs
  120273. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  120274. if (this.showBackLines) {
  120275. // Back
  120276. engine.setDepthFunctionToGreaterOrEqual();
  120277. this.scene.resetCachedMaterial();
  120278. this._colorShader.setColor4("color", this.backColor.toColor4());
  120279. this._colorShader.bind(worldMatrix);
  120280. // Draw order
  120281. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120282. }
  120283. // Front
  120284. engine.setDepthFunctionToLess();
  120285. this.scene.resetCachedMaterial();
  120286. this._colorShader.setColor4("color", this.frontColor.toColor4());
  120287. this._colorShader.bind(worldMatrix);
  120288. // Draw order
  120289. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120290. }
  120291. this._colorShader.unbind();
  120292. engine.setDepthFunctionToLessOrEqual();
  120293. engine.setDepthWrite(true);
  120294. };
  120295. /**
  120296. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120297. * @param mesh Define the mesh to render the occlusion bounding box for
  120298. */
  120299. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  120300. this._prepareRessources();
  120301. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  120302. return;
  120303. }
  120304. var engine = this.scene.getEngine();
  120305. engine.setDepthWrite(false);
  120306. engine.setColorWrite(false);
  120307. this._colorShader._preBind();
  120308. var boundingBox = mesh._boundingInfo.boundingBox;
  120309. var min = boundingBox.minimum;
  120310. var max = boundingBox.maximum;
  120311. var diff = max.subtract(min);
  120312. var median = min.add(diff.scale(0.5));
  120313. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  120314. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  120315. .multiply(boundingBox.getWorldMatrix());
  120316. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  120317. engine.setDepthFunctionToLess();
  120318. this.scene.resetCachedMaterial();
  120319. this._colorShader.bind(worldMatrix);
  120320. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120321. this._colorShader.unbind();
  120322. engine.setDepthFunctionToLessOrEqual();
  120323. engine.setDepthWrite(true);
  120324. engine.setColorWrite(true);
  120325. };
  120326. /**
  120327. * Dispose and release the resources attached to this renderer.
  120328. */
  120329. BoundingBoxRenderer.prototype.dispose = function () {
  120330. if (!this._colorShader) {
  120331. return;
  120332. }
  120333. this.renderList.dispose();
  120334. this._colorShader.dispose();
  120335. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120336. if (buffer) {
  120337. buffer.dispose();
  120338. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120339. }
  120340. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  120341. };
  120342. return BoundingBoxRenderer;
  120343. }());
  120344. /***/ }),
  120345. /***/ "./Rendering/depthRenderer.ts":
  120346. /*!************************************!*\
  120347. !*** ./Rendering/depthRenderer.ts ***!
  120348. \************************************/
  120349. /*! exports provided: DepthRenderer */
  120350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120351. "use strict";
  120352. __webpack_require__.r(__webpack_exports__);
  120353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  120354. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120355. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120356. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120357. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  120358. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120359. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120360. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  120361. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  120362. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  120363. /**
  120364. * This represents a depth renderer in Babylon.
  120365. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120366. */
  120367. var DepthRenderer = /** @class */ (function () {
  120368. /**
  120369. * Instantiates a depth renderer
  120370. * @param scene The scene the renderer belongs to
  120371. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120372. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120373. */
  120374. function DepthRenderer(scene, type, camera) {
  120375. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  120376. if (camera === void 0) { camera = null; }
  120377. var _this = this;
  120378. /**
  120379. * Specifiess that the depth renderer will only be used within
  120380. * the camera it is created for.
  120381. * This can help forcing its rendering during the camera processing.
  120382. */
  120383. this.useOnlyInActiveCamera = false;
  120384. this._scene = scene;
  120385. DepthRenderer._SceneComponentInitialization(this._scene);
  120386. this._camera = camera;
  120387. var engine = scene.getEngine();
  120388. // Render target
  120389. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  120390. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120391. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120392. this._depthMap.refreshRate = 1;
  120393. this._depthMap.renderParticles = false;
  120394. this._depthMap.renderList = null;
  120395. // Camera to get depth map from to support multiple concurrent cameras
  120396. this._depthMap.activeCamera = this._camera;
  120397. this._depthMap.ignoreCameraViewport = true;
  120398. this._depthMap.useCameraPostProcesses = false;
  120399. // set default depth value to 1.0 (far away)
  120400. this._depthMap.onClearObservable.add(function (engine) {
  120401. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  120402. });
  120403. // Custom render function
  120404. var renderSubMesh = function (subMesh) {
  120405. var mesh = subMesh.getRenderingMesh();
  120406. var scene = _this._scene;
  120407. var engine = scene.getEngine();
  120408. var material = subMesh.getMaterial();
  120409. if (!material) {
  120410. return;
  120411. }
  120412. // Culling and reverse (right handed system)
  120413. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  120414. // Managing instances
  120415. var batch = mesh._getInstancesRenderList(subMesh._id);
  120416. if (batch.mustReturn) {
  120417. return;
  120418. }
  120419. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120420. var camera = _this._camera || scene.activeCamera;
  120421. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  120422. engine.enableEffect(_this._effect);
  120423. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  120424. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120425. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  120426. // Alpha test
  120427. if (material && material.needAlphaTesting()) {
  120428. var alphaTexture = material.getAlphaTestTexture();
  120429. if (alphaTexture) {
  120430. _this._effect.setTexture("diffuseSampler", alphaTexture);
  120431. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120432. }
  120433. }
  120434. // Bones
  120435. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120436. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120437. }
  120438. // Draw
  120439. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  120440. }
  120441. };
  120442. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120443. var index;
  120444. if (depthOnlySubMeshes.length) {
  120445. engine.setColorWrite(false);
  120446. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120447. renderSubMesh(depthOnlySubMeshes.data[index]);
  120448. }
  120449. engine.setColorWrite(true);
  120450. }
  120451. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120452. renderSubMesh(opaqueSubMeshes.data[index]);
  120453. }
  120454. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120455. renderSubMesh(alphaTestSubMeshes.data[index]);
  120456. }
  120457. };
  120458. }
  120459. /**
  120460. * Creates the depth rendering effect and checks if the effect is ready.
  120461. * @param subMesh The submesh to be used to render the depth map of
  120462. * @param useInstances If multiple world instances should be used
  120463. * @returns if the depth renderer is ready to render the depth map
  120464. */
  120465. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  120466. var material = subMesh.getMaterial();
  120467. if (material.disableDepthWrite) {
  120468. return false;
  120469. }
  120470. var defines = [];
  120471. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120472. var mesh = subMesh.getMesh();
  120473. // Alpha test
  120474. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  120475. defines.push("#define ALPHATEST");
  120476. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  120477. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  120478. defines.push("#define UV1");
  120479. }
  120480. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  120481. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  120482. defines.push("#define UV2");
  120483. }
  120484. }
  120485. // Bones
  120486. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120487. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  120488. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  120489. if (mesh.numBoneInfluencers > 4) {
  120490. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  120491. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  120492. }
  120493. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120494. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120495. }
  120496. else {
  120497. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120498. }
  120499. // Instances
  120500. if (useInstances) {
  120501. defines.push("#define INSTANCES");
  120502. attribs.push("world0");
  120503. attribs.push("world1");
  120504. attribs.push("world2");
  120505. attribs.push("world3");
  120506. }
  120507. // Get correct effect
  120508. var join = defines.join("\n");
  120509. if (this._cachedDefines !== join) {
  120510. this._cachedDefines = join;
  120511. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  120512. }
  120513. return this._effect.isReady();
  120514. };
  120515. /**
  120516. * Gets the texture which the depth map will be written to.
  120517. * @returns The depth map texture
  120518. */
  120519. DepthRenderer.prototype.getDepthMap = function () {
  120520. return this._depthMap;
  120521. };
  120522. /**
  120523. * Disposes of the depth renderer.
  120524. */
  120525. DepthRenderer.prototype.dispose = function () {
  120526. this._depthMap.dispose();
  120527. };
  120528. /** @hidden */
  120529. DepthRenderer._SceneComponentInitialization = function (_) {
  120530. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  120531. };
  120532. return DepthRenderer;
  120533. }());
  120534. /***/ }),
  120535. /***/ "./Rendering/depthRendererSceneComponent.ts":
  120536. /*!**************************************************!*\
  120537. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  120538. \**************************************************/
  120539. /*! exports provided: DepthRendererSceneComponent */
  120540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120541. "use strict";
  120542. __webpack_require__.r(__webpack_exports__);
  120543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  120544. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120545. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  120546. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120547. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120548. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  120549. camera = camera || this.activeCamera;
  120550. if (!camera) {
  120551. throw "No camera available to enable depth renderer";
  120552. }
  120553. if (!this._depthRenderer) {
  120554. this._depthRenderer = {};
  120555. }
  120556. if (!this._depthRenderer[camera.id]) {
  120557. var textureType = 0;
  120558. if (this.getEngine().getCaps().textureHalfFloatRender) {
  120559. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  120560. }
  120561. else if (this.getEngine().getCaps().textureFloatRender) {
  120562. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  120563. }
  120564. else {
  120565. throw "Depth renderer does not support int texture type";
  120566. }
  120567. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  120568. }
  120569. return this._depthRenderer[camera.id];
  120570. };
  120571. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  120572. camera = camera || this.activeCamera;
  120573. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  120574. return;
  120575. }
  120576. this._depthRenderer[camera.id].dispose();
  120577. delete this._depthRenderer[camera.id];
  120578. };
  120579. /**
  120580. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120581. * in several rendering techniques.
  120582. */
  120583. var DepthRendererSceneComponent = /** @class */ (function () {
  120584. /**
  120585. * Creates a new instance of the component for the given scene
  120586. * @param scene Defines the scene to register the component in
  120587. */
  120588. function DepthRendererSceneComponent(scene) {
  120589. /**
  120590. * The component name helpfull to identify the component in the list of scene components.
  120591. */
  120592. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  120593. this.scene = scene;
  120594. }
  120595. /**
  120596. * Registers the component in a given scene
  120597. */
  120598. DepthRendererSceneComponent.prototype.register = function () {
  120599. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  120600. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  120601. };
  120602. /**
  120603. * Rebuilds the elements related to this component in case of
  120604. * context lost for instance.
  120605. */
  120606. DepthRendererSceneComponent.prototype.rebuild = function () {
  120607. // Nothing to do for this component
  120608. };
  120609. /**
  120610. * Disposes the component and the associated ressources
  120611. */
  120612. DepthRendererSceneComponent.prototype.dispose = function () {
  120613. for (var key in this.scene._depthRenderer) {
  120614. this.scene._depthRenderer[key].dispose();
  120615. }
  120616. };
  120617. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  120618. if (this.scene._depthRenderer) {
  120619. for (var key in this.scene._depthRenderer) {
  120620. var depthRenderer = this.scene._depthRenderer[key];
  120621. if (!depthRenderer.useOnlyInActiveCamera) {
  120622. renderTargets.push(depthRenderer.getDepthMap());
  120623. }
  120624. }
  120625. }
  120626. };
  120627. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  120628. if (this.scene._depthRenderer) {
  120629. for (var key in this.scene._depthRenderer) {
  120630. var depthRenderer = this.scene._depthRenderer[key];
  120631. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  120632. renderTargets.push(depthRenderer.getDepthMap());
  120633. }
  120634. }
  120635. }
  120636. };
  120637. return DepthRendererSceneComponent;
  120638. }());
  120639. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  120640. // Register the G Buffer component to the scene.
  120641. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  120642. if (!component) {
  120643. component = new DepthRendererSceneComponent(scene);
  120644. scene._addComponent(component);
  120645. }
  120646. };
  120647. /***/ }),
  120648. /***/ "./Rendering/edgesRenderer.ts":
  120649. /*!************************************!*\
  120650. !*** ./Rendering/edgesRenderer.ts ***!
  120651. \************************************/
  120652. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  120653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120654. "use strict";
  120655. __webpack_require__.r(__webpack_exports__);
  120656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  120657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  120658. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120659. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120660. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120661. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  120662. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120663. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120664. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120665. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  120666. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120667. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  120668. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  120669. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  120670. if (this._edgesRenderer) {
  120671. this._edgesRenderer.dispose();
  120672. this._edgesRenderer = null;
  120673. }
  120674. return this;
  120675. };
  120676. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120677. if (epsilon === void 0) { epsilon = 0.95; }
  120678. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120679. this.disableEdgesRendering();
  120680. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120681. return this;
  120682. };
  120683. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  120684. get: function () {
  120685. return this._edgesRenderer;
  120686. },
  120687. enumerable: true,
  120688. configurable: true
  120689. });
  120690. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120691. if (epsilon === void 0) { epsilon = 0.95; }
  120692. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120693. this.disableEdgesRendering();
  120694. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120695. return this;
  120696. };
  120697. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120698. if (epsilon === void 0) { epsilon = 0.95; }
  120699. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120700. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  120701. return this;
  120702. };
  120703. /**
  120704. * FaceAdjacencies Helper class to generate edges
  120705. */
  120706. var FaceAdjacencies = /** @class */ (function () {
  120707. function FaceAdjacencies() {
  120708. this.edges = new Array();
  120709. this.edgesConnectedCount = 0;
  120710. }
  120711. return FaceAdjacencies;
  120712. }());
  120713. /**
  120714. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  120715. */
  120716. var EdgesRenderer = /** @class */ (function () {
  120717. /**
  120718. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  120719. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  120720. * @param source Mesh used to create edges
  120721. * @param epsilon sum of angles in adjacency to check for edge
  120722. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  120723. * @param generateEdgesLines - should generate Lines or only prepare resources.
  120724. */
  120725. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  120726. if (epsilon === void 0) { epsilon = 0.95; }
  120727. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120728. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  120729. var _this = this;
  120730. /**
  120731. * Define the size of the edges with an orthographic camera
  120732. */
  120733. this.edgesWidthScalerForOrthographic = 1000.0;
  120734. /**
  120735. * Define the size of the edges with a perspective camera
  120736. */
  120737. this.edgesWidthScalerForPerspective = 50.0;
  120738. this._linesPositions = new Array();
  120739. this._linesNormals = new Array();
  120740. this._linesIndices = new Array();
  120741. this._buffers = {};
  120742. this._checkVerticesInsteadOfIndices = false;
  120743. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  120744. this.isEnabled = true;
  120745. this._source = source;
  120746. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  120747. this._epsilon = epsilon;
  120748. this._prepareRessources();
  120749. if (generateEdgesLines) {
  120750. this._generateEdgesLines();
  120751. }
  120752. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  120753. _this._rebuild();
  120754. });
  120755. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  120756. _this.dispose();
  120757. });
  120758. }
  120759. EdgesRenderer.prototype._prepareRessources = function () {
  120760. if (this._lineShader) {
  120761. return;
  120762. }
  120763. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  120764. attributes: ["position", "normal"],
  120765. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  120766. });
  120767. this._lineShader.disableDepthWrite = true;
  120768. this._lineShader.backFaceCulling = false;
  120769. };
  120770. /** @hidden */
  120771. EdgesRenderer.prototype._rebuild = function () {
  120772. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120773. if (buffer) {
  120774. buffer._rebuild();
  120775. }
  120776. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120777. if (buffer) {
  120778. buffer._rebuild();
  120779. }
  120780. var scene = this._source.getScene();
  120781. var engine = scene.getEngine();
  120782. this._ib = engine.createIndexBuffer(this._linesIndices);
  120783. };
  120784. /**
  120785. * Releases the required resources for the edges renderer
  120786. */
  120787. EdgesRenderer.prototype.dispose = function () {
  120788. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  120789. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  120790. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120791. if (buffer) {
  120792. buffer.dispose();
  120793. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120794. }
  120795. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120796. if (buffer) {
  120797. buffer.dispose();
  120798. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  120799. }
  120800. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  120801. this._lineShader.dispose();
  120802. };
  120803. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  120804. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  120805. return 0;
  120806. }
  120807. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  120808. return 1;
  120809. }
  120810. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  120811. return 2;
  120812. }
  120813. return -1;
  120814. };
  120815. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  120816. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  120817. return 0;
  120818. }
  120819. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  120820. return 1;
  120821. }
  120822. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  120823. return 2;
  120824. }
  120825. return -1;
  120826. };
  120827. /**
  120828. * Checks if the pair of p0 and p1 is en edge
  120829. * @param faceIndex
  120830. * @param edge
  120831. * @param faceNormals
  120832. * @param p0
  120833. * @param p1
  120834. * @private
  120835. */
  120836. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  120837. var needToCreateLine;
  120838. if (edge === undefined) {
  120839. needToCreateLine = true;
  120840. }
  120841. else {
  120842. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  120843. needToCreateLine = dotProduct < this._epsilon;
  120844. }
  120845. if (needToCreateLine) {
  120846. this.createLine(p0, p1, this._linesPositions.length / 3);
  120847. }
  120848. };
  120849. /**
  120850. * push line into the position, normal and index buffer
  120851. * @protected
  120852. */
  120853. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  120854. // Positions
  120855. 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);
  120856. // Normals
  120857. 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);
  120858. // Indices
  120859. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  120860. };
  120861. /**
  120862. * Generates lines edges from adjacencjes
  120863. * @private
  120864. */
  120865. EdgesRenderer.prototype._generateEdgesLines = function () {
  120866. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  120867. var indices = this._source.getIndices();
  120868. if (!indices || !positions) {
  120869. return;
  120870. }
  120871. // First let's find adjacencies
  120872. var adjacencies = new Array();
  120873. var faceNormals = new Array();
  120874. var index;
  120875. var faceAdjacencies;
  120876. // Prepare faces
  120877. for (index = 0; index < indices.length; index += 3) {
  120878. faceAdjacencies = new FaceAdjacencies();
  120879. var p0Index = indices[index];
  120880. var p1Index = indices[index + 1];
  120881. var p2Index = indices[index + 2];
  120882. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  120883. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  120884. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  120885. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  120886. faceNormal.normalize();
  120887. faceNormals.push(faceNormal);
  120888. adjacencies.push(faceAdjacencies);
  120889. }
  120890. // Scan
  120891. for (index = 0; index < adjacencies.length; index++) {
  120892. faceAdjacencies = adjacencies[index];
  120893. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  120894. var otherFaceAdjacencies = adjacencies[otherIndex];
  120895. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  120896. break;
  120897. }
  120898. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  120899. continue;
  120900. }
  120901. var otherP0 = indices[otherIndex * 3];
  120902. var otherP1 = indices[otherIndex * 3 + 1];
  120903. var otherP2 = indices[otherIndex * 3 + 2];
  120904. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  120905. var otherEdgeIndex = 0;
  120906. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  120907. continue;
  120908. }
  120909. switch (edgeIndex) {
  120910. case 0:
  120911. if (this._checkVerticesInsteadOfIndices) {
  120912. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120913. }
  120914. else {
  120915. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  120916. }
  120917. break;
  120918. case 1:
  120919. if (this._checkVerticesInsteadOfIndices) {
  120920. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120921. }
  120922. else {
  120923. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  120924. }
  120925. break;
  120926. case 2:
  120927. if (this._checkVerticesInsteadOfIndices) {
  120928. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120929. }
  120930. else {
  120931. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  120932. }
  120933. break;
  120934. }
  120935. if (otherEdgeIndex === -1) {
  120936. continue;
  120937. }
  120938. faceAdjacencies.edges[edgeIndex] = otherIndex;
  120939. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  120940. faceAdjacencies.edgesConnectedCount++;
  120941. otherFaceAdjacencies.edgesConnectedCount++;
  120942. if (faceAdjacencies.edgesConnectedCount === 3) {
  120943. break;
  120944. }
  120945. }
  120946. }
  120947. }
  120948. // Create lines
  120949. for (index = 0; index < adjacencies.length; index++) {
  120950. // 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
  120951. var current = adjacencies[index];
  120952. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  120953. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  120954. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  120955. }
  120956. // Merge into a single mesh
  120957. var engine = this._source.getScene().getEngine();
  120958. 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);
  120959. 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);
  120960. this._ib = engine.createIndexBuffer(this._linesIndices);
  120961. this._indicesCount = this._linesIndices.length;
  120962. };
  120963. /**
  120964. * Checks wether or not the edges renderer is ready to render.
  120965. * @return true if ready, otherwise false.
  120966. */
  120967. EdgesRenderer.prototype.isReady = function () {
  120968. return this._lineShader.isReady();
  120969. };
  120970. /**
  120971. * Renders the edges of the attached mesh,
  120972. */
  120973. EdgesRenderer.prototype.render = function () {
  120974. var scene = this._source.getScene();
  120975. if (!this.isReady() || !scene.activeCamera) {
  120976. return;
  120977. }
  120978. var engine = scene.getEngine();
  120979. this._lineShader._preBind();
  120980. if (this._source.edgesColor.a !== 1) {
  120981. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  120982. }
  120983. else {
  120984. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  120985. }
  120986. // VBOs
  120987. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  120988. scene.resetCachedMaterial();
  120989. this._lineShader.setColor4("color", this._source.edgesColor);
  120990. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  120991. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  120992. }
  120993. else {
  120994. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  120995. }
  120996. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  120997. this._lineShader.bind(this._source.getWorldMatrix());
  120998. // Draw order
  120999. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  121000. this._lineShader.unbind();
  121001. };
  121002. return EdgesRenderer;
  121003. }());
  121004. /**
  121005. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  121006. */
  121007. var LineEdgesRenderer = /** @class */ (function (_super) {
  121008. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  121009. /**
  121010. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  121011. * @param source LineMesh used to generate edges
  121012. * @param epsilon not important (specified angle for edge detection)
  121013. * @param checkVerticesInsteadOfIndices not important for LineMesh
  121014. */
  121015. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  121016. if (epsilon === void 0) { epsilon = 0.95; }
  121017. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  121018. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  121019. _this._generateEdgesLines();
  121020. return _this;
  121021. }
  121022. /**
  121023. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  121024. */
  121025. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  121026. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  121027. var indices = this._source.getIndices();
  121028. if (!indices || !positions) {
  121029. return;
  121030. }
  121031. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  121032. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  121033. var len = indices.length - 1;
  121034. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  121035. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  121036. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  121037. this.createLine(p0, p1, offset);
  121038. }
  121039. // Merge into a single mesh
  121040. var engine = this._source.getScene().getEngine();
  121041. 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);
  121042. 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);
  121043. this._ib = engine.createIndexBuffer(this._linesIndices);
  121044. this._indicesCount = this._linesIndices.length;
  121045. };
  121046. return LineEdgesRenderer;
  121047. }(EdgesRenderer));
  121048. /***/ }),
  121049. /***/ "./Rendering/geometryBufferRenderer.ts":
  121050. /*!*********************************************!*\
  121051. !*** ./Rendering/geometryBufferRenderer.ts ***!
  121052. \*********************************************/
  121053. /*! exports provided: GeometryBufferRenderer */
  121054. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121055. "use strict";
  121056. __webpack_require__.r(__webpack_exports__);
  121057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  121058. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121059. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121060. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121061. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121062. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  121063. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121064. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  121065. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  121066. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  121067. /**
  121068. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  121069. */
  121070. var GeometryBufferRenderer = /** @class */ (function () {
  121071. /**
  121072. * Creates a new G Buffer for the scene
  121073. * @param scene The scene the buffer belongs to
  121074. * @param ratio How big is the buffer related to the main canvas.
  121075. */
  121076. function GeometryBufferRenderer(scene, ratio) {
  121077. if (ratio === void 0) { ratio = 1; }
  121078. /**
  121079. * Dictionary used to store the previous transformation matrices of each rendered mesh
  121080. * in order to compute objects velocities when enableVelocity is set to "true"
  121081. * @hidden
  121082. */
  121083. this._previousTransformationMatrices = {};
  121084. this._enablePosition = false;
  121085. this._enableVelocity = false;
  121086. this._positionIndex = -1;
  121087. this._velocityIndex = -1;
  121088. this._scene = scene;
  121089. this._ratio = ratio;
  121090. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  121091. // Render target
  121092. this._createRenderTargets();
  121093. }
  121094. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  121095. /**
  121096. * Set the render list (meshes to be rendered) used in the G buffer.
  121097. */
  121098. set: function (meshes) {
  121099. this._multiRenderTarget.renderList = meshes;
  121100. },
  121101. enumerable: true,
  121102. configurable: true
  121103. });
  121104. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  121105. /**
  121106. * Gets wether or not G buffer are supported by the running hardware.
  121107. * This requires draw buffer supports
  121108. */
  121109. get: function () {
  121110. return this._multiRenderTarget.isSupported;
  121111. },
  121112. enumerable: true,
  121113. configurable: true
  121114. });
  121115. /**
  121116. * Returns the index of the given texture type in the G-Buffer textures array
  121117. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  121118. * @returns the index of the given texture type in the G-Buffer textures array
  121119. */
  121120. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  121121. switch (textureType) {
  121122. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  121123. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  121124. default: return -1;
  121125. }
  121126. };
  121127. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  121128. /**
  121129. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  121130. */
  121131. get: function () {
  121132. return this._enablePosition;
  121133. },
  121134. /**
  121135. * Sets whether or not objects positions are enabled for the G buffer.
  121136. */
  121137. set: function (enable) {
  121138. this._enablePosition = enable;
  121139. this.dispose();
  121140. this._createRenderTargets();
  121141. },
  121142. enumerable: true,
  121143. configurable: true
  121144. });
  121145. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  121146. /**
  121147. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  121148. */
  121149. get: function () {
  121150. return this._enableVelocity;
  121151. },
  121152. /**
  121153. * Sets wether or not objects velocities are enabled for the G buffer.
  121154. */
  121155. set: function (enable) {
  121156. this._enableVelocity = enable;
  121157. this.dispose();
  121158. this._createRenderTargets();
  121159. },
  121160. enumerable: true,
  121161. configurable: true
  121162. });
  121163. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  121164. /**
  121165. * Gets the scene associated with the buffer.
  121166. */
  121167. get: function () {
  121168. return this._scene;
  121169. },
  121170. enumerable: true,
  121171. configurable: true
  121172. });
  121173. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  121174. /**
  121175. * Gets the ratio used by the buffer during its creation.
  121176. * How big is the buffer related to the main canvas.
  121177. */
  121178. get: function () {
  121179. return this._ratio;
  121180. },
  121181. enumerable: true,
  121182. configurable: true
  121183. });
  121184. /**
  121185. * Checks wether everything is ready to render a submesh to the G buffer.
  121186. * @param subMesh the submesh to check readiness for
  121187. * @param useInstances is the mesh drawn using instance or not
  121188. * @returns true if ready otherwise false
  121189. */
  121190. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  121191. var material = subMesh.getMaterial();
  121192. if (material && material.disableDepthWrite) {
  121193. return false;
  121194. }
  121195. var defines = [];
  121196. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  121197. var mesh = subMesh.getMesh();
  121198. // Alpha test
  121199. if (material && material.needAlphaTesting()) {
  121200. defines.push("#define ALPHATEST");
  121201. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  121202. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  121203. defines.push("#define UV1");
  121204. }
  121205. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  121206. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  121207. defines.push("#define UV2");
  121208. }
  121209. }
  121210. // Buffers
  121211. if (this._enablePosition) {
  121212. defines.push("#define POSITION");
  121213. defines.push("#define POSITION_INDEX " + this._positionIndex);
  121214. }
  121215. if (this._enableVelocity) {
  121216. defines.push("#define VELOCITY");
  121217. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  121218. }
  121219. // Bones
  121220. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121221. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  121222. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  121223. if (mesh.numBoneInfluencers > 4) {
  121224. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  121225. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  121226. }
  121227. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121228. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121229. }
  121230. else {
  121231. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121232. }
  121233. // Instances
  121234. if (useInstances) {
  121235. defines.push("#define INSTANCES");
  121236. attribs.push("world0");
  121237. attribs.push("world1");
  121238. attribs.push("world2");
  121239. attribs.push("world3");
  121240. }
  121241. // Setup textures count
  121242. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  121243. // Get correct effect
  121244. var join = defines.join("\n");
  121245. if (this._cachedDefines !== join) {
  121246. this._cachedDefines = join;
  121247. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  121248. }
  121249. return this._effect.isReady();
  121250. };
  121251. /**
  121252. * Gets the current underlying G Buffer.
  121253. * @returns the buffer
  121254. */
  121255. GeometryBufferRenderer.prototype.getGBuffer = function () {
  121256. return this._multiRenderTarget;
  121257. };
  121258. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  121259. /**
  121260. * Gets the number of samples used to render the buffer (anti aliasing).
  121261. */
  121262. get: function () {
  121263. return this._multiRenderTarget.samples;
  121264. },
  121265. /**
  121266. * Sets the number of samples used to render the buffer (anti aliasing).
  121267. */
  121268. set: function (value) {
  121269. this._multiRenderTarget.samples = value;
  121270. },
  121271. enumerable: true,
  121272. configurable: true
  121273. });
  121274. /**
  121275. * Disposes the renderer and frees up associated resources.
  121276. */
  121277. GeometryBufferRenderer.prototype.dispose = function () {
  121278. this.getGBuffer().dispose();
  121279. };
  121280. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  121281. var _this = this;
  121282. var engine = this._scene.getEngine();
  121283. var count = 2;
  121284. if (this._enablePosition) {
  121285. this._positionIndex = count;
  121286. count++;
  121287. }
  121288. if (this._enableVelocity) {
  121289. this._velocityIndex = count;
  121290. count++;
  121291. }
  121292. 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 });
  121293. if (!this.isSupported) {
  121294. return;
  121295. }
  121296. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  121297. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  121298. this._multiRenderTarget.refreshRate = 1;
  121299. this._multiRenderTarget.renderParticles = false;
  121300. this._multiRenderTarget.renderList = null;
  121301. // set default depth value to 1.0 (far away)
  121302. this._multiRenderTarget.onClearObservable.add(function (engine) {
  121303. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  121304. });
  121305. // Custom render function
  121306. var renderSubMesh = function (subMesh) {
  121307. var mesh = subMesh.getRenderingMesh();
  121308. var scene = _this._scene;
  121309. var engine = scene.getEngine();
  121310. var material = subMesh.getMaterial();
  121311. if (!material) {
  121312. return;
  121313. }
  121314. // Velocity
  121315. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  121316. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  121317. }
  121318. // Culling
  121319. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  121320. // Managing instances
  121321. var batch = mesh._getInstancesRenderList(subMesh._id);
  121322. if (batch.mustReturn) {
  121323. return;
  121324. }
  121325. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  121326. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  121327. engine.enableEffect(_this._effect);
  121328. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121329. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121330. _this._effect.setMatrix("view", scene.getViewMatrix());
  121331. // Alpha test
  121332. if (material && material.needAlphaTesting()) {
  121333. var alphaTexture = material.getAlphaTestTexture();
  121334. if (alphaTexture) {
  121335. _this._effect.setTexture("diffuseSampler", alphaTexture);
  121336. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121337. }
  121338. }
  121339. // Bones
  121340. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121341. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121342. }
  121343. // Velocity
  121344. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  121345. // Draw
  121346. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  121347. }
  121348. // Velocity
  121349. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  121350. };
  121351. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  121352. var index;
  121353. if (depthOnlySubMeshes.length) {
  121354. engine.setColorWrite(false);
  121355. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  121356. renderSubMesh(depthOnlySubMeshes.data[index]);
  121357. }
  121358. engine.setColorWrite(true);
  121359. }
  121360. for (index = 0; index < opaqueSubMeshes.length; index++) {
  121361. renderSubMesh(opaqueSubMeshes.data[index]);
  121362. }
  121363. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  121364. renderSubMesh(alphaTestSubMeshes.data[index]);
  121365. }
  121366. };
  121367. };
  121368. /**
  121369. * Constant used to retrieve the position texture index in the G-Buffer textures array
  121370. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  121371. */
  121372. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  121373. /**
  121374. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  121375. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  121376. */
  121377. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  121378. /** @hidden */
  121379. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  121380. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  121381. };
  121382. return GeometryBufferRenderer;
  121383. }());
  121384. /***/ }),
  121385. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  121386. /*!***********************************************************!*\
  121387. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  121388. \***********************************************************/
  121389. /*! exports provided: GeometryBufferRendererSceneComponent */
  121390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121391. "use strict";
  121392. __webpack_require__.r(__webpack_exports__);
  121393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  121394. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121395. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121396. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121397. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  121398. get: function () {
  121399. this._geometryBufferRenderer;
  121400. },
  121401. set: function (value) {
  121402. if (value && value.isSupported) {
  121403. this._geometryBufferRenderer = value;
  121404. }
  121405. },
  121406. enumerable: true,
  121407. configurable: true
  121408. });
  121409. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  121410. if (ratio === void 0) { ratio = 1; }
  121411. if (this._geometryBufferRenderer) {
  121412. return this._geometryBufferRenderer;
  121413. }
  121414. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  121415. if (!this._geometryBufferRenderer.isSupported) {
  121416. this._geometryBufferRenderer = null;
  121417. }
  121418. return this._geometryBufferRenderer;
  121419. };
  121420. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  121421. if (!this._geometryBufferRenderer) {
  121422. return;
  121423. }
  121424. this._geometryBufferRenderer.dispose();
  121425. this._geometryBufferRenderer = null;
  121426. };
  121427. /**
  121428. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121429. * in several rendering techniques.
  121430. */
  121431. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  121432. /**
  121433. * Creates a new instance of the component for the given scene
  121434. * @param scene Defines the scene to register the component in
  121435. */
  121436. function GeometryBufferRendererSceneComponent(scene) {
  121437. /**
  121438. * The component name helpful to identify the component in the list of scene components.
  121439. */
  121440. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  121441. this.scene = scene;
  121442. }
  121443. /**
  121444. * Registers the component in a given scene
  121445. */
  121446. GeometryBufferRendererSceneComponent.prototype.register = function () {
  121447. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  121448. };
  121449. /**
  121450. * Rebuilds the elements related to this component in case of
  121451. * context lost for instance.
  121452. */
  121453. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  121454. // Nothing to do for this component
  121455. };
  121456. /**
  121457. * Disposes the component and the associated ressources
  121458. */
  121459. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  121460. // Nothing to do for this component
  121461. };
  121462. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  121463. if (this.scene._geometryBufferRenderer) {
  121464. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  121465. }
  121466. };
  121467. return GeometryBufferRendererSceneComponent;
  121468. }());
  121469. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  121470. // Register the G Buffer component to the scene.
  121471. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  121472. if (!component) {
  121473. component = new GeometryBufferRendererSceneComponent(scene);
  121474. scene._addComponent(component);
  121475. }
  121476. };
  121477. /***/ }),
  121478. /***/ "./Rendering/index.ts":
  121479. /*!****************************!*\
  121480. !*** ./Rendering/index.ts ***!
  121481. \****************************/
  121482. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  121483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121484. "use strict";
  121485. __webpack_require__.r(__webpack_exports__);
  121486. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  121487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  121488. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  121489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  121490. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  121491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  121492. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  121493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  121494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  121495. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  121497. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  121498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  121499. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  121500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  121501. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  121502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  121503. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  121504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  121505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  121506. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  121507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  121508. /***/ }),
  121509. /***/ "./Rendering/outlineRenderer.ts":
  121510. /*!**************************************!*\
  121511. !*** ./Rendering/outlineRenderer.ts ***!
  121512. \**************************************/
  121513. /*! exports provided: OutlineRenderer */
  121514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121515. "use strict";
  121516. __webpack_require__.r(__webpack_exports__);
  121517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  121518. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121519. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121520. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121521. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121522. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121523. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121524. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  121525. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  121526. /**
  121527. * Gets the outline renderer associated with the scene
  121528. * @returns a OutlineRenderer
  121529. */
  121530. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  121531. if (!this._outlineRenderer) {
  121532. this._outlineRenderer = new OutlineRenderer(this);
  121533. }
  121534. return this._outlineRenderer;
  121535. };
  121536. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  121537. get: function () {
  121538. return this._renderOutline;
  121539. },
  121540. set: function (value) {
  121541. if (value) {
  121542. // Lazy Load the component.
  121543. this.getScene().getOutlineRenderer();
  121544. }
  121545. this._renderOutline = value;
  121546. },
  121547. enumerable: true,
  121548. configurable: true
  121549. });
  121550. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  121551. get: function () {
  121552. return this._renderOverlay;
  121553. },
  121554. set: function (value) {
  121555. if (value) {
  121556. // Lazy Load the component.
  121557. this.getScene().getOutlineRenderer();
  121558. }
  121559. this._renderOverlay = value;
  121560. },
  121561. enumerable: true,
  121562. configurable: true
  121563. });
  121564. /**
  121565. * This class is responsible to draw bothe outline/overlay of meshes.
  121566. * It should not be used directly but through the available method on mesh.
  121567. */
  121568. var OutlineRenderer = /** @class */ (function () {
  121569. /**
  121570. * Instantiates a new outline renderer. (There could be only one per scene).
  121571. * @param scene Defines the scene it belongs to
  121572. */
  121573. function OutlineRenderer(scene) {
  121574. /**
  121575. * The name of the component. Each component must have a unique name.
  121576. */
  121577. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  121578. /**
  121579. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  121580. */
  121581. this.zOffset = 1;
  121582. this.scene = scene;
  121583. this._engine = scene.getEngine();
  121584. this.scene._addComponent(this);
  121585. }
  121586. /**
  121587. * Register the component to one instance of a scene.
  121588. */
  121589. OutlineRenderer.prototype.register = function () {
  121590. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  121591. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  121592. };
  121593. /**
  121594. * Rebuilds the elements related to this component in case of
  121595. * context lost for instance.
  121596. */
  121597. OutlineRenderer.prototype.rebuild = function () {
  121598. // Nothing to do here.
  121599. };
  121600. /**
  121601. * Disposes the component and the associated ressources.
  121602. */
  121603. OutlineRenderer.prototype.dispose = function () {
  121604. // Nothing to do here.
  121605. };
  121606. /**
  121607. * Renders the outline in the canvas.
  121608. * @param subMesh Defines the sumesh to render
  121609. * @param batch Defines the batch of meshes in case of instances
  121610. * @param useOverlay Defines if the rendering is for the overlay or the outline
  121611. */
  121612. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  121613. var _this = this;
  121614. if (useOverlay === void 0) { useOverlay = false; }
  121615. var scene = this.scene;
  121616. var engine = scene.getEngine();
  121617. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  121618. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  121619. return;
  121620. }
  121621. var mesh = subMesh.getRenderingMesh();
  121622. var material = subMesh.getMaterial();
  121623. if (!material || !scene.activeCamera) {
  121624. return;
  121625. }
  121626. engine.enableEffect(this._effect);
  121627. // Logarithmic depth
  121628. if (material.useLogarithmicDepth) {
  121629. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  121630. }
  121631. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  121632. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  121633. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121634. // Bones
  121635. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121636. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121637. }
  121638. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121639. // Alpha test
  121640. if (material && material.needAlphaTesting()) {
  121641. var alphaTexture = material.getAlphaTestTexture();
  121642. if (alphaTexture) {
  121643. this._effect.setTexture("diffuseSampler", alphaTexture);
  121644. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121645. }
  121646. }
  121647. engine.setZOffset(-this.zOffset);
  121648. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  121649. engine.setZOffset(0);
  121650. };
  121651. /**
  121652. * Returns whether or not the outline renderer is ready for a given submesh.
  121653. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  121654. * @param subMesh Defines the submesh to check readyness for
  121655. * @param useInstances Defines wheter wee are trying to render instances or not
  121656. * @returns true if ready otherwise false
  121657. */
  121658. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  121659. var defines = [];
  121660. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  121661. var mesh = subMesh.getMesh();
  121662. var material = subMesh.getMaterial();
  121663. if (material) {
  121664. // Alpha test
  121665. if (material.needAlphaTesting()) {
  121666. defines.push("#define ALPHATEST");
  121667. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  121668. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  121669. defines.push("#define UV1");
  121670. }
  121671. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  121672. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  121673. defines.push("#define UV2");
  121674. }
  121675. }
  121676. //Logarithmic depth
  121677. if (material.useLogarithmicDepth) {
  121678. defines.push("#define LOGARITHMICDEPTH");
  121679. }
  121680. }
  121681. // Bones
  121682. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121683. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  121684. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  121685. if (mesh.numBoneInfluencers > 4) {
  121686. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  121687. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  121688. }
  121689. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121690. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121691. }
  121692. else {
  121693. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121694. }
  121695. // Instances
  121696. if (useInstances) {
  121697. defines.push("#define INSTANCES");
  121698. attribs.push("world0");
  121699. attribs.push("world1");
  121700. attribs.push("world2");
  121701. attribs.push("world3");
  121702. }
  121703. // Get correct effect
  121704. var join = defines.join("\n");
  121705. if (this._cachedDefines !== join) {
  121706. this._cachedDefines = join;
  121707. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  121708. }
  121709. return this._effect.isReady();
  121710. };
  121711. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  121712. // Outline - step 1
  121713. this._savedDepthWrite = this._engine.getDepthWrite();
  121714. if (mesh.renderOutline) {
  121715. this._engine.setDepthWrite(false);
  121716. this.render(subMesh, batch);
  121717. this._engine.setDepthWrite(this._savedDepthWrite);
  121718. }
  121719. };
  121720. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  121721. // Outline - step 2
  121722. if (mesh.renderOutline && this._savedDepthWrite) {
  121723. this._engine.setDepthWrite(true);
  121724. this._engine.setColorWrite(false);
  121725. this.render(subMesh, batch);
  121726. this._engine.setColorWrite(true);
  121727. }
  121728. // Overlay
  121729. if (mesh.renderOverlay) {
  121730. var currentMode = this._engine.getAlphaMode();
  121731. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  121732. this.render(subMesh, batch, true);
  121733. this._engine.setAlphaMode(currentMode);
  121734. }
  121735. };
  121736. return OutlineRenderer;
  121737. }());
  121738. /***/ }),
  121739. /***/ "./Rendering/renderingGroup.ts":
  121740. /*!*************************************!*\
  121741. !*** ./Rendering/renderingGroup.ts ***!
  121742. \*************************************/
  121743. /*! exports provided: RenderingGroup */
  121744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121745. "use strict";
  121746. __webpack_require__.r(__webpack_exports__);
  121747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  121748. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  121749. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121750. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121751. /**
  121752. * This represents the object necessary to create a rendering group.
  121753. * This is exclusively used and created by the rendering manager.
  121754. * To modify the behavior, you use the available helpers in your scene or meshes.
  121755. * @hidden
  121756. */
  121757. var RenderingGroup = /** @class */ (function () {
  121758. /**
  121759. * Creates a new rendering group.
  121760. * @param index The rendering group index
  121761. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  121762. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  121763. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  121764. */
  121765. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  121766. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  121767. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  121768. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  121769. this.index = index;
  121770. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121771. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121772. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121773. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121774. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121775. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121776. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  121777. this._scene = scene;
  121778. this.opaqueSortCompareFn = opaqueSortCompareFn;
  121779. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  121780. this.transparentSortCompareFn = transparentSortCompareFn;
  121781. }
  121782. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  121783. /**
  121784. * Set the opaque sort comparison function.
  121785. * If null the sub meshes will be render in the order they were created
  121786. */
  121787. set: function (value) {
  121788. this._opaqueSortCompareFn = value;
  121789. if (value) {
  121790. this._renderOpaque = this.renderOpaqueSorted;
  121791. }
  121792. else {
  121793. this._renderOpaque = RenderingGroup.renderUnsorted;
  121794. }
  121795. },
  121796. enumerable: true,
  121797. configurable: true
  121798. });
  121799. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  121800. /**
  121801. * Set the alpha test sort comparison function.
  121802. * If null the sub meshes will be render in the order they were created
  121803. */
  121804. set: function (value) {
  121805. this._alphaTestSortCompareFn = value;
  121806. if (value) {
  121807. this._renderAlphaTest = this.renderAlphaTestSorted;
  121808. }
  121809. else {
  121810. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  121811. }
  121812. },
  121813. enumerable: true,
  121814. configurable: true
  121815. });
  121816. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  121817. /**
  121818. * Set the transparent sort comparison function.
  121819. * If null the sub meshes will be render in the order they were created
  121820. */
  121821. set: function (value) {
  121822. if (value) {
  121823. this._transparentSortCompareFn = value;
  121824. }
  121825. else {
  121826. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  121827. }
  121828. this._renderTransparent = this.renderTransparentSorted;
  121829. },
  121830. enumerable: true,
  121831. configurable: true
  121832. });
  121833. /**
  121834. * Render all the sub meshes contained in the group.
  121835. * @param customRenderFunction Used to override the default render behaviour of the group.
  121836. * @returns true if rendered some submeshes.
  121837. */
  121838. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  121839. if (customRenderFunction) {
  121840. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  121841. return;
  121842. }
  121843. var engine = this._scene.getEngine();
  121844. // Depth only
  121845. if (this._depthOnlySubMeshes.length !== 0) {
  121846. engine.setColorWrite(false);
  121847. this._renderAlphaTest(this._depthOnlySubMeshes);
  121848. engine.setColorWrite(true);
  121849. }
  121850. // Opaque
  121851. if (this._opaqueSubMeshes.length !== 0) {
  121852. this._renderOpaque(this._opaqueSubMeshes);
  121853. }
  121854. // Alpha test
  121855. if (this._alphaTestSubMeshes.length !== 0) {
  121856. this._renderAlphaTest(this._alphaTestSubMeshes);
  121857. }
  121858. var stencilState = engine.getStencilBuffer();
  121859. engine.setStencilBuffer(false);
  121860. // Sprites
  121861. if (renderSprites) {
  121862. this._renderSprites();
  121863. }
  121864. // Particles
  121865. if (renderParticles) {
  121866. this._renderParticles(activeMeshes);
  121867. }
  121868. if (this.onBeforeTransparentRendering) {
  121869. this.onBeforeTransparentRendering();
  121870. }
  121871. // Transparent
  121872. if (this._transparentSubMeshes.length !== 0) {
  121873. this._renderTransparent(this._transparentSubMeshes);
  121874. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121875. }
  121876. // Set back stencil to false in case it changes before the edge renderer.
  121877. engine.setStencilBuffer(false);
  121878. // Edges
  121879. if (this._edgesRenderers.length) {
  121880. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  121881. this._edgesRenderers.data[edgesRendererIndex].render();
  121882. }
  121883. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121884. }
  121885. // Restore Stencil state.
  121886. engine.setStencilBuffer(stencilState);
  121887. };
  121888. /**
  121889. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  121890. * @param subMeshes The submeshes to render
  121891. */
  121892. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  121893. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  121894. };
  121895. /**
  121896. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  121897. * @param subMeshes The submeshes to render
  121898. */
  121899. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  121900. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  121901. };
  121902. /**
  121903. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  121904. * @param subMeshes The submeshes to render
  121905. */
  121906. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  121907. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  121908. };
  121909. /**
  121910. * Renders the submeshes in a specified order.
  121911. * @param subMeshes The submeshes to sort before render
  121912. * @param sortCompareFn The comparison function use to sort
  121913. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  121914. * @param transparent Specifies to activate blending if true
  121915. */
  121916. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  121917. var subIndex = 0;
  121918. var subMesh;
  121919. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  121920. for (; subIndex < subMeshes.length; subIndex++) {
  121921. subMesh = subMeshes.data[subIndex];
  121922. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  121923. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  121924. }
  121925. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  121926. if (sortCompareFn) {
  121927. sortedArray.sort(sortCompareFn);
  121928. }
  121929. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  121930. subMesh = sortedArray[subIndex];
  121931. if (transparent) {
  121932. var material = subMesh.getMaterial();
  121933. if (material && material.needDepthPrePass) {
  121934. var engine = material.getScene().getEngine();
  121935. engine.setColorWrite(false);
  121936. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121937. subMesh.render(false);
  121938. engine.setColorWrite(true);
  121939. }
  121940. }
  121941. subMesh.render(transparent);
  121942. }
  121943. };
  121944. /**
  121945. * Renders the submeshes in the order they were dispatched (no sort applied).
  121946. * @param subMeshes The submeshes to render
  121947. */
  121948. RenderingGroup.renderUnsorted = function (subMeshes) {
  121949. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  121950. var submesh = subMeshes.data[subIndex];
  121951. submesh.render(false);
  121952. }
  121953. };
  121954. /**
  121955. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121956. * are rendered back to front if in the same alpha index.
  121957. *
  121958. * @param a The first submesh
  121959. * @param b The second submesh
  121960. * @returns The result of the comparison
  121961. */
  121962. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  121963. // Alpha index first
  121964. if (a._alphaIndex > b._alphaIndex) {
  121965. return 1;
  121966. }
  121967. if (a._alphaIndex < b._alphaIndex) {
  121968. return -1;
  121969. }
  121970. // Then distance to camera
  121971. return RenderingGroup.backToFrontSortCompare(a, b);
  121972. };
  121973. /**
  121974. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121975. * are rendered back to front.
  121976. *
  121977. * @param a The first submesh
  121978. * @param b The second submesh
  121979. * @returns The result of the comparison
  121980. */
  121981. RenderingGroup.backToFrontSortCompare = function (a, b) {
  121982. // Then distance to camera
  121983. if (a._distanceToCamera < b._distanceToCamera) {
  121984. return 1;
  121985. }
  121986. if (a._distanceToCamera > b._distanceToCamera) {
  121987. return -1;
  121988. }
  121989. return 0;
  121990. };
  121991. /**
  121992. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121993. * are rendered front to back (prevent overdraw).
  121994. *
  121995. * @param a The first submesh
  121996. * @param b The second submesh
  121997. * @returns The result of the comparison
  121998. */
  121999. RenderingGroup.frontToBackSortCompare = function (a, b) {
  122000. // Then distance to camera
  122001. if (a._distanceToCamera < b._distanceToCamera) {
  122002. return -1;
  122003. }
  122004. if (a._distanceToCamera > b._distanceToCamera) {
  122005. return 1;
  122006. }
  122007. return 0;
  122008. };
  122009. /**
  122010. * Resets the different lists of submeshes to prepare a new frame.
  122011. */
  122012. RenderingGroup.prototype.prepare = function () {
  122013. this._opaqueSubMeshes.reset();
  122014. this._transparentSubMeshes.reset();
  122015. this._alphaTestSubMeshes.reset();
  122016. this._depthOnlySubMeshes.reset();
  122017. this._particleSystems.reset();
  122018. this._spriteManagers.reset();
  122019. this._edgesRenderers.reset();
  122020. };
  122021. RenderingGroup.prototype.dispose = function () {
  122022. this._opaqueSubMeshes.dispose();
  122023. this._transparentSubMeshes.dispose();
  122024. this._alphaTestSubMeshes.dispose();
  122025. this._depthOnlySubMeshes.dispose();
  122026. this._particleSystems.dispose();
  122027. this._spriteManagers.dispose();
  122028. this._edgesRenderers.dispose();
  122029. };
  122030. /**
  122031. * Inserts the submesh in its correct queue depending on its material.
  122032. * @param subMesh The submesh to dispatch
  122033. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  122034. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  122035. */
  122036. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  122037. // Get mesh and materials if not provided
  122038. if (mesh === undefined) {
  122039. mesh = subMesh.getMesh();
  122040. }
  122041. if (material === undefined) {
  122042. material = subMesh.getMaterial();
  122043. }
  122044. if (material === null || material === undefined) {
  122045. return;
  122046. }
  122047. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  122048. this._transparentSubMeshes.push(subMesh);
  122049. }
  122050. else if (material.needAlphaTesting()) { // Alpha test
  122051. if (material.needDepthPrePass) {
  122052. this._depthOnlySubMeshes.push(subMesh);
  122053. }
  122054. this._alphaTestSubMeshes.push(subMesh);
  122055. }
  122056. else {
  122057. if (material.needDepthPrePass) {
  122058. this._depthOnlySubMeshes.push(subMesh);
  122059. }
  122060. this._opaqueSubMeshes.push(subMesh); // Opaque
  122061. }
  122062. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  122063. this._edgesRenderers.push(mesh._edgesRenderer);
  122064. }
  122065. };
  122066. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  122067. this._spriteManagers.push(spriteManager);
  122068. };
  122069. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  122070. this._particleSystems.push(particleSystem);
  122071. };
  122072. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  122073. if (this._particleSystems.length === 0) {
  122074. return;
  122075. }
  122076. // Particles
  122077. var activeCamera = this._scene.activeCamera;
  122078. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  122079. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  122080. var particleSystem = this._particleSystems.data[particleIndex];
  122081. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  122082. continue;
  122083. }
  122084. var emitter = particleSystem.emitter;
  122085. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  122086. this._scene._activeParticles.addCount(particleSystem.render(), false);
  122087. }
  122088. }
  122089. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  122090. };
  122091. RenderingGroup.prototype._renderSprites = function () {
  122092. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  122093. return;
  122094. }
  122095. // Sprites
  122096. var activeCamera = this._scene.activeCamera;
  122097. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  122098. for (var id = 0; id < this._spriteManagers.length; id++) {
  122099. var spriteManager = this._spriteManagers.data[id];
  122100. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  122101. spriteManager.render();
  122102. }
  122103. }
  122104. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  122105. };
  122106. return RenderingGroup;
  122107. }());
  122108. /***/ }),
  122109. /***/ "./Rendering/renderingManager.ts":
  122110. /*!***************************************!*\
  122111. !*** ./Rendering/renderingManager.ts ***!
  122112. \***************************************/
  122113. /*! exports provided: RenderingGroupInfo, RenderingManager */
  122114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122115. "use strict";
  122116. __webpack_require__.r(__webpack_exports__);
  122117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  122118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  122119. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  122120. /**
  122121. * This class is used by the onRenderingGroupObservable
  122122. */
  122123. var RenderingGroupInfo = /** @class */ (function () {
  122124. function RenderingGroupInfo() {
  122125. }
  122126. return RenderingGroupInfo;
  122127. }());
  122128. /**
  122129. * This is the manager responsible of all the rendering for meshes sprites and particles.
  122130. * It is enable to manage the different groups as well as the different necessary sort functions.
  122131. * This should not be used directly aside of the few static configurations
  122132. */
  122133. var RenderingManager = /** @class */ (function () {
  122134. /**
  122135. * Instantiates a new rendering group for a particular scene
  122136. * @param scene Defines the scene the groups belongs to
  122137. */
  122138. function RenderingManager(scene) {
  122139. /**
  122140. * @hidden
  122141. */
  122142. this._useSceneAutoClearSetup = false;
  122143. this._renderingGroups = new Array();
  122144. this._autoClearDepthStencil = {};
  122145. this._customOpaqueSortCompareFn = {};
  122146. this._customAlphaTestSortCompareFn = {};
  122147. this._customTransparentSortCompareFn = {};
  122148. this._renderingGroupInfo = new RenderingGroupInfo();
  122149. this._scene = scene;
  122150. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  122151. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  122152. }
  122153. }
  122154. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  122155. if (depth === void 0) { depth = true; }
  122156. if (stencil === void 0) { stencil = true; }
  122157. if (this._depthStencilBufferAlreadyCleaned) {
  122158. return;
  122159. }
  122160. this._scene.getEngine().clear(null, false, depth, stencil);
  122161. this._depthStencilBufferAlreadyCleaned = true;
  122162. };
  122163. /**
  122164. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  122165. * @hidden
  122166. */
  122167. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  122168. // Update the observable context (not null as it only goes away on dispose)
  122169. var info = this._renderingGroupInfo;
  122170. info.scene = this._scene;
  122171. info.camera = this._scene.activeCamera;
  122172. // Dispatch sprites
  122173. if (this._scene.spriteManagers && renderSprites) {
  122174. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  122175. var manager = this._scene.spriteManagers[index];
  122176. this.dispatchSprites(manager);
  122177. }
  122178. }
  122179. // Render
  122180. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122181. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  122182. var renderingGroup = this._renderingGroups[index];
  122183. if (!renderingGroup) {
  122184. continue;
  122185. }
  122186. var renderingGroupMask = Math.pow(2, index);
  122187. info.renderingGroupId = index;
  122188. // Before Observable
  122189. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122190. // Clear depth/stencil if needed
  122191. if (RenderingManager.AUTOCLEAR) {
  122192. var autoClear = this._useSceneAutoClearSetup ?
  122193. this._scene.getAutoClearDepthStencilSetup(index) :
  122194. this._autoClearDepthStencil[index];
  122195. if (autoClear && autoClear.autoClear) {
  122196. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  122197. }
  122198. }
  122199. // Render
  122200. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  122201. var step = _a[_i];
  122202. step.action(index);
  122203. }
  122204. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  122205. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  122206. var step = _c[_b];
  122207. step.action(index);
  122208. }
  122209. // After Observable
  122210. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122211. }
  122212. };
  122213. /**
  122214. * Resets the different information of the group to prepare a new frame
  122215. * @hidden
  122216. */
  122217. RenderingManager.prototype.reset = function () {
  122218. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122219. var renderingGroup = this._renderingGroups[index];
  122220. if (renderingGroup) {
  122221. renderingGroup.prepare();
  122222. }
  122223. }
  122224. };
  122225. /**
  122226. * Dispose and release the group and its associated resources.
  122227. * @hidden
  122228. */
  122229. RenderingManager.prototype.dispose = function () {
  122230. this.freeRenderingGroups();
  122231. this._renderingGroups.length = 0;
  122232. this._renderingGroupInfo = null;
  122233. };
  122234. /**
  122235. * Clear the info related to rendering groups preventing retention points during dispose.
  122236. */
  122237. RenderingManager.prototype.freeRenderingGroups = function () {
  122238. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122239. var renderingGroup = this._renderingGroups[index];
  122240. if (renderingGroup) {
  122241. renderingGroup.dispose();
  122242. }
  122243. }
  122244. };
  122245. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  122246. if (this._renderingGroups[renderingGroupId] === undefined) {
  122247. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  122248. }
  122249. };
  122250. /**
  122251. * Add a sprite manager to the rendering manager in order to render it this frame.
  122252. * @param spriteManager Define the sprite manager to render
  122253. */
  122254. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  122255. var renderingGroupId = spriteManager.renderingGroupId || 0;
  122256. this._prepareRenderingGroup(renderingGroupId);
  122257. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  122258. };
  122259. /**
  122260. * Add a particle system to the rendering manager in order to render it this frame.
  122261. * @param particleSystem Define the particle system to render
  122262. */
  122263. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  122264. var renderingGroupId = particleSystem.renderingGroupId || 0;
  122265. this._prepareRenderingGroup(renderingGroupId);
  122266. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  122267. };
  122268. /**
  122269. * Add a submesh to the manager in order to render it this frame
  122270. * @param subMesh The submesh to dispatch
  122271. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  122272. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  122273. */
  122274. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  122275. if (mesh === undefined) {
  122276. mesh = subMesh.getMesh();
  122277. }
  122278. var renderingGroupId = mesh.renderingGroupId || 0;
  122279. this._prepareRenderingGroup(renderingGroupId);
  122280. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  122281. };
  122282. /**
  122283. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  122284. * This allowed control for front to back rendering or reversly depending of the special needs.
  122285. *
  122286. * @param renderingGroupId The rendering group id corresponding to its index
  122287. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  122288. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  122289. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  122290. */
  122291. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  122292. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  122293. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  122294. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  122295. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  122296. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  122297. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  122298. if (this._renderingGroups[renderingGroupId]) {
  122299. var group = this._renderingGroups[renderingGroupId];
  122300. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  122301. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  122302. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  122303. }
  122304. };
  122305. /**
  122306. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  122307. *
  122308. * @param renderingGroupId The rendering group id corresponding to its index
  122309. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  122310. * @param depth Automatically clears depth between groups if true and autoClear is true.
  122311. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  122312. */
  122313. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  122314. if (depth === void 0) { depth = true; }
  122315. if (stencil === void 0) { stencil = true; }
  122316. this._autoClearDepthStencil[renderingGroupId] = {
  122317. autoClear: autoClearDepthStencil,
  122318. depth: depth,
  122319. stencil: stencil
  122320. };
  122321. };
  122322. /**
  122323. * Gets the current auto clear configuration for one rendering group of the rendering
  122324. * manager.
  122325. * @param index the rendering group index to get the information for
  122326. * @returns The auto clear setup for the requested rendering group
  122327. */
  122328. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  122329. return this._autoClearDepthStencil[index];
  122330. };
  122331. /**
  122332. * The max id used for rendering groups (not included)
  122333. */
  122334. RenderingManager.MAX_RENDERINGGROUPS = 4;
  122335. /**
  122336. * The min id used for rendering groups (included)
  122337. */
  122338. RenderingManager.MIN_RENDERINGGROUPS = 0;
  122339. /**
  122340. * Used to globally prevent autoclearing scenes.
  122341. */
  122342. RenderingManager.AUTOCLEAR = true;
  122343. return RenderingManager;
  122344. }());
  122345. /***/ }),
  122346. /***/ "./Rendering/utilityLayerRenderer.ts":
  122347. /*!*******************************************!*\
  122348. !*** ./Rendering/utilityLayerRenderer.ts ***!
  122349. \*******************************************/
  122350. /*! exports provided: UtilityLayerRenderer */
  122351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122352. "use strict";
  122353. __webpack_require__.r(__webpack_exports__);
  122354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  122355. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122356. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  122357. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  122358. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  122359. /**
  122360. * Renders a layer on top of an existing scene
  122361. */
  122362. var UtilityLayerRenderer = /** @class */ (function () {
  122363. /**
  122364. * Instantiates a UtilityLayerRenderer
  122365. * @param originalScene the original scene that will be rendered on top of
  122366. * @param handleEvents boolean indicating if the utility layer should handle events
  122367. */
  122368. function UtilityLayerRenderer(
  122369. /** the original scene that will be rendered on top of */
  122370. originalScene, handleEvents) {
  122371. if (handleEvents === void 0) { handleEvents = true; }
  122372. var _this = this;
  122373. this.originalScene = originalScene;
  122374. this._pointerCaptures = {};
  122375. this._lastPointerEvents = {};
  122376. /**
  122377. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  122378. */
  122379. this.pickUtilitySceneFirst = true;
  122380. /**
  122381. * If the utility layer should automatically be rendered on top of existing scene
  122382. */
  122383. this.shouldRender = true;
  122384. /**
  122385. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  122386. */
  122387. this.onlyCheckPointerDownEvents = true;
  122388. /**
  122389. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  122390. */
  122391. this.processAllEvents = false;
  122392. /**
  122393. * Observable raised when the pointer move from the utility layer scene to the main scene
  122394. */
  122395. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  122396. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  122397. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  122398. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  122399. this.utilityLayerScene._allowPostProcessClearColor = false;
  122400. originalScene.getEngine().scenes.pop();
  122401. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  122402. this.utilityLayerScene.detachControl();
  122403. if (handleEvents) {
  122404. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  122405. if (!_this.utilityLayerScene.activeCamera) {
  122406. return;
  122407. }
  122408. if (!_this.processAllEvents) {
  122409. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  122410. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  122411. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122412. return;
  122413. }
  122414. }
  122415. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  122416. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  122417. var pointerEvent = (prePointerInfo.event);
  122418. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  122419. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122420. return;
  122421. }
  122422. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  122423. if (!prePointerInfo.ray && utilityScenePick) {
  122424. prePointerInfo.ray = utilityScenePick.ray;
  122425. }
  122426. // always fire the prepointer oversvable
  122427. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  122428. // allow every non pointer down event to flow to the utility layer
  122429. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122430. if (!prePointerInfo.skipOnPointerObservable) {
  122431. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122432. }
  122433. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  122434. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122435. }
  122436. return;
  122437. }
  122438. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  122439. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  122440. if (utilityScenePick && utilityScenePick.hit) {
  122441. if (!prePointerInfo.skipOnPointerObservable) {
  122442. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122443. }
  122444. prePointerInfo.skipOnPointerObservable = true;
  122445. }
  122446. }
  122447. else {
  122448. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  122449. var pointerEvent_1 = (prePointerInfo.event);
  122450. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  122451. if (originalScenePick && utilityScenePick) {
  122452. // No pick in utility scene
  122453. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  122454. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122455. // We touched an utility mesh present in the main scene
  122456. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122457. prePointerInfo.skipOnPointerObservable = true;
  122458. }
  122459. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122460. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  122461. }
  122462. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122463. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122464. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122465. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122466. }
  122467. }
  122468. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  122469. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  122470. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  122471. // If a previous utility layer set this, do not unset this
  122472. if (!prePointerInfo.skipOnPointerObservable) {
  122473. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  122474. }
  122475. }
  122476. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  122477. // We have a pick in both scenes but main is closer than utility
  122478. // We touched an utility mesh present in the main scene
  122479. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122480. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122481. prePointerInfo.skipOnPointerObservable = true;
  122482. }
  122483. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122484. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122485. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122486. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122487. }
  122488. }
  122489. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  122490. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  122491. }
  122492. }
  122493. }
  122494. });
  122495. }
  122496. // Render directly on top of existing scene without clearing
  122497. this.utilityLayerScene.autoClear = false;
  122498. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  122499. if (_this.shouldRender) {
  122500. _this.render();
  122501. }
  122502. });
  122503. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  122504. _this.dispose();
  122505. });
  122506. this._updateCamera();
  122507. }
  122508. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  122509. /**
  122510. * 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)
  122511. */
  122512. get: function () {
  122513. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  122514. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122515. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122516. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122517. });
  122518. }
  122519. return UtilityLayerRenderer._DefaultUtilityLayer;
  122520. },
  122521. enumerable: true,
  122522. configurable: true
  122523. });
  122524. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  122525. /**
  122526. * 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)
  122527. */
  122528. get: function () {
  122529. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  122530. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122531. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  122532. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122533. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122534. });
  122535. }
  122536. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  122537. },
  122538. enumerable: true,
  122539. configurable: true
  122540. });
  122541. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  122542. if (!prePointerInfo.skipOnPointerObservable) {
  122543. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  122544. this._lastPointerEvents[pointerEvent.pointerId] = true;
  122545. }
  122546. };
  122547. /**
  122548. * Renders the utility layers scene on top of the original scene
  122549. */
  122550. UtilityLayerRenderer.prototype.render = function () {
  122551. this._updateCamera();
  122552. if (this.utilityLayerScene.activeCamera) {
  122553. // Set the camera's scene to utility layers scene
  122554. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  122555. var camera = this.utilityLayerScene.activeCamera;
  122556. camera._scene = this.utilityLayerScene;
  122557. if (camera.leftCamera) {
  122558. camera.leftCamera._scene = this.utilityLayerScene;
  122559. }
  122560. if (camera.rightCamera) {
  122561. camera.rightCamera._scene = this.utilityLayerScene;
  122562. }
  122563. this.utilityLayerScene.render(false);
  122564. // Reset camera's scene back to original
  122565. camera._scene = oldScene;
  122566. if (camera.leftCamera) {
  122567. camera.leftCamera._scene = oldScene;
  122568. }
  122569. if (camera.rightCamera) {
  122570. camera.rightCamera._scene = oldScene;
  122571. }
  122572. }
  122573. };
  122574. /**
  122575. * Disposes of the renderer
  122576. */
  122577. UtilityLayerRenderer.prototype.dispose = function () {
  122578. this.onPointerOutObservable.clear();
  122579. if (this._afterRenderObserver) {
  122580. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  122581. }
  122582. if (this._sceneDisposeObserver) {
  122583. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  122584. }
  122585. if (this._originalPointerObserver) {
  122586. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  122587. }
  122588. this.utilityLayerScene.dispose();
  122589. };
  122590. UtilityLayerRenderer.prototype._updateCamera = function () {
  122591. if (this.originalScene.activeCameras.length > 1) {
  122592. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  122593. }
  122594. else {
  122595. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  122596. }
  122597. };
  122598. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122599. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122600. return UtilityLayerRenderer;
  122601. }());
  122602. /***/ }),
  122603. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  122604. /*!*****************************************************************!*\
  122605. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  122606. \*****************************************************************/
  122607. /*! exports provided: backgroundFragmentDeclaration */
  122608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122609. "use strict";
  122610. __webpack_require__.r(__webpack_exports__);
  122611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  122612. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122613. var name = 'backgroundFragmentDeclaration';
  122614. 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";
  122615. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122616. /** @hidden */
  122617. var backgroundFragmentDeclaration = { name: name, shader: shader };
  122618. /***/ }),
  122619. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  122620. /*!************************************************************!*\
  122621. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  122622. \************************************************************/
  122623. /*! exports provided: backgroundUboDeclaration */
  122624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122625. "use strict";
  122626. __webpack_require__.r(__webpack_exports__);
  122627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  122628. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122629. var name = 'backgroundUboDeclaration';
  122630. 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};";
  122631. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122632. /** @hidden */
  122633. var backgroundUboDeclaration = { name: name, shader: shader };
  122634. /***/ }),
  122635. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  122636. /*!***************************************************************!*\
  122637. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  122638. \***************************************************************/
  122639. /*! exports provided: backgroundVertexDeclaration */
  122640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122641. "use strict";
  122642. __webpack_require__.r(__webpack_exports__);
  122643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  122644. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122645. var name = 'backgroundVertexDeclaration';
  122646. 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";
  122647. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122648. /** @hidden */
  122649. var backgroundVertexDeclaration = { name: name, shader: shader };
  122650. /***/ }),
  122651. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  122652. /*!****************************************************!*\
  122653. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  122654. \****************************************************/
  122655. /*! exports provided: bonesDeclaration */
  122656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122657. "use strict";
  122658. __webpack_require__.r(__webpack_exports__);
  122659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  122660. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122661. var name = 'bonesDeclaration';
  122662. 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";
  122663. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122664. /** @hidden */
  122665. var bonesDeclaration = { name: name, shader: shader };
  122666. /***/ }),
  122667. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  122668. /*!***********************************************!*\
  122669. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  122670. \***********************************************/
  122671. /*! exports provided: bonesVertex */
  122672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122673. "use strict";
  122674. __webpack_require__.r(__webpack_exports__);
  122675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  122676. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122677. var name = 'bonesVertex';
  122678. 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";
  122679. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122680. /** @hidden */
  122681. var bonesVertex = { name: name, shader: shader };
  122682. /***/ }),
  122683. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  122684. /*!************************************************!*\
  122685. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  122686. \************************************************/
  122687. /*! exports provided: bumpFragment */
  122688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122689. "use strict";
  122690. __webpack_require__.r(__webpack_exports__);
  122691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  122692. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122693. var name = 'bumpFragment';
  122694. 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";
  122695. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122696. /** @hidden */
  122697. var bumpFragment = { name: name, shader: shader };
  122698. /***/ }),
  122699. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  122700. /*!*********************************************************!*\
  122701. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  122702. \*********************************************************/
  122703. /*! exports provided: bumpFragmentFunctions */
  122704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122705. "use strict";
  122706. __webpack_require__.r(__webpack_exports__);
  122707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  122708. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122709. var name = 'bumpFragmentFunctions';
  122710. 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";
  122711. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122712. /** @hidden */
  122713. var bumpFragmentFunctions = { name: name, shader: shader };
  122714. /***/ }),
  122715. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  122716. /*!**********************************************!*\
  122717. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  122718. \**********************************************/
  122719. /*! exports provided: bumpVertex */
  122720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122721. "use strict";
  122722. __webpack_require__.r(__webpack_exports__);
  122723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  122724. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122725. var name = 'bumpVertex';
  122726. 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";
  122727. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122728. /** @hidden */
  122729. var bumpVertex = { name: name, shader: shader };
  122730. /***/ }),
  122731. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  122732. /*!*********************************************************!*\
  122733. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  122734. \*********************************************************/
  122735. /*! exports provided: bumpVertexDeclaration */
  122736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122737. "use strict";
  122738. __webpack_require__.r(__webpack_exports__);
  122739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  122740. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122741. var name = 'bumpVertexDeclaration';
  122742. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  122743. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122744. /** @hidden */
  122745. var bumpVertexDeclaration = { name: name, shader: shader };
  122746. /***/ }),
  122747. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  122748. /*!*****************************************************!*\
  122749. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  122750. \*****************************************************/
  122751. /*! exports provided: clipPlaneFragment */
  122752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122753. "use strict";
  122754. __webpack_require__.r(__webpack_exports__);
  122755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  122756. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122757. var name = 'clipPlaneFragment';
  122758. 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";
  122759. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122760. /** @hidden */
  122761. var clipPlaneFragment = { name: name, shader: shader };
  122762. /***/ }),
  122763. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  122764. /*!****************************************************************!*\
  122765. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  122766. \****************************************************************/
  122767. /*! exports provided: clipPlaneFragmentDeclaration */
  122768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122769. "use strict";
  122770. __webpack_require__.r(__webpack_exports__);
  122771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  122772. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122773. var name = 'clipPlaneFragmentDeclaration';
  122774. 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";
  122775. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122776. /** @hidden */
  122777. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  122778. /***/ }),
  122779. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  122780. /*!*****************************************************************!*\
  122781. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  122782. \*****************************************************************/
  122783. /*! exports provided: clipPlaneFragmentDeclaration2 */
  122784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122785. "use strict";
  122786. __webpack_require__.r(__webpack_exports__);
  122787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  122788. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122789. var name = 'clipPlaneFragmentDeclaration2';
  122790. 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";
  122791. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122792. /** @hidden */
  122793. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  122794. /***/ }),
  122795. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  122796. /*!***************************************************!*\
  122797. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  122798. \***************************************************/
  122799. /*! exports provided: clipPlaneVertex */
  122800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122801. "use strict";
  122802. __webpack_require__.r(__webpack_exports__);
  122803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  122804. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122805. var name = 'clipPlaneVertex';
  122806. 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";
  122807. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122808. /** @hidden */
  122809. var clipPlaneVertex = { name: name, shader: shader };
  122810. /***/ }),
  122811. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  122812. /*!**************************************************************!*\
  122813. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  122814. \**************************************************************/
  122815. /*! exports provided: clipPlaneVertexDeclaration */
  122816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122817. "use strict";
  122818. __webpack_require__.r(__webpack_exports__);
  122819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  122820. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122821. var name = 'clipPlaneVertexDeclaration';
  122822. 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";
  122823. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122824. /** @hidden */
  122825. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  122826. /***/ }),
  122827. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  122828. /*!***************************************************************!*\
  122829. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  122830. \***************************************************************/
  122831. /*! exports provided: clipPlaneVertexDeclaration2 */
  122832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122833. "use strict";
  122834. __webpack_require__.r(__webpack_exports__);
  122835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  122836. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122837. var name = 'clipPlaneVertexDeclaration2';
  122838. 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";
  122839. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122840. /** @hidden */
  122841. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  122842. /***/ }),
  122843. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  122844. /*!**************************************************************!*\
  122845. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  122846. \**************************************************************/
  122847. /*! exports provided: defaultFragmentDeclaration */
  122848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122849. "use strict";
  122850. __webpack_require__.r(__webpack_exports__);
  122851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  122852. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122853. var name = 'defaultFragmentDeclaration';
  122854. 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";
  122855. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122856. /** @hidden */
  122857. var defaultFragmentDeclaration = { name: name, shader: shader };
  122858. /***/ }),
  122859. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  122860. /*!*********************************************************!*\
  122861. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  122862. \*********************************************************/
  122863. /*! exports provided: defaultUboDeclaration */
  122864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122865. "use strict";
  122866. __webpack_require__.r(__webpack_exports__);
  122867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  122868. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122869. var name = 'defaultUboDeclaration';
  122870. 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};";
  122871. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122872. /** @hidden */
  122873. var defaultUboDeclaration = { name: name, shader: shader };
  122874. /***/ }),
  122875. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  122876. /*!************************************************************!*\
  122877. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  122878. \************************************************************/
  122879. /*! exports provided: defaultVertexDeclaration */
  122880. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122881. "use strict";
  122882. __webpack_require__.r(__webpack_exports__);
  122883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  122884. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122885. var name = 'defaultVertexDeclaration';
  122886. 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";
  122887. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122888. /** @hidden */
  122889. var defaultVertexDeclaration = { name: name, shader: shader };
  122890. /***/ }),
  122891. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  122892. /*!************************************************!*\
  122893. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  122894. \************************************************/
  122895. /*! exports provided: depthPrePass */
  122896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122897. "use strict";
  122898. __webpack_require__.r(__webpack_exports__);
  122899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  122900. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122901. var name = 'depthPrePass';
  122902. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  122903. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122904. /** @hidden */
  122905. var depthPrePass = { name: name, shader: shader };
  122906. /***/ }),
  122907. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  122908. /*!***********************************************!*\
  122909. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  122910. \***********************************************/
  122911. /*! exports provided: fogFragment */
  122912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122913. "use strict";
  122914. __webpack_require__.r(__webpack_exports__);
  122915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  122916. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122917. var name = 'fogFragment';
  122918. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  122919. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122920. /** @hidden */
  122921. var fogFragment = { name: name, shader: shader };
  122922. /***/ }),
  122923. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  122924. /*!**********************************************************!*\
  122925. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  122926. \**********************************************************/
  122927. /*! exports provided: fogFragmentDeclaration */
  122928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122929. "use strict";
  122930. __webpack_require__.r(__webpack_exports__);
  122931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  122932. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122933. var name = 'fogFragmentDeclaration';
  122934. 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";
  122935. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122936. /** @hidden */
  122937. var fogFragmentDeclaration = { name: name, shader: shader };
  122938. /***/ }),
  122939. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  122940. /*!*********************************************!*\
  122941. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  122942. \*********************************************/
  122943. /*! exports provided: fogVertex */
  122944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122945. "use strict";
  122946. __webpack_require__.r(__webpack_exports__);
  122947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  122948. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122949. var name = 'fogVertex';
  122950. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  122951. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122952. /** @hidden */
  122953. var fogVertex = { name: name, shader: shader };
  122954. /***/ }),
  122955. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  122956. /*!********************************************************!*\
  122957. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  122958. \********************************************************/
  122959. /*! exports provided: fogVertexDeclaration */
  122960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122961. "use strict";
  122962. __webpack_require__.r(__webpack_exports__);
  122963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  122964. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122965. var name = 'fogVertexDeclaration';
  122966. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  122967. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122968. /** @hidden */
  122969. var fogVertexDeclaration = { name: name, shader: shader };
  122970. /***/ }),
  122971. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  122972. /*!***************************************************!*\
  122973. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  122974. \***************************************************/
  122975. /*! exports provided: fresnelFunction */
  122976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122977. "use strict";
  122978. __webpack_require__.r(__webpack_exports__);
  122979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  122980. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122981. var name = 'fresnelFunction';
  122982. 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";
  122983. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122984. /** @hidden */
  122985. var fresnelFunction = { name: name, shader: shader };
  122986. /***/ }),
  122987. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  122988. /*!******************************************************!*\
  122989. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  122990. \******************************************************/
  122991. /*! exports provided: harmonicsFunctions */
  122992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122993. "use strict";
  122994. __webpack_require__.r(__webpack_exports__);
  122995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  122996. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122997. var name = 'harmonicsFunctions';
  122998. 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";
  122999. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123000. /** @hidden */
  123001. var harmonicsFunctions = { name: name, shader: shader };
  123002. /***/ }),
  123003. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  123004. /*!***************************************************!*\
  123005. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  123006. \***************************************************/
  123007. /*! exports provided: helperFunctions */
  123008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123009. "use strict";
  123010. __webpack_require__.r(__webpack_exports__);
  123011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  123012. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123013. var name = 'helperFunctions';
  123014. 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}";
  123015. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123016. /** @hidden */
  123017. var helperFunctions = { name: name, shader: shader };
  123018. /***/ }),
  123019. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  123020. /*!**************************************************************!*\
  123021. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  123022. \**************************************************************/
  123023. /*! exports provided: imageProcessingDeclaration */
  123024. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123025. "use strict";
  123026. __webpack_require__.r(__webpack_exports__);
  123027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  123028. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123029. var name = 'imageProcessingDeclaration';
  123030. 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";
  123031. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123032. /** @hidden */
  123033. var imageProcessingDeclaration = { name: name, shader: shader };
  123034. /***/ }),
  123035. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  123036. /*!************************************************************!*\
  123037. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  123038. \************************************************************/
  123039. /*! exports provided: imageProcessingFunctions */
  123040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123041. "use strict";
  123042. __webpack_require__.r(__webpack_exports__);
  123043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  123044. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123045. var name = 'imageProcessingFunctions';
  123046. 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}";
  123047. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123048. /** @hidden */
  123049. var imageProcessingFunctions = { name: name, shader: shader };
  123050. /***/ }),
  123051. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  123052. /*!********************************************************!*\
  123053. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  123054. \********************************************************/
  123055. /*! exports provided: instancesDeclaration */
  123056. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123057. "use strict";
  123058. __webpack_require__.r(__webpack_exports__);
  123059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  123060. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123061. var name = 'instancesDeclaration';
  123062. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  123063. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123064. /** @hidden */
  123065. var instancesDeclaration = { name: name, shader: shader };
  123066. /***/ }),
  123067. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  123068. /*!***************************************************!*\
  123069. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  123070. \***************************************************/
  123071. /*! exports provided: instancesVertex */
  123072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123073. "use strict";
  123074. __webpack_require__.r(__webpack_exports__);
  123075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  123076. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123077. var name = 'instancesVertex';
  123078. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  123079. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123080. /** @hidden */
  123081. var instancesVertex = { name: name, shader: shader };
  123082. /***/ }),
  123083. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  123084. /*!******************************************************!*\
  123085. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  123086. \******************************************************/
  123087. /*! exports provided: kernelBlurFragment */
  123088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123089. "use strict";
  123090. __webpack_require__.r(__webpack_exports__);
  123091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  123092. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123093. var name = 'kernelBlurFragment';
  123094. 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";
  123095. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123096. /** @hidden */
  123097. var kernelBlurFragment = { name: name, shader: shader };
  123098. /***/ }),
  123099. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  123100. /*!*******************************************************!*\
  123101. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  123102. \*******************************************************/
  123103. /*! exports provided: kernelBlurFragment2 */
  123104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123105. "use strict";
  123106. __webpack_require__.r(__webpack_exports__);
  123107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  123108. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123109. var name = 'kernelBlurFragment2';
  123110. 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";
  123111. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123112. /** @hidden */
  123113. var kernelBlurFragment2 = { name: name, shader: shader };
  123114. /***/ }),
  123115. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  123116. /*!****************************************************************!*\
  123117. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  123118. \****************************************************************/
  123119. /*! exports provided: kernelBlurVaryingDeclaration */
  123120. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123121. "use strict";
  123122. __webpack_require__.r(__webpack_exports__);
  123123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  123124. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123125. var name = 'kernelBlurVaryingDeclaration';
  123126. var shader = "varying vec2 sampleCoord{X};";
  123127. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123128. /** @hidden */
  123129. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  123130. /***/ }),
  123131. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  123132. /*!****************************************************!*\
  123133. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  123134. \****************************************************/
  123135. /*! exports provided: kernelBlurVertex */
  123136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123137. "use strict";
  123138. __webpack_require__.r(__webpack_exports__);
  123139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  123140. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123141. var name = 'kernelBlurVertex';
  123142. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  123143. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123144. /** @hidden */
  123145. var kernelBlurVertex = { name: name, shader: shader };
  123146. /***/ }),
  123147. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  123148. /*!*************************************************!*\
  123149. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  123150. \*************************************************/
  123151. /*! exports provided: lightFragment */
  123152. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123153. "use strict";
  123154. __webpack_require__.r(__webpack_exports__);
  123155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  123156. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123157. var name = 'lightFragment';
  123158. 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";
  123159. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123160. /** @hidden */
  123161. var lightFragment = { name: name, shader: shader };
  123162. /***/ }),
  123163. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  123164. /*!************************************************************!*\
  123165. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  123166. \************************************************************/
  123167. /*! exports provided: lightFragmentDeclaration */
  123168. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123169. "use strict";
  123170. __webpack_require__.r(__webpack_exports__);
  123171. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  123172. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123173. var name = 'lightFragmentDeclaration';
  123174. 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";
  123175. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123176. /** @hidden */
  123177. var lightFragmentDeclaration = { name: name, shader: shader };
  123178. /***/ }),
  123179. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  123180. /*!*******************************************************!*\
  123181. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  123182. \*******************************************************/
  123183. /*! exports provided: lightUboDeclaration */
  123184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123185. "use strict";
  123186. __webpack_require__.r(__webpack_exports__);
  123187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  123188. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123189. var name = 'lightUboDeclaration';
  123190. 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";
  123191. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123192. /** @hidden */
  123193. var lightUboDeclaration = { name: name, shader: shader };
  123194. /***/ }),
  123195. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  123196. /*!***********************************************************!*\
  123197. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  123198. \***********************************************************/
  123199. /*! exports provided: lightsFragmentFunctions */
  123200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123201. "use strict";
  123202. __webpack_require__.r(__webpack_exports__);
  123203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  123204. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123205. var name = 'lightsFragmentFunctions';
  123206. 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}";
  123207. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123208. /** @hidden */
  123209. var lightsFragmentFunctions = { name: name, shader: shader };
  123210. /***/ }),
  123211. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  123212. /*!*******************************************************!*\
  123213. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  123214. \*******************************************************/
  123215. /*! exports provided: logDepthDeclaration */
  123216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123217. "use strict";
  123218. __webpack_require__.r(__webpack_exports__);
  123219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  123220. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123221. var name = 'logDepthDeclaration';
  123222. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  123223. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123224. /** @hidden */
  123225. var logDepthDeclaration = { name: name, shader: shader };
  123226. /***/ }),
  123227. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  123228. /*!****************************************************!*\
  123229. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  123230. \****************************************************/
  123231. /*! exports provided: logDepthFragment */
  123232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123233. "use strict";
  123234. __webpack_require__.r(__webpack_exports__);
  123235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  123236. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123237. var name = 'logDepthFragment';
  123238. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  123239. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123240. /** @hidden */
  123241. var logDepthFragment = { name: name, shader: shader };
  123242. /***/ }),
  123243. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  123244. /*!**************************************************!*\
  123245. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  123246. \**************************************************/
  123247. /*! exports provided: logDepthVertex */
  123248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123249. "use strict";
  123250. __webpack_require__.r(__webpack_exports__);
  123251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  123252. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123253. var name = 'logDepthVertex';
  123254. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  123255. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123256. /** @hidden */
  123257. var logDepthVertex = { name: name, shader: shader };
  123258. /***/ }),
  123259. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  123260. /*!******************************************************!*\
  123261. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  123262. \******************************************************/
  123263. /*! exports provided: morphTargetsVertex */
  123264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123265. "use strict";
  123266. __webpack_require__.r(__webpack_exports__);
  123267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  123268. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123269. var name = 'morphTargetsVertex';
  123270. 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";
  123271. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123272. /** @hidden */
  123273. var morphTargetsVertex = { name: name, shader: shader };
  123274. /***/ }),
  123275. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  123276. /*!*****************************************************************!*\
  123277. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  123278. \*****************************************************************/
  123279. /*! exports provided: morphTargetsVertexDeclaration */
  123280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123281. "use strict";
  123282. __webpack_require__.r(__webpack_exports__);
  123283. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  123284. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123285. var name = 'morphTargetsVertexDeclaration';
  123286. 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";
  123287. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123288. /** @hidden */
  123289. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  123290. /***/ }),
  123291. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  123292. /*!***********************************************************************!*\
  123293. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  123294. \***********************************************************************/
  123295. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  123296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123297. "use strict";
  123298. __webpack_require__.r(__webpack_exports__);
  123299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  123300. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123301. var name = 'morphTargetsVertexGlobalDeclaration';
  123302. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  123303. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123304. /** @hidden */
  123305. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  123306. /***/ }),
  123307. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  123308. /*!**********************************************************!*\
  123309. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  123310. \**********************************************************/
  123311. /*! exports provided: mrtFragmentDeclaration */
  123312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123313. "use strict";
  123314. __webpack_require__.r(__webpack_exports__);
  123315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  123316. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123317. var name = 'mrtFragmentDeclaration';
  123318. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  123319. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123320. /** @hidden */
  123321. var mrtFragmentDeclaration = { name: name, shader: shader };
  123322. /***/ }),
  123323. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  123324. /*!**********************************************************!*\
  123325. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  123326. \**********************************************************/
  123327. /*! exports provided: pbrFragmentDeclaration */
  123328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123329. "use strict";
  123330. __webpack_require__.r(__webpack_exports__);
  123331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  123332. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123333. var name = 'pbrFragmentDeclaration';
  123334. 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";
  123335. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123336. /** @hidden */
  123337. var pbrFragmentDeclaration = { name: name, shader: shader };
  123338. /***/ }),
  123339. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  123340. /*!************************************************!*\
  123341. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  123342. \************************************************/
  123343. /*! exports provided: pbrFunctions */
  123344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123345. "use strict";
  123346. __webpack_require__.r(__webpack_exports__);
  123347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  123348. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123349. var name = 'pbrFunctions';
  123350. 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}";
  123351. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123352. /** @hidden */
  123353. var pbrFunctions = { name: name, shader: shader };
  123354. /***/ }),
  123355. /***/ "./Shaders/ShadersInclude/pbrLightFunctions.ts":
  123356. /*!*****************************************************!*\
  123357. !*** ./Shaders/ShadersInclude/pbrLightFunctions.ts ***!
  123358. \*****************************************************/
  123359. /*! exports provided: pbrLightFunctions */
  123360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123361. "use strict";
  123362. __webpack_require__.r(__webpack_exports__);
  123363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightFunctions", function() { return pbrLightFunctions; });
  123364. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123365. var name = 'pbrLightFunctions';
  123366. 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}";
  123367. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123368. /** @hidden */
  123369. var pbrLightFunctions = { name: name, shader: shader };
  123370. /***/ }),
  123371. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  123372. /*!*****************************************************!*\
  123373. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  123374. \*****************************************************/
  123375. /*! exports provided: pbrUboDeclaration */
  123376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123377. "use strict";
  123378. __webpack_require__.r(__webpack_exports__);
  123379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  123380. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123381. var name = 'pbrUboDeclaration';
  123382. 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};";
  123383. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123384. /** @hidden */
  123385. var pbrUboDeclaration = { name: name, shader: shader };
  123386. /***/ }),
  123387. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  123388. /*!********************************************************!*\
  123389. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  123390. \********************************************************/
  123391. /*! exports provided: pbrVertexDeclaration */
  123392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123393. "use strict";
  123394. __webpack_require__.r(__webpack_exports__);
  123395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  123396. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123397. var name = 'pbrVertexDeclaration';
  123398. 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";
  123399. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123400. /** @hidden */
  123401. var pbrVertexDeclaration = { name: name, shader: shader };
  123402. /***/ }),
  123403. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  123404. /*!****************************************************!*\
  123405. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  123406. \****************************************************/
  123407. /*! exports provided: pointCloudVertex */
  123408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123409. "use strict";
  123410. __webpack_require__.r(__webpack_exports__);
  123411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  123412. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123413. var name = 'pointCloudVertex';
  123414. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  123415. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123416. /** @hidden */
  123417. var pointCloudVertex = { name: name, shader: shader };
  123418. /***/ }),
  123419. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  123420. /*!******************************************************!*\
  123421. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  123422. \******************************************************/
  123423. /*! exports provided: reflectionFunction */
  123424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123425. "use strict";
  123426. __webpack_require__.r(__webpack_exports__);
  123427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  123428. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123429. var name = 'reflectionFunction';
  123430. 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}";
  123431. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123432. /** @hidden */
  123433. var reflectionFunction = { name: name, shader: shader };
  123434. /***/ }),
  123435. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  123436. /*!************************************************************!*\
  123437. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  123438. \************************************************************/
  123439. /*! exports provided: shadowsFragmentFunctions */
  123440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123441. "use strict";
  123442. __webpack_require__.r(__webpack_exports__);
  123443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  123444. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123445. var name = 'shadowsFragmentFunctions';
  123446. 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";
  123447. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123448. /** @hidden */
  123449. var shadowsFragmentFunctions = { name: name, shader: shader };
  123450. /***/ }),
  123451. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  123452. /*!*************************************************!*\
  123453. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  123454. \*************************************************/
  123455. /*! exports provided: shadowsVertex */
  123456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123457. "use strict";
  123458. __webpack_require__.r(__webpack_exports__);
  123459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  123460. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123461. var name = 'shadowsVertex';
  123462. 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";
  123463. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123464. /** @hidden */
  123465. var shadowsVertex = { name: name, shader: shader };
  123466. /***/ }),
  123467. /***/ "./Shaders/anaglyph.fragment.ts":
  123468. /*!**************************************!*\
  123469. !*** ./Shaders/anaglyph.fragment.ts ***!
  123470. \**************************************/
  123471. /*! exports provided: anaglyphPixelShader */
  123472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123473. "use strict";
  123474. __webpack_require__.r(__webpack_exports__);
  123475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  123476. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123477. var name = 'anaglyphPixelShader';
  123478. 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}";
  123479. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123480. /** @hidden */
  123481. var anaglyphPixelShader = { name: name, shader: shader };
  123482. /***/ }),
  123483. /***/ "./Shaders/background.fragment.ts":
  123484. /*!****************************************!*\
  123485. !*** ./Shaders/background.fragment.ts ***!
  123486. \****************************************/
  123487. /*! exports provided: backgroundPixelShader */
  123488. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123489. "use strict";
  123490. __webpack_require__.r(__webpack_exports__);
  123491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  123492. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123493. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  123494. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123495. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123496. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123497. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123498. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123499. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123500. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123501. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123502. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123503. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123504. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123505. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123506. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123507. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123508. var name = 'backgroundPixelShader';
  123509. 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";
  123510. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123511. /** @hidden */
  123512. var backgroundPixelShader = { name: name, shader: shader };
  123513. /***/ }),
  123514. /***/ "./Shaders/background.vertex.ts":
  123515. /*!**************************************!*\
  123516. !*** ./Shaders/background.vertex.ts ***!
  123517. \**************************************/
  123518. /*! exports provided: backgroundVertexShader */
  123519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123520. "use strict";
  123521. __webpack_require__.r(__webpack_exports__);
  123522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  123523. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123524. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  123525. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123526. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123527. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123528. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123529. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123530. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123531. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123532. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123533. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123534. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123535. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123536. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123537. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123538. var name = 'backgroundVertexShader';
  123539. 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";
  123540. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123541. /** @hidden */
  123542. var backgroundVertexShader = { name: name, shader: shader };
  123543. /***/ }),
  123544. /***/ "./Shaders/blackAndWhite.fragment.ts":
  123545. /*!*******************************************!*\
  123546. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  123547. \*******************************************/
  123548. /*! exports provided: blackAndWhitePixelShader */
  123549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123550. "use strict";
  123551. __webpack_require__.r(__webpack_exports__);
  123552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  123553. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123554. var name = 'blackAndWhitePixelShader';
  123555. 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}";
  123556. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123557. /** @hidden */
  123558. var blackAndWhitePixelShader = { name: name, shader: shader };
  123559. /***/ }),
  123560. /***/ "./Shaders/bloomMerge.fragment.ts":
  123561. /*!****************************************!*\
  123562. !*** ./Shaders/bloomMerge.fragment.ts ***!
  123563. \****************************************/
  123564. /*! exports provided: bloomMergePixelShader */
  123565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123566. "use strict";
  123567. __webpack_require__.r(__webpack_exports__);
  123568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  123569. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123570. var name = 'bloomMergePixelShader';
  123571. 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";
  123572. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123573. /** @hidden */
  123574. var bloomMergePixelShader = { name: name, shader: shader };
  123575. /***/ }),
  123576. /***/ "./Shaders/chromaticAberration.fragment.ts":
  123577. /*!*************************************************!*\
  123578. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  123579. \*************************************************/
  123580. /*! exports provided: chromaticAberrationPixelShader */
  123581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123582. "use strict";
  123583. __webpack_require__.r(__webpack_exports__);
  123584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  123585. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123586. var name = 'chromaticAberrationPixelShader';
  123587. 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}";
  123588. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123589. /** @hidden */
  123590. var chromaticAberrationPixelShader = { name: name, shader: shader };
  123591. /***/ }),
  123592. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  123593. /*!***********************************************!*\
  123594. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  123595. \***********************************************/
  123596. /*! exports provided: circleOfConfusionPixelShader */
  123597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123598. "use strict";
  123599. __webpack_require__.r(__webpack_exports__);
  123600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  123601. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123602. var name = 'circleOfConfusionPixelShader';
  123603. 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";
  123604. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123605. /** @hidden */
  123606. var circleOfConfusionPixelShader = { name: name, shader: shader };
  123607. /***/ }),
  123608. /***/ "./Shaders/color.fragment.ts":
  123609. /*!***********************************!*\
  123610. !*** ./Shaders/color.fragment.ts ***!
  123611. \***********************************/
  123612. /*! exports provided: colorPixelShader */
  123613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123614. "use strict";
  123615. __webpack_require__.r(__webpack_exports__);
  123616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  123617. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123618. var name = 'colorPixelShader';
  123619. 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}";
  123620. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123621. /** @hidden */
  123622. var colorPixelShader = { name: name, shader: shader };
  123623. /***/ }),
  123624. /***/ "./Shaders/color.vertex.ts":
  123625. /*!*********************************!*\
  123626. !*** ./Shaders/color.vertex.ts ***!
  123627. \*********************************/
  123628. /*! exports provided: colorVertexShader */
  123629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123630. "use strict";
  123631. __webpack_require__.r(__webpack_exports__);
  123632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  123633. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123634. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123635. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123636. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123637. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123638. var name = 'colorVertexShader';
  123639. 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}";
  123640. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123641. /** @hidden */
  123642. var colorVertexShader = { name: name, shader: shader };
  123643. /***/ }),
  123644. /***/ "./Shaders/colorCorrection.fragment.ts":
  123645. /*!*********************************************!*\
  123646. !*** ./Shaders/colorCorrection.fragment.ts ***!
  123647. \*********************************************/
  123648. /*! exports provided: colorCorrectionPixelShader */
  123649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123650. "use strict";
  123651. __webpack_require__.r(__webpack_exports__);
  123652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  123653. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123654. var name = 'colorCorrectionPixelShader';
  123655. 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}";
  123656. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123657. /** @hidden */
  123658. var colorCorrectionPixelShader = { name: name, shader: shader };
  123659. /***/ }),
  123660. /***/ "./Shaders/convolution.fragment.ts":
  123661. /*!*****************************************!*\
  123662. !*** ./Shaders/convolution.fragment.ts ***!
  123663. \*****************************************/
  123664. /*! exports provided: convolutionPixelShader */
  123665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123666. "use strict";
  123667. __webpack_require__.r(__webpack_exports__);
  123668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  123669. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123670. var name = 'convolutionPixelShader';
  123671. 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}";
  123672. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123673. /** @hidden */
  123674. var convolutionPixelShader = { name: name, shader: shader };
  123675. /***/ }),
  123676. /***/ "./Shaders/default.fragment.ts":
  123677. /*!*************************************!*\
  123678. !*** ./Shaders/default.fragment.ts ***!
  123679. \*************************************/
  123680. /*! exports provided: defaultPixelShader */
  123681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123682. "use strict";
  123683. __webpack_require__.r(__webpack_exports__);
  123684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  123685. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123686. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  123687. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123688. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123689. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123690. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123691. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123692. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123693. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  123694. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123695. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123696. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123697. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  123698. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123699. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123700. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123701. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123702. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  123703. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  123704. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123705. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123706. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123707. var name = 'defaultPixelShader';
  123708. 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";
  123709. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123710. /** @hidden */
  123711. var defaultPixelShader = { name: name, shader: shader };
  123712. /***/ }),
  123713. /***/ "./Shaders/default.vertex.ts":
  123714. /*!***********************************!*\
  123715. !*** ./Shaders/default.vertex.ts ***!
  123716. \***********************************/
  123717. /*! exports provided: defaultVertexShader */
  123718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123719. "use strict";
  123720. __webpack_require__.r(__webpack_exports__);
  123721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  123722. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123723. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  123724. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123725. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123726. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123727. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123728. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  123729. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123730. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123731. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123732. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123733. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123734. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123735. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123736. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123737. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123738. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123739. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  123740. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123741. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123742. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123743. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  123744. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123745. var name = 'defaultVertexShader';
  123746. 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";
  123747. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123748. /** @hidden */
  123749. var defaultVertexShader = { name: name, shader: shader };
  123750. /***/ }),
  123751. /***/ "./Shaders/depth.fragment.ts":
  123752. /*!***********************************!*\
  123753. !*** ./Shaders/depth.fragment.ts ***!
  123754. \***********************************/
  123755. /*! exports provided: depthPixelShader */
  123756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123757. "use strict";
  123758. __webpack_require__.r(__webpack_exports__);
  123759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  123760. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123761. var name = 'depthPixelShader';
  123762. 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}";
  123763. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123764. /** @hidden */
  123765. var depthPixelShader = { name: name, shader: shader };
  123766. /***/ }),
  123767. /***/ "./Shaders/depth.vertex.ts":
  123768. /*!*********************************!*\
  123769. !*** ./Shaders/depth.vertex.ts ***!
  123770. \*********************************/
  123771. /*! exports provided: depthVertexShader */
  123772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123773. "use strict";
  123774. __webpack_require__.r(__webpack_exports__);
  123775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  123776. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123777. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123778. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123779. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123780. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123781. var name = 'depthVertexShader';
  123782. 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}";
  123783. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123784. /** @hidden */
  123785. var depthVertexShader = { name: name, shader: shader };
  123786. /***/ }),
  123787. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  123788. /*!******************************************!*\
  123789. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  123790. \******************************************/
  123791. /*! exports provided: depthBoxBlurPixelShader */
  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__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  123796. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123797. var name = 'depthBoxBlurPixelShader';
  123798. 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}";
  123799. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123800. /** @hidden */
  123801. var depthBoxBlurPixelShader = { name: name, shader: shader };
  123802. /***/ }),
  123803. /***/ "./Shaders/depthOfField.fragment.ts":
  123804. /*!******************************************!*\
  123805. !*** ./Shaders/depthOfField.fragment.ts ***!
  123806. \******************************************/
  123807. /*! exports provided: depthOfFieldPixelShader */
  123808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123809. "use strict";
  123810. __webpack_require__.r(__webpack_exports__);
  123811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  123812. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123813. var name = 'depthOfFieldPixelShader';
  123814. 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";
  123815. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123816. /** @hidden */
  123817. var depthOfFieldPixelShader = { name: name, shader: shader };
  123818. /***/ }),
  123819. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  123820. /*!***********************************************!*\
  123821. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  123822. \***********************************************/
  123823. /*! exports provided: depthOfFieldMergePixelShader */
  123824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123825. "use strict";
  123826. __webpack_require__.r(__webpack_exports__);
  123827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  123828. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123829. var name = 'depthOfFieldMergePixelShader';
  123830. 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";
  123831. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123832. /** @hidden */
  123833. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  123834. /***/ }),
  123835. /***/ "./Shaders/displayPass.fragment.ts":
  123836. /*!*****************************************!*\
  123837. !*** ./Shaders/displayPass.fragment.ts ***!
  123838. \*****************************************/
  123839. /*! exports provided: displayPassPixelShader */
  123840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123841. "use strict";
  123842. __webpack_require__.r(__webpack_exports__);
  123843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  123844. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123845. var name = 'displayPassPixelShader';
  123846. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  123847. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123848. /** @hidden */
  123849. var displayPassPixelShader = { name: name, shader: shader };
  123850. /***/ }),
  123851. /***/ "./Shaders/extractHighlights.fragment.ts":
  123852. /*!***********************************************!*\
  123853. !*** ./Shaders/extractHighlights.fragment.ts ***!
  123854. \***********************************************/
  123855. /*! exports provided: extractHighlightsPixelShader */
  123856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123857. "use strict";
  123858. __webpack_require__.r(__webpack_exports__);
  123859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  123860. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123861. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123862. var name = 'extractHighlightsPixelShader';
  123863. 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}";
  123864. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123865. /** @hidden */
  123866. var extractHighlightsPixelShader = { name: name, shader: shader };
  123867. /***/ }),
  123868. /***/ "./Shaders/filter.fragment.ts":
  123869. /*!************************************!*\
  123870. !*** ./Shaders/filter.fragment.ts ***!
  123871. \************************************/
  123872. /*! exports provided: filterPixelShader */
  123873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123874. "use strict";
  123875. __webpack_require__.r(__webpack_exports__);
  123876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  123877. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123878. var name = 'filterPixelShader';
  123879. 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}";
  123880. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123881. /** @hidden */
  123882. var filterPixelShader = { name: name, shader: shader };
  123883. /***/ }),
  123884. /***/ "./Shaders/fxaa.fragment.ts":
  123885. /*!**********************************!*\
  123886. !*** ./Shaders/fxaa.fragment.ts ***!
  123887. \**********************************/
  123888. /*! exports provided: fxaaPixelShader */
  123889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123890. "use strict";
  123891. __webpack_require__.r(__webpack_exports__);
  123892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  123893. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123894. var name = 'fxaaPixelShader';
  123895. 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}";
  123896. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123897. /** @hidden */
  123898. var fxaaPixelShader = { name: name, shader: shader };
  123899. /***/ }),
  123900. /***/ "./Shaders/fxaa.vertex.ts":
  123901. /*!********************************!*\
  123902. !*** ./Shaders/fxaa.vertex.ts ***!
  123903. \********************************/
  123904. /*! exports provided: fxaaVertexShader */
  123905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123906. "use strict";
  123907. __webpack_require__.r(__webpack_exports__);
  123908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  123909. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123910. var name = 'fxaaVertexShader';
  123911. 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}";
  123912. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123913. /** @hidden */
  123914. var fxaaVertexShader = { name: name, shader: shader };
  123915. /***/ }),
  123916. /***/ "./Shaders/geometry.fragment.ts":
  123917. /*!**************************************!*\
  123918. !*** ./Shaders/geometry.fragment.ts ***!
  123919. \**************************************/
  123920. /*! exports provided: geometryPixelShader */
  123921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123922. "use strict";
  123923. __webpack_require__.r(__webpack_exports__);
  123924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  123925. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123926. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  123927. var name = 'geometryPixelShader';
  123928. 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}";
  123929. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123930. /** @hidden */
  123931. var geometryPixelShader = { name: name, shader: shader };
  123932. /***/ }),
  123933. /***/ "./Shaders/geometry.vertex.ts":
  123934. /*!************************************!*\
  123935. !*** ./Shaders/geometry.vertex.ts ***!
  123936. \************************************/
  123937. /*! exports provided: geometryVertexShader */
  123938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123939. "use strict";
  123940. __webpack_require__.r(__webpack_exports__);
  123941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  123942. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123943. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123944. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123945. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123946. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123947. var name = 'geometryVertexShader';
  123948. 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}";
  123949. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123950. /** @hidden */
  123951. var geometryVertexShader = { name: name, shader: shader };
  123952. /***/ }),
  123953. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  123954. /*!*************************************************!*\
  123955. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  123956. \*************************************************/
  123957. /*! exports provided: glowBlurPostProcessPixelShader */
  123958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123959. "use strict";
  123960. __webpack_require__.r(__webpack_exports__);
  123961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  123962. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123963. var name = 'glowBlurPostProcessPixelShader';
  123964. 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}";
  123965. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123966. /** @hidden */
  123967. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  123968. /***/ }),
  123969. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  123970. /*!***********************************************!*\
  123971. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  123972. \***********************************************/
  123973. /*! exports provided: glowMapGenerationPixelShader */
  123974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123975. "use strict";
  123976. __webpack_require__.r(__webpack_exports__);
  123977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  123978. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123979. var name = 'glowMapGenerationPixelShader';
  123980. 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}";
  123981. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123982. /** @hidden */
  123983. var glowMapGenerationPixelShader = { name: name, shader: shader };
  123984. /***/ }),
  123985. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  123986. /*!*********************************************!*\
  123987. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  123988. \*********************************************/
  123989. /*! exports provided: glowMapGenerationVertexShader */
  123990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123991. "use strict";
  123992. __webpack_require__.r(__webpack_exports__);
  123993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  123994. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123995. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123996. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123997. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123998. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123999. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124000. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124001. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124002. var name = 'glowMapGenerationVertexShader';
  124003. 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}";
  124004. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124005. /** @hidden */
  124006. var glowMapGenerationVertexShader = { name: name, shader: shader };
  124007. /***/ }),
  124008. /***/ "./Shaders/glowMapMerge.fragment.ts":
  124009. /*!******************************************!*\
  124010. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  124011. \******************************************/
  124012. /*! exports provided: glowMapMergePixelShader */
  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__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  124017. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124018. var name = 'glowMapMergePixelShader';
  124019. 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}";
  124020. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124021. /** @hidden */
  124022. var glowMapMergePixelShader = { name: name, shader: shader };
  124023. /***/ }),
  124024. /***/ "./Shaders/glowMapMerge.vertex.ts":
  124025. /*!****************************************!*\
  124026. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  124027. \****************************************/
  124028. /*! exports provided: glowMapMergeVertexShader */
  124029. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124030. "use strict";
  124031. __webpack_require__.r(__webpack_exports__);
  124032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  124033. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124034. var name = 'glowMapMergeVertexShader';
  124035. 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}";
  124036. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124037. /** @hidden */
  124038. var glowMapMergeVertexShader = { name: name, shader: shader };
  124039. /***/ }),
  124040. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  124041. /*!************************************************!*\
  124042. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  124043. \************************************************/
  124044. /*! exports provided: gpuRenderParticlesPixelShader */
  124045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124046. "use strict";
  124047. __webpack_require__.r(__webpack_exports__);
  124048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  124049. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124050. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  124051. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124052. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124053. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124054. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124055. var name = 'gpuRenderParticlesPixelShader';
  124056. 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";
  124057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124058. /** @hidden */
  124059. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  124060. /***/ }),
  124061. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  124062. /*!**********************************************!*\
  124063. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  124064. \**********************************************/
  124065. /*! exports provided: gpuRenderParticlesVertexShader */
  124066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124067. "use strict";
  124068. __webpack_require__.r(__webpack_exports__);
  124069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  124070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124071. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  124072. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124073. var name = 'gpuRenderParticlesVertexShader';
  124074. 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}";
  124075. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124076. /** @hidden */
  124077. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  124078. /***/ }),
  124079. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  124080. /*!************************************************!*\
  124081. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  124082. \************************************************/
  124083. /*! exports provided: gpuUpdateParticlesPixelShader */
  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__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  124088. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124089. var name = 'gpuUpdateParticlesPixelShader';
  124090. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  124091. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124092. /** @hidden */
  124093. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  124094. /***/ }),
  124095. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  124096. /*!**********************************************!*\
  124097. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  124098. \**********************************************/
  124099. /*! exports provided: gpuUpdateParticlesVertexShader */
  124100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124101. "use strict";
  124102. __webpack_require__.r(__webpack_exports__);
  124103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  124104. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124105. var name = 'gpuUpdateParticlesVertexShader';
  124106. 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}";
  124107. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124108. /** @hidden */
  124109. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  124110. /***/ }),
  124111. /***/ "./Shaders/grain.fragment.ts":
  124112. /*!***********************************!*\
  124113. !*** ./Shaders/grain.fragment.ts ***!
  124114. \***********************************/
  124115. /*! exports provided: grainPixelShader */
  124116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124117. "use strict";
  124118. __webpack_require__.r(__webpack_exports__);
  124119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  124120. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124121. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124122. var name = 'grainPixelShader';
  124123. 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}";
  124124. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124125. /** @hidden */
  124126. var grainPixelShader = { name: name, shader: shader };
  124127. /***/ }),
  124128. /***/ "./Shaders/highlights.fragment.ts":
  124129. /*!****************************************!*\
  124130. !*** ./Shaders/highlights.fragment.ts ***!
  124131. \****************************************/
  124132. /*! exports provided: highlightsPixelShader */
  124133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124134. "use strict";
  124135. __webpack_require__.r(__webpack_exports__);
  124136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  124137. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124138. var name = 'highlightsPixelShader';
  124139. 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}";
  124140. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124141. /** @hidden */
  124142. var highlightsPixelShader = { name: name, shader: shader };
  124143. /***/ }),
  124144. /***/ "./Shaders/imageProcessing.fragment.ts":
  124145. /*!*********************************************!*\
  124146. !*** ./Shaders/imageProcessing.fragment.ts ***!
  124147. \*********************************************/
  124148. /*! exports provided: imageProcessingPixelShader */
  124149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124150. "use strict";
  124151. __webpack_require__.r(__webpack_exports__);
  124152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  124153. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124154. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124155. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124156. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124157. var name = 'imageProcessingPixelShader';
  124158. 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}";
  124159. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124160. /** @hidden */
  124161. var imageProcessingPixelShader = { name: name, shader: shader };
  124162. /***/ }),
  124163. /***/ "./Shaders/kernelBlur.fragment.ts":
  124164. /*!****************************************!*\
  124165. !*** ./Shaders/kernelBlur.fragment.ts ***!
  124166. \****************************************/
  124167. /*! exports provided: kernelBlurPixelShader */
  124168. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124169. "use strict";
  124170. __webpack_require__.r(__webpack_exports__);
  124171. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  124172. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124173. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124174. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  124175. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  124176. var name = 'kernelBlurPixelShader';
  124177. 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}";
  124178. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124179. /** @hidden */
  124180. var kernelBlurPixelShader = { name: name, shader: shader };
  124181. /***/ }),
  124182. /***/ "./Shaders/kernelBlur.vertex.ts":
  124183. /*!**************************************!*\
  124184. !*** ./Shaders/kernelBlur.vertex.ts ***!
  124185. \**************************************/
  124186. /*! exports provided: kernelBlurVertexShader */
  124187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124188. "use strict";
  124189. __webpack_require__.r(__webpack_exports__);
  124190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  124191. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124192. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124193. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  124194. var name = 'kernelBlurVertexShader';
  124195. 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}";
  124196. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124197. /** @hidden */
  124198. var kernelBlurVertexShader = { name: name, shader: shader };
  124199. /***/ }),
  124200. /***/ "./Shaders/layer.fragment.ts":
  124201. /*!***********************************!*\
  124202. !*** ./Shaders/layer.fragment.ts ***!
  124203. \***********************************/
  124204. /*! exports provided: layerPixelShader */
  124205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124206. "use strict";
  124207. __webpack_require__.r(__webpack_exports__);
  124208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  124209. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124210. var name = 'layerPixelShader';
  124211. 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}";
  124212. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124213. /** @hidden */
  124214. var layerPixelShader = { name: name, shader: shader };
  124215. /***/ }),
  124216. /***/ "./Shaders/layer.vertex.ts":
  124217. /*!*********************************!*\
  124218. !*** ./Shaders/layer.vertex.ts ***!
  124219. \*********************************/
  124220. /*! exports provided: layerVertexShader */
  124221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124222. "use strict";
  124223. __webpack_require__.r(__webpack_exports__);
  124224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  124225. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124226. var name = 'layerVertexShader';
  124227. 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}";
  124228. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124229. /** @hidden */
  124230. var layerVertexShader = { name: name, shader: shader };
  124231. /***/ }),
  124232. /***/ "./Shaders/lensFlare.fragment.ts":
  124233. /*!***************************************!*\
  124234. !*** ./Shaders/lensFlare.fragment.ts ***!
  124235. \***************************************/
  124236. /*! exports provided: lensFlarePixelShader */
  124237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124238. "use strict";
  124239. __webpack_require__.r(__webpack_exports__);
  124240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  124241. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124242. var name = 'lensFlarePixelShader';
  124243. 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}";
  124244. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124245. /** @hidden */
  124246. var lensFlarePixelShader = { name: name, shader: shader };
  124247. /***/ }),
  124248. /***/ "./Shaders/lensFlare.vertex.ts":
  124249. /*!*************************************!*\
  124250. !*** ./Shaders/lensFlare.vertex.ts ***!
  124251. \*************************************/
  124252. /*! exports provided: lensFlareVertexShader */
  124253. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124254. "use strict";
  124255. __webpack_require__.r(__webpack_exports__);
  124256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  124257. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124258. var name = 'lensFlareVertexShader';
  124259. 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}";
  124260. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124261. /** @hidden */
  124262. var lensFlareVertexShader = { name: name, shader: shader };
  124263. /***/ }),
  124264. /***/ "./Shaders/lensHighlights.fragment.ts":
  124265. /*!********************************************!*\
  124266. !*** ./Shaders/lensHighlights.fragment.ts ***!
  124267. \********************************************/
  124268. /*! exports provided: lensHighlightsPixelShader */
  124269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124270. "use strict";
  124271. __webpack_require__.r(__webpack_exports__);
  124272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  124273. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124274. var name = 'lensHighlightsPixelShader';
  124275. 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}";
  124276. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124277. /** @hidden */
  124278. var lensHighlightsPixelShader = { name: name, shader: shader };
  124279. /***/ }),
  124280. /***/ "./Shaders/line.fragment.ts":
  124281. /*!**********************************!*\
  124282. !*** ./Shaders/line.fragment.ts ***!
  124283. \**********************************/
  124284. /*! exports provided: linePixelShader */
  124285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124286. "use strict";
  124287. __webpack_require__.r(__webpack_exports__);
  124288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  124289. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124290. var name = 'linePixelShader';
  124291. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  124292. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124293. /** @hidden */
  124294. var linePixelShader = { name: name, shader: shader };
  124295. /***/ }),
  124296. /***/ "./Shaders/line.vertex.ts":
  124297. /*!********************************!*\
  124298. !*** ./Shaders/line.vertex.ts ***!
  124299. \********************************/
  124300. /*! exports provided: lineVertexShader */
  124301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124302. "use strict";
  124303. __webpack_require__.r(__webpack_exports__);
  124304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  124305. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124306. var name = 'lineVertexShader';
  124307. 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}";
  124308. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124309. /** @hidden */
  124310. var lineVertexShader = { name: name, shader: shader };
  124311. /***/ }),
  124312. /***/ "./Shaders/motionBlur.fragment.ts":
  124313. /*!****************************************!*\
  124314. !*** ./Shaders/motionBlur.fragment.ts ***!
  124315. \****************************************/
  124316. /*! exports provided: motionBlurPixelShader */
  124317. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124318. "use strict";
  124319. __webpack_require__.r(__webpack_exports__);
  124320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  124321. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124322. var name = 'motionBlurPixelShader';
  124323. 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";
  124324. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124325. /** @hidden */
  124326. var motionBlurPixelShader = { name: name, shader: shader };
  124327. /***/ }),
  124328. /***/ "./Shaders/noise.fragment.ts":
  124329. /*!***********************************!*\
  124330. !*** ./Shaders/noise.fragment.ts ***!
  124331. \***********************************/
  124332. /*! exports provided: noisePixelShader */
  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__, "noisePixelShader", function() { return noisePixelShader; });
  124337. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124338. var name = 'noisePixelShader';
  124339. 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";
  124340. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124341. /** @hidden */
  124342. var noisePixelShader = { name: name, shader: shader };
  124343. /***/ }),
  124344. /***/ "./Shaders/outline.fragment.ts":
  124345. /*!*************************************!*\
  124346. !*** ./Shaders/outline.fragment.ts ***!
  124347. \*************************************/
  124348. /*! exports provided: outlinePixelShader */
  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__, "outlinePixelShader", function() { return outlinePixelShader; });
  124353. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124354. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124355. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124356. var name = 'outlinePixelShader';
  124357. 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}";
  124358. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124359. /** @hidden */
  124360. var outlinePixelShader = { name: name, shader: shader };
  124361. /***/ }),
  124362. /***/ "./Shaders/outline.vertex.ts":
  124363. /*!***********************************!*\
  124364. !*** ./Shaders/outline.vertex.ts ***!
  124365. \***********************************/
  124366. /*! exports provided: outlineVertexShader */
  124367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124368. "use strict";
  124369. __webpack_require__.r(__webpack_exports__);
  124370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  124371. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124372. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124373. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124374. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124375. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124376. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124377. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124378. var name = 'outlineVertexShader';
  124379. 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";
  124380. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124381. /** @hidden */
  124382. var outlineVertexShader = { name: name, shader: shader };
  124383. /***/ }),
  124384. /***/ "./Shaders/particles.fragment.ts":
  124385. /*!***************************************!*\
  124386. !*** ./Shaders/particles.fragment.ts ***!
  124387. \***************************************/
  124388. /*! exports provided: particlesPixelShader */
  124389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124390. "use strict";
  124391. __webpack_require__.r(__webpack_exports__);
  124392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  124393. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124394. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124395. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124396. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124397. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124398. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124399. var name = 'particlesPixelShader';
  124400. 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}";
  124401. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124402. /** @hidden */
  124403. var particlesPixelShader = { name: name, shader: shader };
  124404. /***/ }),
  124405. /***/ "./Shaders/particles.vertex.ts":
  124406. /*!*************************************!*\
  124407. !*** ./Shaders/particles.vertex.ts ***!
  124408. \*************************************/
  124409. /*! exports provided: particlesVertexShader */
  124410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124411. "use strict";
  124412. __webpack_require__.r(__webpack_exports__);
  124413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  124414. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124415. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124416. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124417. var name = 'particlesVertexShader';
  124418. 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}";
  124419. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124420. /** @hidden */
  124421. var particlesVertexShader = { name: name, shader: shader };
  124422. /***/ }),
  124423. /***/ "./Shaders/pass.fragment.ts":
  124424. /*!**********************************!*\
  124425. !*** ./Shaders/pass.fragment.ts ***!
  124426. \**********************************/
  124427. /*! exports provided: passPixelShader */
  124428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124429. "use strict";
  124430. __webpack_require__.r(__webpack_exports__);
  124431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  124432. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124433. var name = 'passPixelShader';
  124434. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  124435. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124436. /** @hidden */
  124437. var passPixelShader = { name: name, shader: shader };
  124438. /***/ }),
  124439. /***/ "./Shaders/passCube.fragment.ts":
  124440. /*!**************************************!*\
  124441. !*** ./Shaders/passCube.fragment.ts ***!
  124442. \**************************************/
  124443. /*! exports provided: passCubePixelShader */
  124444. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124445. "use strict";
  124446. __webpack_require__.r(__webpack_exports__);
  124447. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  124448. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124449. var name = 'passCubePixelShader';
  124450. 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}";
  124451. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124452. /** @hidden */
  124453. var passCubePixelShader = { name: name, shader: shader };
  124454. /***/ }),
  124455. /***/ "./Shaders/pbr.fragment.ts":
  124456. /*!*********************************!*\
  124457. !*** ./Shaders/pbr.fragment.ts ***!
  124458. \*********************************/
  124459. /*! exports provided: pbrPixelShader */
  124460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124461. "use strict";
  124462. __webpack_require__.r(__webpack_exports__);
  124463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  124464. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124465. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  124466. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124467. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124468. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124469. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  124470. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124471. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124472. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124473. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  124474. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  124475. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124476. /* harmony import */ var _ShadersInclude_pbrLightFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrLightFunctions */ "./Shaders/ShadersInclude/pbrLightFunctions.ts");
  124477. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  124478. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124479. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124480. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124481. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124482. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  124483. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  124484. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  124485. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124486. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124487. var name = 'pbrPixelShader';
  124488. 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";
  124489. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124490. /** @hidden */
  124491. var pbrPixelShader = { name: name, shader: shader };
  124492. /***/ }),
  124493. /***/ "./Shaders/pbr.vertex.ts":
  124494. /*!*******************************!*\
  124495. !*** ./Shaders/pbr.vertex.ts ***!
  124496. \*******************************/
  124497. /*! exports provided: pbrVertexShader */
  124498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124499. "use strict";
  124500. __webpack_require__.r(__webpack_exports__);
  124501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  124502. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124503. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  124504. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124505. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124506. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124507. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124508. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124509. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  124510. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124511. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124512. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124513. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124514. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124515. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124516. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124517. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124518. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124519. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124520. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  124521. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124522. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  124523. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  124524. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124525. var name = 'pbrVertexShader';
  124526. 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}";
  124527. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124528. /** @hidden */
  124529. var pbrVertexShader = { name: name, shader: shader };
  124530. /***/ }),
  124531. /***/ "./Shaders/postprocess.vertex.ts":
  124532. /*!***************************************!*\
  124533. !*** ./Shaders/postprocess.vertex.ts ***!
  124534. \***************************************/
  124535. /*! exports provided: postprocessVertexShader */
  124536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124537. "use strict";
  124538. __webpack_require__.r(__webpack_exports__);
  124539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  124540. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124541. var name = 'postprocessVertexShader';
  124542. 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}";
  124543. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124544. /** @hidden */
  124545. var postprocessVertexShader = { name: name, shader: shader };
  124546. /***/ }),
  124547. /***/ "./Shaders/procedural.vertex.ts":
  124548. /*!**************************************!*\
  124549. !*** ./Shaders/procedural.vertex.ts ***!
  124550. \**************************************/
  124551. /*! exports provided: proceduralVertexShader */
  124552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124553. "use strict";
  124554. __webpack_require__.r(__webpack_exports__);
  124555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  124556. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124557. var name = 'proceduralVertexShader';
  124558. 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}";
  124559. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124560. /** @hidden */
  124561. var proceduralVertexShader = { name: name, shader: shader };
  124562. /***/ }),
  124563. /***/ "./Shaders/refraction.fragment.ts":
  124564. /*!****************************************!*\
  124565. !*** ./Shaders/refraction.fragment.ts ***!
  124566. \****************************************/
  124567. /*! exports provided: refractionPixelShader */
  124568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124569. "use strict";
  124570. __webpack_require__.r(__webpack_exports__);
  124571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  124572. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124573. var name = 'refractionPixelShader';
  124574. 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}";
  124575. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124576. /** @hidden */
  124577. var refractionPixelShader = { name: name, shader: shader };
  124578. /***/ }),
  124579. /***/ "./Shaders/rgbdDecode.fragment.ts":
  124580. /*!****************************************!*\
  124581. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  124582. \****************************************/
  124583. /*! exports provided: rgbdDecodePixelShader */
  124584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124585. "use strict";
  124586. __webpack_require__.r(__webpack_exports__);
  124587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  124588. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124589. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124590. var name = 'rgbdDecodePixelShader';
  124591. 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}";
  124592. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124593. /** @hidden */
  124594. var rgbdDecodePixelShader = { name: name, shader: shader };
  124595. /***/ }),
  124596. /***/ "./Shaders/rgbdEncode.fragment.ts":
  124597. /*!****************************************!*\
  124598. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  124599. \****************************************/
  124600. /*! exports provided: rgbdEncodePixelShader */
  124601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124602. "use strict";
  124603. __webpack_require__.r(__webpack_exports__);
  124604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  124605. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124606. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124607. var name = 'rgbdEncodePixelShader';
  124608. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  124609. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124610. /** @hidden */
  124611. var rgbdEncodePixelShader = { name: name, shader: shader };
  124612. /***/ }),
  124613. /***/ "./Shaders/shadowMap.fragment.ts":
  124614. /*!***************************************!*\
  124615. !*** ./Shaders/shadowMap.fragment.ts ***!
  124616. \***************************************/
  124617. /*! exports provided: shadowMapPixelShader */
  124618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124619. "use strict";
  124620. __webpack_require__.r(__webpack_exports__);
  124621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  124622. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124623. var name = 'shadowMapPixelShader';
  124624. 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}";
  124625. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124626. /** @hidden */
  124627. var shadowMapPixelShader = { name: name, shader: shader };
  124628. /***/ }),
  124629. /***/ "./Shaders/shadowMap.vertex.ts":
  124630. /*!*************************************!*\
  124631. !*** ./Shaders/shadowMap.vertex.ts ***!
  124632. \*************************************/
  124633. /*! exports provided: shadowMapVertexShader */
  124634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124635. "use strict";
  124636. __webpack_require__.r(__webpack_exports__);
  124637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  124638. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124639. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124640. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124641. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124642. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124643. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124644. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124645. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124646. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124647. var name = 'shadowMapVertexShader';
  124648. 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}";
  124649. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124650. /** @hidden */
  124651. var shadowMapVertexShader = { name: name, shader: shader };
  124652. /***/ }),
  124653. /***/ "./Shaders/sharpen.fragment.ts":
  124654. /*!*************************************!*\
  124655. !*** ./Shaders/sharpen.fragment.ts ***!
  124656. \*************************************/
  124657. /*! exports provided: sharpenPixelShader */
  124658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124659. "use strict";
  124660. __webpack_require__.r(__webpack_exports__);
  124661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  124662. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124663. var name = 'sharpenPixelShader';
  124664. 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}";
  124665. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124666. /** @hidden */
  124667. var sharpenPixelShader = { name: name, shader: shader };
  124668. /***/ }),
  124669. /***/ "./Shaders/sprites.fragment.ts":
  124670. /*!*************************************!*\
  124671. !*** ./Shaders/sprites.fragment.ts ***!
  124672. \*************************************/
  124673. /*! exports provided: spritesPixelShader */
  124674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124675. "use strict";
  124676. __webpack_require__.r(__webpack_exports__);
  124677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  124678. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124679. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124680. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124681. var name = 'spritesPixelShader';
  124682. 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}";
  124683. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124684. /** @hidden */
  124685. var spritesPixelShader = { name: name, shader: shader };
  124686. /***/ }),
  124687. /***/ "./Shaders/sprites.vertex.ts":
  124688. /*!***********************************!*\
  124689. !*** ./Shaders/sprites.vertex.ts ***!
  124690. \***********************************/
  124691. /*! exports provided: spritesVertexShader */
  124692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124693. "use strict";
  124694. __webpack_require__.r(__webpack_exports__);
  124695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  124696. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124697. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124698. var name = 'spritesVertexShader';
  124699. 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}";
  124700. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124701. /** @hidden */
  124702. var spritesVertexShader = { name: name, shader: shader };
  124703. /***/ }),
  124704. /***/ "./Shaders/ssao.fragment.ts":
  124705. /*!**********************************!*\
  124706. !*** ./Shaders/ssao.fragment.ts ***!
  124707. \**********************************/
  124708. /*! exports provided: ssaoPixelShader */
  124709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124710. "use strict";
  124711. __webpack_require__.r(__webpack_exports__);
  124712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  124713. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124714. var name = 'ssaoPixelShader';
  124715. 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";
  124716. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124717. /** @hidden */
  124718. var ssaoPixelShader = { name: name, shader: shader };
  124719. /***/ }),
  124720. /***/ "./Shaders/ssao2.fragment.ts":
  124721. /*!***********************************!*\
  124722. !*** ./Shaders/ssao2.fragment.ts ***!
  124723. \***********************************/
  124724. /*! exports provided: ssao2PixelShader */
  124725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124726. "use strict";
  124727. __webpack_require__.r(__webpack_exports__);
  124728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  124729. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124730. var name = 'ssao2PixelShader';
  124731. 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";
  124732. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124733. /** @hidden */
  124734. var ssao2PixelShader = { name: name, shader: shader };
  124735. /***/ }),
  124736. /***/ "./Shaders/ssaoCombine.fragment.ts":
  124737. /*!*****************************************!*\
  124738. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  124739. \*****************************************/
  124740. /*! exports provided: ssaoCombinePixelShader */
  124741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124742. "use strict";
  124743. __webpack_require__.r(__webpack_exports__);
  124744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  124745. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124746. var name = 'ssaoCombinePixelShader';
  124747. 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";
  124748. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124749. /** @hidden */
  124750. var ssaoCombinePixelShader = { name: name, shader: shader };
  124751. /***/ }),
  124752. /***/ "./Shaders/standard.fragment.ts":
  124753. /*!**************************************!*\
  124754. !*** ./Shaders/standard.fragment.ts ***!
  124755. \**************************************/
  124756. /*! exports provided: standardPixelShader */
  124757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124758. "use strict";
  124759. __webpack_require__.r(__webpack_exports__);
  124760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  124761. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124762. var name = 'standardPixelShader';
  124763. 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";
  124764. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124765. /** @hidden */
  124766. var standardPixelShader = { name: name, shader: shader };
  124767. /***/ }),
  124768. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  124769. /*!***************************************************!*\
  124770. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  124771. \***************************************************/
  124772. /*! exports provided: stereoscopicInterlacePixelShader */
  124773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124774. "use strict";
  124775. __webpack_require__.r(__webpack_exports__);
  124776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  124777. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124778. var name = 'stereoscopicInterlacePixelShader';
  124779. 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}";
  124780. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124781. /** @hidden */
  124782. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  124783. /***/ }),
  124784. /***/ "./Shaders/tonemap.fragment.ts":
  124785. /*!*************************************!*\
  124786. !*** ./Shaders/tonemap.fragment.ts ***!
  124787. \*************************************/
  124788. /*! exports provided: tonemapPixelShader */
  124789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124790. "use strict";
  124791. __webpack_require__.r(__webpack_exports__);
  124792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  124793. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124794. var name = 'tonemapPixelShader';
  124795. 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}";
  124796. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124797. /** @hidden */
  124798. var tonemapPixelShader = { name: name, shader: shader };
  124799. /***/ }),
  124800. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  124801. /*!*******************************************************!*\
  124802. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  124803. \*******************************************************/
  124804. /*! exports provided: volumetricLightScatteringPixelShader */
  124805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124806. "use strict";
  124807. __webpack_require__.r(__webpack_exports__);
  124808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  124809. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124810. var name = 'volumetricLightScatteringPixelShader';
  124811. 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";
  124812. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124813. /** @hidden */
  124814. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  124815. /***/ }),
  124816. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  124817. /*!***********************************************************!*\
  124818. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  124819. \***********************************************************/
  124820. /*! exports provided: volumetricLightScatteringPassPixelShader */
  124821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124822. "use strict";
  124823. __webpack_require__.r(__webpack_exports__);
  124824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  124825. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124826. var name = 'volumetricLightScatteringPassPixelShader';
  124827. 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";
  124828. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124829. /** @hidden */
  124830. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  124831. /***/ }),
  124832. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  124833. /*!****************************************************!*\
  124834. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  124835. \****************************************************/
  124836. /*! exports provided: vrDistortionCorrectionPixelShader */
  124837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124838. "use strict";
  124839. __webpack_require__.r(__webpack_exports__);
  124840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  124841. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124842. var name = 'vrDistortionCorrectionPixelShader';
  124843. 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}";
  124844. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124845. /** @hidden */
  124846. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  124847. /***/ }),
  124848. /***/ "./Sprites/index.ts":
  124849. /*!**************************!*\
  124850. !*** ./Sprites/index.ts ***!
  124851. \**************************/
  124852. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  124853. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124854. "use strict";
  124855. __webpack_require__.r(__webpack_exports__);
  124856. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  124857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  124858. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  124859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  124860. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  124861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  124862. /***/ }),
  124863. /***/ "./Sprites/sprite.ts":
  124864. /*!***************************!*\
  124865. !*** ./Sprites/sprite.ts ***!
  124866. \***************************/
  124867. /*! exports provided: Sprite */
  124868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124869. "use strict";
  124870. __webpack_require__.r(__webpack_exports__);
  124871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  124872. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124873. /**
  124874. * Class used to represent a sprite
  124875. * @see http://doc.babylonjs.com/babylon101/sprites
  124876. */
  124877. var Sprite = /** @class */ (function () {
  124878. /**
  124879. * Creates a new Sprite
  124880. * @param name defines the name
  124881. * @param manager defines the manager
  124882. */
  124883. function Sprite(
  124884. /** defines the name */
  124885. name, manager) {
  124886. this.name = name;
  124887. /** Gets or sets the main color */
  124888. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  124889. /** Gets or sets the width */
  124890. this.width = 1.0;
  124891. /** Gets or sets the height */
  124892. this.height = 1.0;
  124893. /** Gets or sets rotation angle */
  124894. this.angle = 0;
  124895. /** Gets or sets the cell index in the sprite sheet */
  124896. this.cellIndex = 0;
  124897. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  124898. this.invertU = 0;
  124899. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  124900. this.invertV = 0;
  124901. /** Gets the list of attached animations */
  124902. this.animations = new Array();
  124903. /** Gets or sets a boolean indicating if the sprite can be picked */
  124904. this.isPickable = false;
  124905. this._animationStarted = false;
  124906. this._loopAnimation = false;
  124907. this._fromIndex = 0;
  124908. this._toIndex = 0;
  124909. this._delay = 0;
  124910. this._direction = 1;
  124911. this._time = 0;
  124912. /**
  124913. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  124914. */
  124915. this.isVisible = true;
  124916. this._manager = manager;
  124917. this._manager.sprites.push(this);
  124918. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124919. }
  124920. Object.defineProperty(Sprite.prototype, "size", {
  124921. /**
  124922. * Gets or sets the sprite size
  124923. */
  124924. get: function () {
  124925. return this.width;
  124926. },
  124927. set: function (value) {
  124928. this.width = value;
  124929. this.height = value;
  124930. },
  124931. enumerable: true,
  124932. configurable: true
  124933. });
  124934. /**
  124935. * Starts an animation
  124936. * @param from defines the initial key
  124937. * @param to defines the end key
  124938. * @param loop defines if the animation must loop
  124939. * @param delay defines the start delay (in ms)
  124940. * @param onAnimationEnd defines a callback to call when animation ends
  124941. */
  124942. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  124943. this._fromIndex = from;
  124944. this._toIndex = to;
  124945. this._loopAnimation = loop;
  124946. this._delay = delay;
  124947. this._animationStarted = true;
  124948. this._direction = from < to ? 1 : -1;
  124949. this.cellIndex = from;
  124950. this._time = 0;
  124951. this._onAnimationEnd = onAnimationEnd;
  124952. };
  124953. /** Stops current animation (if any) */
  124954. Sprite.prototype.stopAnimation = function () {
  124955. this._animationStarted = false;
  124956. };
  124957. /** @hidden */
  124958. Sprite.prototype._animate = function (deltaTime) {
  124959. if (!this._animationStarted) {
  124960. return;
  124961. }
  124962. this._time += deltaTime;
  124963. if (this._time > this._delay) {
  124964. this._time = this._time % this._delay;
  124965. this.cellIndex += this._direction;
  124966. if (this.cellIndex > this._toIndex) {
  124967. if (this._loopAnimation) {
  124968. this.cellIndex = this._fromIndex;
  124969. }
  124970. else {
  124971. this.cellIndex = this._toIndex;
  124972. this._animationStarted = false;
  124973. if (this._onAnimationEnd) {
  124974. this._onAnimationEnd();
  124975. }
  124976. if (this.disposeWhenFinishedAnimating) {
  124977. this.dispose();
  124978. }
  124979. }
  124980. }
  124981. }
  124982. };
  124983. /** Release associated resources */
  124984. Sprite.prototype.dispose = function () {
  124985. for (var i = 0; i < this._manager.sprites.length; i++) {
  124986. if (this._manager.sprites[i] == this) {
  124987. this._manager.sprites.splice(i, 1);
  124988. }
  124989. }
  124990. };
  124991. return Sprite;
  124992. }());
  124993. /***/ }),
  124994. /***/ "./Sprites/spriteManager.ts":
  124995. /*!**********************************!*\
  124996. !*** ./Sprites/spriteManager.ts ***!
  124997. \**********************************/
  124998. /*! exports provided: SpriteManager */
  124999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125000. "use strict";
  125001. __webpack_require__.r(__webpack_exports__);
  125002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  125003. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125004. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  125005. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125006. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125007. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  125008. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  125009. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125010. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125011. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125012. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125013. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  125014. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  125015. /**
  125016. * Class used to manage multiple sprites on the same spritesheet
  125017. * @see http://doc.babylonjs.com/babylon101/sprites
  125018. */
  125019. var SpriteManager = /** @class */ (function () {
  125020. /**
  125021. * Creates a new sprite manager
  125022. * @param name defines the manager's name
  125023. * @param imgUrl defines the sprite sheet url
  125024. * @param capacity defines the maximum allowed number of sprites
  125025. * @param cellSize defines the size of a sprite cell
  125026. * @param scene defines the hosting scene
  125027. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  125028. * @param samplingMode defines the smapling mode to use with spritesheet
  125029. */
  125030. function SpriteManager(
  125031. /** defines the manager's name */
  125032. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  125033. if (epsilon === void 0) { epsilon = 0.01; }
  125034. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  125035. this.name = name;
  125036. /** Gets the list of sprites */
  125037. this.sprites = new Array();
  125038. /** Gets or sets the rendering group id (0 by default) */
  125039. this.renderingGroupId = 0;
  125040. /** Gets or sets camera layer mask */
  125041. this.layerMask = 0x0FFFFFFF;
  125042. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  125043. this.fogEnabled = true;
  125044. /** Gets or sets a boolean indicating if the sprites are pickable */
  125045. this.isPickable = false;
  125046. /**
  125047. * An event triggered when the manager is disposed.
  125048. */
  125049. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  125050. this._vertexBuffers = {};
  125051. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  125052. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  125053. }
  125054. this._capacity = capacity;
  125055. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  125056. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  125057. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  125058. if (cellSize.width && cellSize.height) {
  125059. this.cellWidth = cellSize.width;
  125060. this.cellHeight = cellSize.height;
  125061. }
  125062. else if (cellSize !== undefined) {
  125063. this.cellWidth = cellSize;
  125064. this.cellHeight = cellSize;
  125065. }
  125066. else {
  125067. return;
  125068. }
  125069. this._epsilon = epsilon;
  125070. this._scene = scene;
  125071. this._scene.spriteManagers.push(this);
  125072. var indices = [];
  125073. var index = 0;
  125074. for (var count = 0; count < capacity; count++) {
  125075. indices.push(index);
  125076. indices.push(index + 1);
  125077. indices.push(index + 2);
  125078. indices.push(index);
  125079. indices.push(index + 2);
  125080. indices.push(index + 3);
  125081. index += 4;
  125082. }
  125083. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  125084. // VBO
  125085. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  125086. this._vertexData = new Float32Array(capacity * 16 * 4);
  125087. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  125088. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  125089. var options = this._buffer.createVertexBuffer("options", 4, 4);
  125090. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  125091. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  125092. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  125093. this._vertexBuffers["options"] = options;
  125094. this._vertexBuffers["cellInfo"] = cellInfo;
  125095. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  125096. // Effects
  125097. 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"], "");
  125098. 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");
  125099. }
  125100. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  125101. /**
  125102. * Callback called when the manager is disposed
  125103. */
  125104. set: function (callback) {
  125105. if (this._onDisposeObserver) {
  125106. this.onDisposeObservable.remove(this._onDisposeObserver);
  125107. }
  125108. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  125109. },
  125110. enumerable: true,
  125111. configurable: true
  125112. });
  125113. Object.defineProperty(SpriteManager.prototype, "texture", {
  125114. /**
  125115. * Gets or sets the spritesheet texture
  125116. */
  125117. get: function () {
  125118. return this._spriteTexture;
  125119. },
  125120. set: function (value) {
  125121. this._spriteTexture = value;
  125122. },
  125123. enumerable: true,
  125124. configurable: true
  125125. });
  125126. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  125127. var arrayOffset = index * 16;
  125128. if (offsetX === 0) {
  125129. offsetX = this._epsilon;
  125130. }
  125131. else if (offsetX === 1) {
  125132. offsetX = 1 - this._epsilon;
  125133. }
  125134. if (offsetY === 0) {
  125135. offsetY = this._epsilon;
  125136. }
  125137. else if (offsetY === 1) {
  125138. offsetY = 1 - this._epsilon;
  125139. }
  125140. this._vertexData[arrayOffset] = sprite.position.x;
  125141. this._vertexData[arrayOffset + 1] = sprite.position.y;
  125142. this._vertexData[arrayOffset + 2] = sprite.position.z;
  125143. this._vertexData[arrayOffset + 3] = sprite.angle;
  125144. this._vertexData[arrayOffset + 4] = sprite.width;
  125145. this._vertexData[arrayOffset + 5] = sprite.height;
  125146. this._vertexData[arrayOffset + 6] = offsetX;
  125147. this._vertexData[arrayOffset + 7] = offsetY;
  125148. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  125149. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  125150. var offset = (sprite.cellIndex / rowSize) >> 0;
  125151. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  125152. this._vertexData[arrayOffset + 11] = offset;
  125153. // Color
  125154. this._vertexData[arrayOffset + 12] = sprite.color.r;
  125155. this._vertexData[arrayOffset + 13] = sprite.color.g;
  125156. this._vertexData[arrayOffset + 14] = sprite.color.b;
  125157. this._vertexData[arrayOffset + 15] = sprite.color.a;
  125158. };
  125159. /**
  125160. * Intersects the sprites with a ray
  125161. * @param ray defines the ray to intersect with
  125162. * @param camera defines the current active camera
  125163. * @param predicate defines a predicate used to select candidate sprites
  125164. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  125165. * @returns null if no hit or a PickingInfo
  125166. */
  125167. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  125168. var count = Math.min(this._capacity, this.sprites.length);
  125169. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125170. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125171. var distance = Number.MAX_VALUE;
  125172. var currentSprite = null;
  125173. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125174. var cameraView = camera.getViewMatrix();
  125175. for (var index = 0; index < count; index++) {
  125176. var sprite = this.sprites[index];
  125177. if (!sprite) {
  125178. continue;
  125179. }
  125180. if (predicate) {
  125181. if (!predicate(sprite)) {
  125182. continue;
  125183. }
  125184. }
  125185. else if (!sprite.isPickable) {
  125186. continue;
  125187. }
  125188. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  125189. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  125190. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  125191. if (ray.intersectsBoxMinMax(min, max)) {
  125192. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  125193. if (distance > currentDistance) {
  125194. distance = currentDistance;
  125195. currentSprite = sprite;
  125196. if (fastCheck) {
  125197. break;
  125198. }
  125199. }
  125200. }
  125201. }
  125202. if (currentSprite) {
  125203. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  125204. result.hit = true;
  125205. result.pickedSprite = currentSprite;
  125206. result.distance = distance;
  125207. return result;
  125208. }
  125209. return null;
  125210. };
  125211. /**
  125212. * Render all child sprites
  125213. */
  125214. SpriteManager.prototype.render = function () {
  125215. // Check
  125216. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  125217. || !this._spriteTexture.isReady() || !this.sprites.length) {
  125218. return;
  125219. }
  125220. var engine = this._scene.getEngine();
  125221. var baseSize = this._spriteTexture.getBaseSize();
  125222. // Sprites
  125223. var deltaTime = engine.getDeltaTime();
  125224. var max = Math.min(this._capacity, this.sprites.length);
  125225. var rowSize = baseSize.width / this.cellWidth;
  125226. var offset = 0;
  125227. for (var index = 0; index < max; index++) {
  125228. var sprite = this.sprites[index];
  125229. if (!sprite || !sprite.isVisible) {
  125230. continue;
  125231. }
  125232. sprite._animate(deltaTime);
  125233. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  125234. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  125235. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  125236. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  125237. }
  125238. this._buffer.update(this._vertexData);
  125239. // Render
  125240. var effect = this._effectBase;
  125241. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  125242. effect = this._effectFog;
  125243. }
  125244. engine.enableEffect(effect);
  125245. var viewMatrix = this._scene.getViewMatrix();
  125246. effect.setTexture("diffuseSampler", this._spriteTexture);
  125247. effect.setMatrix("view", viewMatrix);
  125248. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  125249. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  125250. // Fog
  125251. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  125252. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  125253. effect.setColor3("vFogColor", this._scene.fogColor);
  125254. }
  125255. // VBOs
  125256. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125257. // Draw order
  125258. engine.setDepthFunctionToLessOrEqual();
  125259. effect.setBool("alphaTest", true);
  125260. engine.setColorWrite(false);
  125261. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  125262. engine.setColorWrite(true);
  125263. effect.setBool("alphaTest", false);
  125264. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  125265. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  125266. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  125267. };
  125268. /**
  125269. * Release associated resources
  125270. */
  125271. SpriteManager.prototype.dispose = function () {
  125272. if (this._buffer) {
  125273. this._buffer.dispose();
  125274. this._buffer = null;
  125275. }
  125276. if (this._indexBuffer) {
  125277. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  125278. this._indexBuffer = null;
  125279. }
  125280. if (this._spriteTexture) {
  125281. this._spriteTexture.dispose();
  125282. this._spriteTexture = null;
  125283. }
  125284. // Remove from scene
  125285. var index = this._scene.spriteManagers.indexOf(this);
  125286. this._scene.spriteManagers.splice(index, 1);
  125287. // Callback
  125288. this.onDisposeObservable.notifyObservers(this);
  125289. this.onDisposeObservable.clear();
  125290. };
  125291. return SpriteManager;
  125292. }());
  125293. /***/ }),
  125294. /***/ "./Sprites/spriteSceneComponent.ts":
  125295. /*!*****************************************!*\
  125296. !*** ./Sprites/spriteSceneComponent.ts ***!
  125297. \*****************************************/
  125298. /*! exports provided: SpriteSceneComponent */
  125299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125300. "use strict";
  125301. __webpack_require__.r(__webpack_exports__);
  125302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  125303. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  125304. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125305. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  125306. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  125307. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125308. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  125309. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125310. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  125311. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  125312. return null;
  125313. }
  125314. var pickingInfo = null;
  125315. if (!camera) {
  125316. if (!this.activeCamera) {
  125317. return null;
  125318. }
  125319. camera = this.activeCamera;
  125320. }
  125321. if (this.spriteManagers.length > 0) {
  125322. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  125323. var spriteManager = this.spriteManagers[spriteIndex];
  125324. if (!spriteManager.isPickable) {
  125325. continue;
  125326. }
  125327. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  125328. if (!result || !result.hit) {
  125329. continue;
  125330. }
  125331. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  125332. continue;
  125333. }
  125334. pickingInfo = result;
  125335. if (fastCheck) {
  125336. break;
  125337. }
  125338. }
  125339. }
  125340. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  125341. };
  125342. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  125343. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  125344. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  125345. };
  125346. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  125347. if (!this._tempSpritePickingRay) {
  125348. return null;
  125349. }
  125350. if (!camera) {
  125351. if (!this.activeCamera) {
  125352. return null;
  125353. }
  125354. camera = this.activeCamera;
  125355. }
  125356. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  125357. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  125358. };
  125359. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  125360. if (this._pointerOverSprite === sprite) {
  125361. return;
  125362. }
  125363. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  125364. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  125365. }
  125366. this._pointerOverSprite = sprite;
  125367. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  125368. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  125369. }
  125370. };
  125371. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  125372. return this._pointerOverSprite;
  125373. };
  125374. /**
  125375. * Defines the sprite scene component responsible to manage sprites
  125376. * in a given scene.
  125377. */
  125378. var SpriteSceneComponent = /** @class */ (function () {
  125379. /**
  125380. * Creates a new instance of the component for the given scene
  125381. * @param scene Defines the scene to register the component in
  125382. */
  125383. function SpriteSceneComponent(scene) {
  125384. /**
  125385. * The component name helpfull to identify the component in the list of scene components.
  125386. */
  125387. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  125388. this.scene = scene;
  125389. this.scene.spriteManagers = new Array();
  125390. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  125391. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125392. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125393. this._spritePredicate = function (sprite) {
  125394. if (!sprite.actionManager) {
  125395. return false;
  125396. }
  125397. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  125398. };
  125399. }
  125400. /**
  125401. * Registers the component in a given scene
  125402. */
  125403. SpriteSceneComponent.prototype.register = function () {
  125404. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  125405. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  125406. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  125407. };
  125408. /**
  125409. * Rebuilds the elements related to this component in case of
  125410. * context lost for instance.
  125411. */
  125412. SpriteSceneComponent.prototype.rebuild = function () {
  125413. /** Nothing to do for sprites */
  125414. };
  125415. /**
  125416. * Disposes the component and the associated ressources.
  125417. */
  125418. SpriteSceneComponent.prototype.dispose = function () {
  125419. this.scene.onBeforeSpritesRenderingObservable.clear();
  125420. this.scene.onAfterSpritesRenderingObservable.clear();
  125421. var spriteManagers = this.scene.spriteManagers;
  125422. while (spriteManagers.length) {
  125423. spriteManagers[0].dispose();
  125424. }
  125425. };
  125426. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  125427. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  125428. if (result) {
  125429. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  125430. }
  125431. return result;
  125432. };
  125433. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  125434. var scene = this.scene;
  125435. if (isMeshPicked) {
  125436. scene.setPointerOverSprite(null);
  125437. }
  125438. else {
  125439. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  125440. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125441. scene.setPointerOverSprite(pickResult.pickedSprite);
  125442. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  125443. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  125444. }
  125445. else {
  125446. canvas.style.cursor = scene.hoverCursor;
  125447. }
  125448. }
  125449. else {
  125450. scene.setPointerOverSprite(null);
  125451. }
  125452. }
  125453. return pickResult;
  125454. };
  125455. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125456. var scene = this.scene;
  125457. scene._pickedDownSprite = null;
  125458. if (scene.spriteManagers.length > 0) {
  125459. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125460. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125461. if (pickResult.pickedSprite.actionManager) {
  125462. scene._pickedDownSprite = pickResult.pickedSprite;
  125463. switch (evt.button) {
  125464. case 0:
  125465. 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));
  125466. break;
  125467. case 1:
  125468. 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));
  125469. break;
  125470. case 2:
  125471. 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));
  125472. break;
  125473. }
  125474. if (pickResult.pickedSprite.actionManager) {
  125475. 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));
  125476. }
  125477. }
  125478. }
  125479. }
  125480. return pickResult;
  125481. };
  125482. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125483. var scene = this.scene;
  125484. if (scene.spriteManagers.length > 0) {
  125485. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125486. if (spritePickResult) {
  125487. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  125488. if (spritePickResult.pickedSprite.actionManager) {
  125489. 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));
  125490. if (spritePickResult.pickedSprite.actionManager) {
  125491. if (!this.scene._isPointerSwiping()) {
  125492. 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));
  125493. }
  125494. }
  125495. }
  125496. }
  125497. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  125498. 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));
  125499. }
  125500. }
  125501. }
  125502. return pickResult;
  125503. };
  125504. return SpriteSceneComponent;
  125505. }());
  125506. /***/ }),
  125507. /***/ "./States/alphaCullingState.ts":
  125508. /*!*************************************!*\
  125509. !*** ./States/alphaCullingState.ts ***!
  125510. \*************************************/
  125511. /*! exports provided: _AlphaState */
  125512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125513. "use strict";
  125514. __webpack_require__.r(__webpack_exports__);
  125515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  125516. /**
  125517. * @hidden
  125518. **/
  125519. var _AlphaState = /** @class */ (function () {
  125520. /**
  125521. * Initializes the state.
  125522. */
  125523. function _AlphaState() {
  125524. this._isAlphaBlendDirty = false;
  125525. this._isBlendFunctionParametersDirty = false;
  125526. this._isBlendEquationParametersDirty = false;
  125527. this._isBlendConstantsDirty = false;
  125528. this._alphaBlend = false;
  125529. this._blendFunctionParameters = new Array(4);
  125530. this._blendEquationParameters = new Array(2);
  125531. this._blendConstants = new Array(4);
  125532. this.reset();
  125533. }
  125534. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  125535. get: function () {
  125536. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  125537. },
  125538. enumerable: true,
  125539. configurable: true
  125540. });
  125541. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  125542. get: function () {
  125543. return this._alphaBlend;
  125544. },
  125545. set: function (value) {
  125546. if (this._alphaBlend === value) {
  125547. return;
  125548. }
  125549. this._alphaBlend = value;
  125550. this._isAlphaBlendDirty = true;
  125551. },
  125552. enumerable: true,
  125553. configurable: true
  125554. });
  125555. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  125556. if (this._blendConstants[0] === r &&
  125557. this._blendConstants[1] === g &&
  125558. this._blendConstants[2] === b &&
  125559. this._blendConstants[3] === a) {
  125560. return;
  125561. }
  125562. this._blendConstants[0] = r;
  125563. this._blendConstants[1] = g;
  125564. this._blendConstants[2] = b;
  125565. this._blendConstants[3] = a;
  125566. this._isBlendConstantsDirty = true;
  125567. };
  125568. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  125569. if (this._blendFunctionParameters[0] === value0 &&
  125570. this._blendFunctionParameters[1] === value1 &&
  125571. this._blendFunctionParameters[2] === value2 &&
  125572. this._blendFunctionParameters[3] === value3) {
  125573. return;
  125574. }
  125575. this._blendFunctionParameters[0] = value0;
  125576. this._blendFunctionParameters[1] = value1;
  125577. this._blendFunctionParameters[2] = value2;
  125578. this._blendFunctionParameters[3] = value3;
  125579. this._isBlendFunctionParametersDirty = true;
  125580. };
  125581. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  125582. if (this._blendEquationParameters[0] === rgb &&
  125583. this._blendEquationParameters[1] === alpha) {
  125584. return;
  125585. }
  125586. this._blendEquationParameters[0] = rgb;
  125587. this._blendEquationParameters[1] = alpha;
  125588. this._isBlendEquationParametersDirty = true;
  125589. };
  125590. _AlphaState.prototype.reset = function () {
  125591. this._alphaBlend = false;
  125592. this._blendFunctionParameters[0] = null;
  125593. this._blendFunctionParameters[1] = null;
  125594. this._blendFunctionParameters[2] = null;
  125595. this._blendFunctionParameters[3] = null;
  125596. this._blendEquationParameters[0] = null;
  125597. this._blendEquationParameters[1] = null;
  125598. this._blendConstants[0] = null;
  125599. this._blendConstants[1] = null;
  125600. this._blendConstants[2] = null;
  125601. this._blendConstants[3] = null;
  125602. this._isAlphaBlendDirty = true;
  125603. this._isBlendFunctionParametersDirty = false;
  125604. this._isBlendEquationParametersDirty = false;
  125605. this._isBlendConstantsDirty = false;
  125606. };
  125607. _AlphaState.prototype.apply = function (gl) {
  125608. if (!this.isDirty) {
  125609. return;
  125610. }
  125611. // Alpha blend
  125612. if (this._isAlphaBlendDirty) {
  125613. if (this._alphaBlend) {
  125614. gl.enable(gl.BLEND);
  125615. }
  125616. else {
  125617. gl.disable(gl.BLEND);
  125618. }
  125619. this._isAlphaBlendDirty = false;
  125620. }
  125621. // Alpha function
  125622. if (this._isBlendFunctionParametersDirty) {
  125623. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  125624. this._isBlendFunctionParametersDirty = false;
  125625. }
  125626. // Alpha equation
  125627. if (this._isBlendEquationParametersDirty) {
  125628. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  125629. this._isBlendEquationParametersDirty = false;
  125630. }
  125631. // Constants
  125632. if (this._isBlendConstantsDirty) {
  125633. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  125634. this._isBlendConstantsDirty = false;
  125635. }
  125636. };
  125637. return _AlphaState;
  125638. }());
  125639. /***/ }),
  125640. /***/ "./States/depthCullingState.ts":
  125641. /*!*************************************!*\
  125642. !*** ./States/depthCullingState.ts ***!
  125643. \*************************************/
  125644. /*! exports provided: _DepthCullingState */
  125645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125646. "use strict";
  125647. __webpack_require__.r(__webpack_exports__);
  125648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  125649. /**
  125650. * @hidden
  125651. **/
  125652. var _DepthCullingState = /** @class */ (function () {
  125653. /**
  125654. * Initializes the state.
  125655. */
  125656. function _DepthCullingState() {
  125657. this._isDepthTestDirty = false;
  125658. this._isDepthMaskDirty = false;
  125659. this._isDepthFuncDirty = false;
  125660. this._isCullFaceDirty = false;
  125661. this._isCullDirty = false;
  125662. this._isZOffsetDirty = false;
  125663. this._isFrontFaceDirty = false;
  125664. this.reset();
  125665. }
  125666. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  125667. get: function () {
  125668. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  125669. },
  125670. enumerable: true,
  125671. configurable: true
  125672. });
  125673. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  125674. get: function () {
  125675. return this._zOffset;
  125676. },
  125677. set: function (value) {
  125678. if (this._zOffset === value) {
  125679. return;
  125680. }
  125681. this._zOffset = value;
  125682. this._isZOffsetDirty = true;
  125683. },
  125684. enumerable: true,
  125685. configurable: true
  125686. });
  125687. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  125688. get: function () {
  125689. return this._cullFace;
  125690. },
  125691. set: function (value) {
  125692. if (this._cullFace === value) {
  125693. return;
  125694. }
  125695. this._cullFace = value;
  125696. this._isCullFaceDirty = true;
  125697. },
  125698. enumerable: true,
  125699. configurable: true
  125700. });
  125701. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  125702. get: function () {
  125703. return this._cull;
  125704. },
  125705. set: function (value) {
  125706. if (this._cull === value) {
  125707. return;
  125708. }
  125709. this._cull = value;
  125710. this._isCullDirty = true;
  125711. },
  125712. enumerable: true,
  125713. configurable: true
  125714. });
  125715. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  125716. get: function () {
  125717. return this._depthFunc;
  125718. },
  125719. set: function (value) {
  125720. if (this._depthFunc === value) {
  125721. return;
  125722. }
  125723. this._depthFunc = value;
  125724. this._isDepthFuncDirty = true;
  125725. },
  125726. enumerable: true,
  125727. configurable: true
  125728. });
  125729. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  125730. get: function () {
  125731. return this._depthMask;
  125732. },
  125733. set: function (value) {
  125734. if (this._depthMask === value) {
  125735. return;
  125736. }
  125737. this._depthMask = value;
  125738. this._isDepthMaskDirty = true;
  125739. },
  125740. enumerable: true,
  125741. configurable: true
  125742. });
  125743. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  125744. get: function () {
  125745. return this._depthTest;
  125746. },
  125747. set: function (value) {
  125748. if (this._depthTest === value) {
  125749. return;
  125750. }
  125751. this._depthTest = value;
  125752. this._isDepthTestDirty = true;
  125753. },
  125754. enumerable: true,
  125755. configurable: true
  125756. });
  125757. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  125758. get: function () {
  125759. return this._frontFace;
  125760. },
  125761. set: function (value) {
  125762. if (this._frontFace === value) {
  125763. return;
  125764. }
  125765. this._frontFace = value;
  125766. this._isFrontFaceDirty = true;
  125767. },
  125768. enumerable: true,
  125769. configurable: true
  125770. });
  125771. _DepthCullingState.prototype.reset = function () {
  125772. this._depthMask = true;
  125773. this._depthTest = true;
  125774. this._depthFunc = null;
  125775. this._cullFace = null;
  125776. this._cull = null;
  125777. this._zOffset = 0;
  125778. this._frontFace = null;
  125779. this._isDepthTestDirty = true;
  125780. this._isDepthMaskDirty = true;
  125781. this._isDepthFuncDirty = false;
  125782. this._isCullFaceDirty = false;
  125783. this._isCullDirty = false;
  125784. this._isZOffsetDirty = false;
  125785. this._isFrontFaceDirty = false;
  125786. };
  125787. _DepthCullingState.prototype.apply = function (gl) {
  125788. if (!this.isDirty) {
  125789. return;
  125790. }
  125791. // Cull
  125792. if (this._isCullDirty) {
  125793. if (this.cull) {
  125794. gl.enable(gl.CULL_FACE);
  125795. }
  125796. else {
  125797. gl.disable(gl.CULL_FACE);
  125798. }
  125799. this._isCullDirty = false;
  125800. }
  125801. // Cull face
  125802. if (this._isCullFaceDirty) {
  125803. gl.cullFace(this.cullFace);
  125804. this._isCullFaceDirty = false;
  125805. }
  125806. // Depth mask
  125807. if (this._isDepthMaskDirty) {
  125808. gl.depthMask(this.depthMask);
  125809. this._isDepthMaskDirty = false;
  125810. }
  125811. // Depth test
  125812. if (this._isDepthTestDirty) {
  125813. if (this.depthTest) {
  125814. gl.enable(gl.DEPTH_TEST);
  125815. }
  125816. else {
  125817. gl.disable(gl.DEPTH_TEST);
  125818. }
  125819. this._isDepthTestDirty = false;
  125820. }
  125821. // Depth func
  125822. if (this._isDepthFuncDirty) {
  125823. gl.depthFunc(this.depthFunc);
  125824. this._isDepthFuncDirty = false;
  125825. }
  125826. // zOffset
  125827. if (this._isZOffsetDirty) {
  125828. if (this.zOffset) {
  125829. gl.enable(gl.POLYGON_OFFSET_FILL);
  125830. gl.polygonOffset(this.zOffset, 0);
  125831. }
  125832. else {
  125833. gl.disable(gl.POLYGON_OFFSET_FILL);
  125834. }
  125835. this._isZOffsetDirty = false;
  125836. }
  125837. // Front face
  125838. if (this._isFrontFaceDirty) {
  125839. gl.frontFace(this.frontFace);
  125840. this._isFrontFaceDirty = false;
  125841. }
  125842. };
  125843. return _DepthCullingState;
  125844. }());
  125845. /***/ }),
  125846. /***/ "./States/index.ts":
  125847. /*!*************************!*\
  125848. !*** ./States/index.ts ***!
  125849. \*************************/
  125850. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  125851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125852. "use strict";
  125853. __webpack_require__.r(__webpack_exports__);
  125854. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  125855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  125856. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  125857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  125858. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  125859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  125860. /***/ }),
  125861. /***/ "./States/stencilState.ts":
  125862. /*!********************************!*\
  125863. !*** ./States/stencilState.ts ***!
  125864. \********************************/
  125865. /*! exports provided: _StencilState */
  125866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125867. "use strict";
  125868. __webpack_require__.r(__webpack_exports__);
  125869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  125870. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125871. /**
  125872. * @hidden
  125873. **/
  125874. var _StencilState = /** @class */ (function () {
  125875. function _StencilState() {
  125876. this._isStencilTestDirty = false;
  125877. this._isStencilMaskDirty = false;
  125878. this._isStencilFuncDirty = false;
  125879. this._isStencilOpDirty = false;
  125880. this.reset();
  125881. }
  125882. Object.defineProperty(_StencilState.prototype, "isDirty", {
  125883. get: function () {
  125884. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  125885. },
  125886. enumerable: true,
  125887. configurable: true
  125888. });
  125889. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  125890. get: function () {
  125891. return this._stencilFunc;
  125892. },
  125893. set: function (value) {
  125894. if (this._stencilFunc === value) {
  125895. return;
  125896. }
  125897. this._stencilFunc = value;
  125898. this._isStencilFuncDirty = true;
  125899. },
  125900. enumerable: true,
  125901. configurable: true
  125902. });
  125903. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  125904. get: function () {
  125905. return this._stencilFuncRef;
  125906. },
  125907. set: function (value) {
  125908. if (this._stencilFuncRef === value) {
  125909. return;
  125910. }
  125911. this._stencilFuncRef = value;
  125912. this._isStencilFuncDirty = true;
  125913. },
  125914. enumerable: true,
  125915. configurable: true
  125916. });
  125917. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  125918. get: function () {
  125919. return this._stencilFuncMask;
  125920. },
  125921. set: function (value) {
  125922. if (this._stencilFuncMask === value) {
  125923. return;
  125924. }
  125925. this._stencilFuncMask = value;
  125926. this._isStencilFuncDirty = true;
  125927. },
  125928. enumerable: true,
  125929. configurable: true
  125930. });
  125931. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  125932. get: function () {
  125933. return this._stencilOpStencilFail;
  125934. },
  125935. set: function (value) {
  125936. if (this._stencilOpStencilFail === value) {
  125937. return;
  125938. }
  125939. this._stencilOpStencilFail = value;
  125940. this._isStencilOpDirty = true;
  125941. },
  125942. enumerable: true,
  125943. configurable: true
  125944. });
  125945. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  125946. get: function () {
  125947. return this._stencilOpDepthFail;
  125948. },
  125949. set: function (value) {
  125950. if (this._stencilOpDepthFail === value) {
  125951. return;
  125952. }
  125953. this._stencilOpDepthFail = value;
  125954. this._isStencilOpDirty = true;
  125955. },
  125956. enumerable: true,
  125957. configurable: true
  125958. });
  125959. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  125960. get: function () {
  125961. return this._stencilOpStencilDepthPass;
  125962. },
  125963. set: function (value) {
  125964. if (this._stencilOpStencilDepthPass === value) {
  125965. return;
  125966. }
  125967. this._stencilOpStencilDepthPass = value;
  125968. this._isStencilOpDirty = true;
  125969. },
  125970. enumerable: true,
  125971. configurable: true
  125972. });
  125973. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  125974. get: function () {
  125975. return this._stencilMask;
  125976. },
  125977. set: function (value) {
  125978. if (this._stencilMask === value) {
  125979. return;
  125980. }
  125981. this._stencilMask = value;
  125982. this._isStencilMaskDirty = true;
  125983. },
  125984. enumerable: true,
  125985. configurable: true
  125986. });
  125987. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  125988. get: function () {
  125989. return this._stencilTest;
  125990. },
  125991. set: function (value) {
  125992. if (this._stencilTest === value) {
  125993. return;
  125994. }
  125995. this._stencilTest = value;
  125996. this._isStencilTestDirty = true;
  125997. },
  125998. enumerable: true,
  125999. configurable: true
  126000. });
  126001. _StencilState.prototype.reset = function () {
  126002. this._stencilTest = false;
  126003. this._stencilMask = 0xFF;
  126004. this._stencilFunc = _StencilState.ALWAYS;
  126005. this._stencilFuncRef = 1;
  126006. this._stencilFuncMask = 0xFF;
  126007. this._stencilOpStencilFail = _StencilState.KEEP;
  126008. this._stencilOpDepthFail = _StencilState.KEEP;
  126009. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  126010. this._isStencilTestDirty = true;
  126011. this._isStencilMaskDirty = true;
  126012. this._isStencilFuncDirty = true;
  126013. this._isStencilOpDirty = true;
  126014. };
  126015. _StencilState.prototype.apply = function (gl) {
  126016. if (!this.isDirty) {
  126017. return;
  126018. }
  126019. // Stencil test
  126020. if (this._isStencilTestDirty) {
  126021. if (this.stencilTest) {
  126022. gl.enable(gl.STENCIL_TEST);
  126023. }
  126024. else {
  126025. gl.disable(gl.STENCIL_TEST);
  126026. }
  126027. this._isStencilTestDirty = false;
  126028. }
  126029. // Stencil mask
  126030. if (this._isStencilMaskDirty) {
  126031. gl.stencilMask(this.stencilMask);
  126032. this._isStencilMaskDirty = false;
  126033. }
  126034. // Stencil func
  126035. if (this._isStencilFuncDirty) {
  126036. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  126037. this._isStencilFuncDirty = false;
  126038. }
  126039. // Stencil op
  126040. if (this._isStencilOpDirty) {
  126041. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  126042. this._isStencilOpDirty = false;
  126043. }
  126044. };
  126045. /** 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 */
  126046. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  126047. /** Passed to stencilOperation to specify that stencil value must be kept */
  126048. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  126049. /** Passed to stencilOperation to specify that stencil value must be replaced */
  126050. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  126051. return _StencilState;
  126052. }());
  126053. /***/ }),
  126054. /***/ "./abstractScene.ts":
  126055. /*!**************************!*\
  126056. !*** ./abstractScene.ts ***!
  126057. \**************************/
  126058. /*! exports provided: AbstractScene */
  126059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126060. "use strict";
  126061. __webpack_require__.r(__webpack_exports__);
  126062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  126063. /**
  126064. * Base class of the scene acting as a container for the different elements composing a scene.
  126065. * This class is dynamically extended by the different components of the scene increasing
  126066. * flexibility and reducing coupling
  126067. */
  126068. var AbstractScene = /** @class */ (function () {
  126069. function AbstractScene() {
  126070. /**
  126071. * Gets the list of root nodes (ie. nodes with no parent)
  126072. */
  126073. this.rootNodes = new Array();
  126074. /** All of the cameras added to this scene
  126075. * @see http://doc.babylonjs.com/babylon101/cameras
  126076. */
  126077. this.cameras = new Array();
  126078. /**
  126079. * All of the lights added to this scene
  126080. * @see http://doc.babylonjs.com/babylon101/lights
  126081. */
  126082. this.lights = new Array();
  126083. /**
  126084. * All of the (abstract) meshes added to this scene
  126085. */
  126086. this.meshes = new Array();
  126087. /**
  126088. * The list of skeletons added to the scene
  126089. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126090. */
  126091. this.skeletons = new Array();
  126092. /**
  126093. * All of the particle systems added to this scene
  126094. * @see http://doc.babylonjs.com/babylon101/particles
  126095. */
  126096. this.particleSystems = new Array();
  126097. /**
  126098. * Gets a list of Animations associated with the scene
  126099. */
  126100. this.animations = [];
  126101. /**
  126102. * All of the animation groups added to this scene
  126103. * @see http://doc.babylonjs.com/how_to/group
  126104. */
  126105. this.animationGroups = new Array();
  126106. /**
  126107. * All of the multi-materials added to this scene
  126108. * @see http://doc.babylonjs.com/how_to/multi_materials
  126109. */
  126110. this.multiMaterials = new Array();
  126111. /**
  126112. * All of the materials added to this scene
  126113. * In the context of a Scene, it is not supposed to be modified manually.
  126114. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  126115. * Note also that the order of the Material wihin the array is not significant and might change.
  126116. * @see http://doc.babylonjs.com/babylon101/materials
  126117. */
  126118. this.materials = new Array();
  126119. /**
  126120. * The list of morph target managers added to the scene
  126121. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126122. */
  126123. this.morphTargetManagers = new Array();
  126124. /**
  126125. * The list of geometries used in the scene.
  126126. */
  126127. this.geometries = new Array();
  126128. /**
  126129. * All of the tranform nodes added to this scene
  126130. * In the context of a Scene, it is not supposed to be modified manually.
  126131. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126132. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126133. * @see http://doc.babylonjs.com/how_to/transformnode
  126134. */
  126135. this.transformNodes = new Array();
  126136. /**
  126137. * ActionManagers available on the scene.
  126138. */
  126139. this.actionManagers = new Array();
  126140. /**
  126141. * Textures to keep.
  126142. */
  126143. this.textures = new Array();
  126144. }
  126145. /**
  126146. * Adds a parser in the list of available ones
  126147. * @param name Defines the name of the parser
  126148. * @param parser Defines the parser to add
  126149. */
  126150. AbstractScene.AddParser = function (name, parser) {
  126151. this._BabylonFileParsers[name] = parser;
  126152. };
  126153. /**
  126154. * Gets a general parser from the list of avaialble ones
  126155. * @param name Defines the name of the parser
  126156. * @returns the requested parser or null
  126157. */
  126158. AbstractScene.GetParser = function (name) {
  126159. if (this._BabylonFileParsers[name]) {
  126160. return this._BabylonFileParsers[name];
  126161. }
  126162. return null;
  126163. };
  126164. /**
  126165. * Adds n individual parser in the list of available ones
  126166. * @param name Defines the name of the parser
  126167. * @param parser Defines the parser to add
  126168. */
  126169. AbstractScene.AddIndividualParser = function (name, parser) {
  126170. this._IndividualBabylonFileParsers[name] = parser;
  126171. };
  126172. /**
  126173. * Gets an individual parser from the list of avaialble ones
  126174. * @param name Defines the name of the parser
  126175. * @returns the requested parser or null
  126176. */
  126177. AbstractScene.GetIndividualParser = function (name) {
  126178. if (this._IndividualBabylonFileParsers[name]) {
  126179. return this._IndividualBabylonFileParsers[name];
  126180. }
  126181. return null;
  126182. };
  126183. /**
  126184. * Parser json data and populate both a scene and its associated container object
  126185. * @param jsonData Defines the data to parse
  126186. * @param scene Defines the scene to parse the data for
  126187. * @param container Defines the container attached to the parsing sequence
  126188. * @param rootUrl Defines the root url of the data
  126189. */
  126190. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  126191. for (var parserName in this._BabylonFileParsers) {
  126192. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  126193. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  126194. }
  126195. }
  126196. };
  126197. /**
  126198. * Stores the list of available parsers in the application.
  126199. */
  126200. AbstractScene._BabylonFileParsers = {};
  126201. /**
  126202. * Stores the list of available individual parsers in the application.
  126203. */
  126204. AbstractScene._IndividualBabylonFileParsers = {};
  126205. return AbstractScene;
  126206. }());
  126207. /***/ }),
  126208. /***/ "./assetContainer.ts":
  126209. /*!***************************!*\
  126210. !*** ./assetContainer.ts ***!
  126211. \***************************/
  126212. /*! exports provided: KeepAssets, AssetContainer */
  126213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126214. "use strict";
  126215. __webpack_require__.r(__webpack_exports__);
  126216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  126217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  126218. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126219. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126220. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  126221. /**
  126222. * Set of assets to keep when moving a scene into an asset container.
  126223. */
  126224. var KeepAssets = /** @class */ (function (_super) {
  126225. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  126226. function KeepAssets() {
  126227. return _super !== null && _super.apply(this, arguments) || this;
  126228. }
  126229. return KeepAssets;
  126230. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126231. /**
  126232. * Container with a set of assets that can be added or removed from a scene.
  126233. */
  126234. var AssetContainer = /** @class */ (function (_super) {
  126235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  126236. /**
  126237. * Instantiates an AssetContainer.
  126238. * @param scene The scene the AssetContainer belongs to.
  126239. */
  126240. function AssetContainer(scene) {
  126241. var _this = _super.call(this) || this;
  126242. _this.scene = scene;
  126243. _this["sounds"] = [];
  126244. _this["effectLayers"] = [];
  126245. _this["layers"] = [];
  126246. _this["lensFlareSystems"] = [];
  126247. _this["proceduralTextures"] = [];
  126248. _this["reflectionProbes"] = [];
  126249. return _this;
  126250. }
  126251. /**
  126252. * Adds all the assets from the container to the scene.
  126253. */
  126254. AssetContainer.prototype.addAllToScene = function () {
  126255. var _this = this;
  126256. this.cameras.forEach(function (o) {
  126257. _this.scene.addCamera(o);
  126258. });
  126259. this.lights.forEach(function (o) {
  126260. _this.scene.addLight(o);
  126261. });
  126262. this.meshes.forEach(function (o) {
  126263. _this.scene.addMesh(o);
  126264. });
  126265. this.skeletons.forEach(function (o) {
  126266. _this.scene.addSkeleton(o);
  126267. });
  126268. this.animations.forEach(function (o) {
  126269. _this.scene.addAnimation(o);
  126270. });
  126271. this.animationGroups.forEach(function (o) {
  126272. _this.scene.addAnimationGroup(o);
  126273. });
  126274. this.multiMaterials.forEach(function (o) {
  126275. _this.scene.addMultiMaterial(o);
  126276. });
  126277. this.materials.forEach(function (o) {
  126278. _this.scene.addMaterial(o);
  126279. });
  126280. this.morphTargetManagers.forEach(function (o) {
  126281. _this.scene.addMorphTargetManager(o);
  126282. });
  126283. this.geometries.forEach(function (o) {
  126284. _this.scene.addGeometry(o);
  126285. });
  126286. this.transformNodes.forEach(function (o) {
  126287. _this.scene.addTransformNode(o);
  126288. });
  126289. this.actionManagers.forEach(function (o) {
  126290. _this.scene.addActionManager(o);
  126291. });
  126292. this.textures.forEach(function (o) {
  126293. _this.scene.addTexture(o);
  126294. });
  126295. this.reflectionProbes.forEach(function (o) {
  126296. _this.scene.addReflectionProbe(o);
  126297. });
  126298. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126299. var component = _a[_i];
  126300. component.addFromContainer(this);
  126301. }
  126302. };
  126303. /**
  126304. * Removes all the assets in the container from the scene
  126305. */
  126306. AssetContainer.prototype.removeAllFromScene = function () {
  126307. var _this = this;
  126308. this.cameras.forEach(function (o) {
  126309. _this.scene.removeCamera(o);
  126310. });
  126311. this.lights.forEach(function (o) {
  126312. _this.scene.removeLight(o);
  126313. });
  126314. this.meshes.forEach(function (o) {
  126315. _this.scene.removeMesh(o);
  126316. });
  126317. this.skeletons.forEach(function (o) {
  126318. _this.scene.removeSkeleton(o);
  126319. });
  126320. this.animations.forEach(function (o) {
  126321. _this.scene.removeAnimation(o);
  126322. });
  126323. this.animationGroups.forEach(function (o) {
  126324. _this.scene.removeAnimationGroup(o);
  126325. });
  126326. this.multiMaterials.forEach(function (o) {
  126327. _this.scene.removeMultiMaterial(o);
  126328. });
  126329. this.materials.forEach(function (o) {
  126330. _this.scene.removeMaterial(o);
  126331. });
  126332. this.morphTargetManagers.forEach(function (o) {
  126333. _this.scene.removeMorphTargetManager(o);
  126334. });
  126335. this.geometries.forEach(function (o) {
  126336. _this.scene.removeGeometry(o);
  126337. });
  126338. this.transformNodes.forEach(function (o) {
  126339. _this.scene.removeTransformNode(o);
  126340. });
  126341. this.actionManagers.forEach(function (o) {
  126342. _this.scene.removeActionManager(o);
  126343. });
  126344. this.textures.forEach(function (o) {
  126345. _this.scene.removeTexture(o);
  126346. });
  126347. this.reflectionProbes.forEach(function (o) {
  126348. _this.scene.removeReflectionProbe(o);
  126349. });
  126350. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126351. var component = _a[_i];
  126352. component.removeFromContainer(this);
  126353. }
  126354. };
  126355. /**
  126356. * Disposes all the assets in the container
  126357. */
  126358. AssetContainer.prototype.dispose = function () {
  126359. this.cameras.forEach(function (o) {
  126360. o.dispose();
  126361. });
  126362. this.lights.forEach(function (o) {
  126363. o.dispose();
  126364. });
  126365. this.meshes.forEach(function (o) {
  126366. o.dispose();
  126367. });
  126368. this.skeletons.forEach(function (o) {
  126369. o.dispose();
  126370. });
  126371. this.animationGroups.forEach(function (o) {
  126372. o.dispose();
  126373. });
  126374. this.multiMaterials.forEach(function (o) {
  126375. o.dispose();
  126376. });
  126377. this.materials.forEach(function (o) {
  126378. o.dispose();
  126379. });
  126380. this.geometries.forEach(function (o) {
  126381. o.dispose();
  126382. });
  126383. this.transformNodes.forEach(function (o) {
  126384. o.dispose();
  126385. });
  126386. this.actionManagers.forEach(function (o) {
  126387. o.dispose();
  126388. });
  126389. this.textures.forEach(function (o) {
  126390. o.dispose();
  126391. });
  126392. this.reflectionProbes.forEach(function (o) {
  126393. o.dispose();
  126394. });
  126395. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126396. var component = _a[_i];
  126397. component.dispose();
  126398. }
  126399. };
  126400. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  126401. if (!sourceAssets) {
  126402. return;
  126403. }
  126404. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  126405. var asset = sourceAssets_1[_i];
  126406. var move = true;
  126407. if (keepAssets) {
  126408. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  126409. var keepAsset = keepAssets_1[_a];
  126410. if (asset === keepAsset) {
  126411. move = false;
  126412. break;
  126413. }
  126414. }
  126415. }
  126416. if (move) {
  126417. targetAssets.push(asset);
  126418. }
  126419. }
  126420. };
  126421. /**
  126422. * Removes all the assets contained in the scene and adds them to the container.
  126423. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126424. */
  126425. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  126426. if (keepAssets === undefined) {
  126427. keepAssets = new KeepAssets();
  126428. }
  126429. for (var key in this) {
  126430. if (this.hasOwnProperty(key)) {
  126431. this[key] = this[key] || [];
  126432. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  126433. }
  126434. }
  126435. this.removeAllFromScene();
  126436. };
  126437. /**
  126438. * 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.
  126439. * @returns the root mesh
  126440. */
  126441. AssetContainer.prototype.createRootMesh = function () {
  126442. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  126443. this.meshes.forEach(function (m) {
  126444. if (!m.parent) {
  126445. rootMesh.addChild(m);
  126446. }
  126447. });
  126448. this.meshes.unshift(rootMesh);
  126449. return rootMesh;
  126450. };
  126451. return AssetContainer;
  126452. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126453. /***/ }),
  126454. /***/ "./index.ts":
  126455. /*!******************!*\
  126456. !*** ./index.ts ***!
  126457. \******************/
  126458. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, 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, 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, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, 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, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  126459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126460. "use strict";
  126461. __webpack_require__.r(__webpack_exports__);
  126462. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  126464. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  126465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  126466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  126467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  126468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  126469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  126470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  126471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  126472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  126473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  126474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  126475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  126476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  126477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  126478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  126479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  126480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  126481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  126482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  126483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  126484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  126485. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  126486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  126487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  126488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  126489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  126490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  126491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  126492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  126493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  126494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  126495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  126496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  126497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  126498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  126499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  126500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  126501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  126502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  126503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  126504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  126505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  126506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  126507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  126508. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  126509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  126510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  126511. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  126512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  126513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  126514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  126515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  126516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  126517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  126518. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  126519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  126520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  126521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  126522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  126523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  126524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  126525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  126526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  126527. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  126528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  126529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  126530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  126531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  126532. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  126533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  126534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  126535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  126536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  126537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  126538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  126539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  126540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  126541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  126542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  126543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  126544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  126545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  126546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  126547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  126548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  126549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  126550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  126551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  126552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  126553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  126554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  126555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  126556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  126557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  126558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  126559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  126560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  126561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  126562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  126563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  126564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  126565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  126566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  126567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  126568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  126569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  126570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  126571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  126572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  126573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  126574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  126575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  126576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  126577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  126578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  126579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  126580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  126581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  126582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  126583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  126584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  126585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  126586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  126587. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  126588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  126589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  126590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  126591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  126592. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  126593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  126594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  126595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  126596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  126597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  126598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  126599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  126600. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  126601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  126602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  126603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  126604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  126605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  126606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  126607. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  126608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  126609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  126610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  126611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  126612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  126613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  126614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  126615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  126616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  126617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  126618. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  126619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  126620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  126621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  126622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  126623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  126624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  126625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  126626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  126627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  126628. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  126629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  126630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  126631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  126632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  126633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  126634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  126635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  126636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  126637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  126638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  126639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  126640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  126641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  126642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  126643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  126644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  126645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  126646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  126647. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  126648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  126649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  126650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  126651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  126652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  126653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  126654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  126655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  126656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  126657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  126658. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  126659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  126660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  126661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  126662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  126663. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  126664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  126665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  126666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  126667. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  126668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  126669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  126670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  126671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  126672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  126673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  126674. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  126675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  126676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  126677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  126678. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  126679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  126680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  126681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  126682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  126683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  126684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  126685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  126686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  126687. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  126688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  126689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  126690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  126691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  126692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  126693. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  126694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  126695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  126696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  126697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  126698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  126699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  126700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  126701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  126702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  126703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  126704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  126705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  126706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  126707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  126708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  126709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  126710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  126711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  126712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  126713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  126714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  126715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  126716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  126717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  126718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  126719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  126720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  126721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  126722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  126723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  126724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  126725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  126726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  126727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  126728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  126729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  126730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  126731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  126732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  126733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  126734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  126735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  126736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  126737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  126738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  126739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  126740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  126741. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  126742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  126743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  126744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  126745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  126746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  126747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  126748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  126749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  126750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  126751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  126752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  126753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  126754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  126755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  126756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  126757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  126758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  126759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  126760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  126761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  126762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  126763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  126764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  126765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  126766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  126767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  126768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  126769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  126770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  126771. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  126772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  126773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  126774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  126775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  126776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  126777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  126778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  126779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  126780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  126781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  126782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  126783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  126784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  126785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  126786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  126787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  126788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  126789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  126790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  126791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  126792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  126793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  126794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  126795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  126796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  126797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  126798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  126799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  126800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  126801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  126802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  126803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  126804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  126805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  126806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  126807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  126808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  126809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  126810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  126811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  126812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  126813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  126814. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  126815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  126816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  126817. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  126818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  126819. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  126820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  126821. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  126822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  126823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  126824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  126825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  126826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  126827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  126828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  126829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  126830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  126831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  126832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  126833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  126834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  126835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  126836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  126837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  126838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  126839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  126840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  126841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  126842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  126843. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  126844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  126845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  126846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  126847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  126848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  126849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  126850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  126851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  126852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  126853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  126854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  126855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  126856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  126857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  126858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  126859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  126860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  126861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  126862. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  126863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  126864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  126865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  126866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  126867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  126868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  126869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  126870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  126871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  126872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  126873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  126874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  126875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  126876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  126877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  126878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  126879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  126880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  126881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  126882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  126883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  126884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  126885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  126886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  126887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  126888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  126889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  126890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  126891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  126892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  126893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  126894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  126895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  126896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  126897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  126898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  126899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  126900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  126901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  126902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  126903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  126904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  126905. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  126906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  126907. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  126908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  126909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  126910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  126911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  126912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  126913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  126914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  126915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  126916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  126917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  126918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  126919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  126920. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  126921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  126922. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  126923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  126924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  126925. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  126926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  126927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  126928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  126929. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  126930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  126931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  126932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  126933. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  126934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  126935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  126936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  126937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  126938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  126939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  126940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  126941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  126942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  126943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  126944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  126945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  126946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  126947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  126948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  126949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  126950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  126951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  126952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  126953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  126954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  126955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  126956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  126957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  126958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  126959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  126960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  126961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  126962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  126963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  126964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  126965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  126966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  126967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  126968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  126969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  126970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  126971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  126972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  126973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  126974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  126975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  126976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  126977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  126978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  126979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  126980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  126981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  126982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  126983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  126984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  126985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  126986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  126987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  126988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  126989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  126990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  126991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  126992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  126993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  126994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  126995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  126996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  126997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  126998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  126999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  127000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  127001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  127002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  127003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  127004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  127005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  127006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  127007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  127008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  127009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  127010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  127011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  127012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  127013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  127014. /***/ }),
  127015. /***/ "./node.ts":
  127016. /*!*****************!*\
  127017. !*** ./node.ts ***!
  127018. \*****************/
  127019. /*! exports provided: Node */
  127020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127021. "use strict";
  127022. __webpack_require__.r(__webpack_exports__);
  127023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  127024. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127025. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127026. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  127027. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127028. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127029. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  127030. /**
  127031. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  127032. */
  127033. var Node = /** @class */ (function () {
  127034. /**
  127035. * Creates a new Node
  127036. * @param name the name and id to be given to this node
  127037. * @param scene the scene this node will be added to
  127038. * @param addToRootNodes the node will be added to scene.rootNodes
  127039. */
  127040. function Node(name, scene, addToRootNodes) {
  127041. if (scene === void 0) { scene = null; }
  127042. if (addToRootNodes === void 0) { addToRootNodes = true; }
  127043. /**
  127044. * Gets or sets a string used to store user defined state for the node
  127045. */
  127046. this.state = "";
  127047. /**
  127048. * Gets or sets an object used to store user defined information for the node
  127049. */
  127050. this.metadata = null;
  127051. /**
  127052. * For internal use only. Please do not use.
  127053. */
  127054. this.reservedDataStore = null;
  127055. /**
  127056. * Gets or sets a boolean used to define if the node must be serialized
  127057. */
  127058. this.doNotSerialize = false;
  127059. /** @hidden */
  127060. this._isDisposed = false;
  127061. /**
  127062. * Gets a list of Animations associated with the node
  127063. */
  127064. this.animations = new Array();
  127065. this._ranges = {};
  127066. this._isEnabled = true;
  127067. this._isParentEnabled = true;
  127068. this._isReady = true;
  127069. /** @hidden */
  127070. this._currentRenderId = -1;
  127071. this._parentRenderId = -1;
  127072. this._childRenderId = -1;
  127073. /** @hidden */
  127074. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127075. /** @hidden */
  127076. this._worldMatrixDeterminant = 0;
  127077. /** @hidden */
  127078. this._sceneRootNodesIndex = -1;
  127079. this._animationPropertiesOverride = null;
  127080. /** @hidden */
  127081. this._isNode = true;
  127082. /**
  127083. * An event triggered when the mesh is disposed
  127084. */
  127085. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127086. // Behaviors
  127087. this._behaviors = new Array();
  127088. this.name = name;
  127089. this.id = name;
  127090. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  127091. this.uniqueId = this._scene.getUniqueId();
  127092. this._initCache();
  127093. if (addToRootNodes) {
  127094. this.addToSceneRootNodes();
  127095. }
  127096. }
  127097. /**
  127098. * Add a new node constructor
  127099. * @param type defines the type name of the node to construct
  127100. * @param constructorFunc defines the constructor function
  127101. */
  127102. Node.AddNodeConstructor = function (type, constructorFunc) {
  127103. this._NodeConstructors[type] = constructorFunc;
  127104. };
  127105. /**
  127106. * Returns a node constructor based on type name
  127107. * @param type defines the type name
  127108. * @param name defines the new node name
  127109. * @param scene defines the hosting scene
  127110. * @param options defines optional options to transmit to constructors
  127111. * @returns the new constructor or null
  127112. */
  127113. Node.Construct = function (type, name, scene, options) {
  127114. var constructorFunc = this._NodeConstructors[type];
  127115. if (!constructorFunc) {
  127116. return null;
  127117. }
  127118. return constructorFunc(name, scene, options);
  127119. };
  127120. /**
  127121. * Gets a boolean indicating if the node has been disposed
  127122. * @returns true if the node was disposed
  127123. */
  127124. Node.prototype.isDisposed = function () {
  127125. return this._isDisposed;
  127126. };
  127127. Object.defineProperty(Node.prototype, "parent", {
  127128. get: function () {
  127129. return this._parentNode;
  127130. },
  127131. /**
  127132. * Gets or sets the parent of the node
  127133. */
  127134. set: function (parent) {
  127135. if (this._parentNode === parent) {
  127136. return;
  127137. }
  127138. var previousParentNode = this._parentNode;
  127139. // Remove self from list of children of parent
  127140. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  127141. var index = this._parentNode._children.indexOf(this);
  127142. if (index !== -1) {
  127143. this._parentNode._children.splice(index, 1);
  127144. }
  127145. if (!parent && !this._isDisposed) {
  127146. this.addToSceneRootNodes();
  127147. }
  127148. }
  127149. // Store new parent
  127150. this._parentNode = parent;
  127151. // Add as child to new parent
  127152. if (this._parentNode) {
  127153. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  127154. this._parentNode._children = new Array();
  127155. }
  127156. this._parentNode._children.push(this);
  127157. if (!previousParentNode) {
  127158. this.removeFromSceneRootNodes();
  127159. }
  127160. }
  127161. // Enabled state
  127162. this._syncParentEnabledState();
  127163. },
  127164. enumerable: true,
  127165. configurable: true
  127166. });
  127167. Node.prototype.addToSceneRootNodes = function () {
  127168. if (this._sceneRootNodesIndex === -1) {
  127169. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  127170. this._scene.rootNodes.push(this);
  127171. }
  127172. };
  127173. Node.prototype.removeFromSceneRootNodes = function () {
  127174. if (this._sceneRootNodesIndex !== -1) {
  127175. var rootNodes = this._scene.rootNodes;
  127176. var lastIdx = rootNodes.length - 1;
  127177. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  127178. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  127179. this._scene.rootNodes.pop();
  127180. this._sceneRootNodesIndex = -1;
  127181. }
  127182. };
  127183. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  127184. /**
  127185. * Gets or sets the animation properties override
  127186. */
  127187. get: function () {
  127188. if (!this._animationPropertiesOverride) {
  127189. return this._scene.animationPropertiesOverride;
  127190. }
  127191. return this._animationPropertiesOverride;
  127192. },
  127193. set: function (value) {
  127194. this._animationPropertiesOverride = value;
  127195. },
  127196. enumerable: true,
  127197. configurable: true
  127198. });
  127199. /**
  127200. * Gets a string idenfifying the name of the class
  127201. * @returns "Node" string
  127202. */
  127203. Node.prototype.getClassName = function () {
  127204. return "Node";
  127205. };
  127206. Object.defineProperty(Node.prototype, "onDispose", {
  127207. /**
  127208. * Sets a callback that will be raised when the node will be disposed
  127209. */
  127210. set: function (callback) {
  127211. if (this._onDisposeObserver) {
  127212. this.onDisposeObservable.remove(this._onDisposeObserver);
  127213. }
  127214. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127215. },
  127216. enumerable: true,
  127217. configurable: true
  127218. });
  127219. /**
  127220. * Gets the scene of the node
  127221. * @returns a scene
  127222. */
  127223. Node.prototype.getScene = function () {
  127224. return this._scene;
  127225. };
  127226. /**
  127227. * Gets the engine of the node
  127228. * @returns a Engine
  127229. */
  127230. Node.prototype.getEngine = function () {
  127231. return this._scene.getEngine();
  127232. };
  127233. /**
  127234. * Attach a behavior to the node
  127235. * @see http://doc.babylonjs.com/features/behaviour
  127236. * @param behavior defines the behavior to attach
  127237. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  127238. * @returns the current Node
  127239. */
  127240. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  127241. var _this = this;
  127242. if (attachImmediately === void 0) { attachImmediately = false; }
  127243. var index = this._behaviors.indexOf(behavior);
  127244. if (index !== -1) {
  127245. return this;
  127246. }
  127247. behavior.init();
  127248. if (this._scene.isLoading && !attachImmediately) {
  127249. // We defer the attach when the scene will be loaded
  127250. this._scene.onDataLoadedObservable.addOnce(function () {
  127251. behavior.attach(_this);
  127252. });
  127253. }
  127254. else {
  127255. behavior.attach(this);
  127256. }
  127257. this._behaviors.push(behavior);
  127258. return this;
  127259. };
  127260. /**
  127261. * Remove an attached behavior
  127262. * @see http://doc.babylonjs.com/features/behaviour
  127263. * @param behavior defines the behavior to attach
  127264. * @returns the current Node
  127265. */
  127266. Node.prototype.removeBehavior = function (behavior) {
  127267. var index = this._behaviors.indexOf(behavior);
  127268. if (index === -1) {
  127269. return this;
  127270. }
  127271. this._behaviors[index].detach();
  127272. this._behaviors.splice(index, 1);
  127273. return this;
  127274. };
  127275. Object.defineProperty(Node.prototype, "behaviors", {
  127276. /**
  127277. * Gets the list of attached behaviors
  127278. * @see http://doc.babylonjs.com/features/behaviour
  127279. */
  127280. get: function () {
  127281. return this._behaviors;
  127282. },
  127283. enumerable: true,
  127284. configurable: true
  127285. });
  127286. /**
  127287. * Gets an attached behavior by name
  127288. * @param name defines the name of the behavior to look for
  127289. * @see http://doc.babylonjs.com/features/behaviour
  127290. * @returns null if behavior was not found else the requested behavior
  127291. */
  127292. Node.prototype.getBehaviorByName = function (name) {
  127293. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  127294. var behavior = _a[_i];
  127295. if (behavior.name === name) {
  127296. return behavior;
  127297. }
  127298. }
  127299. return null;
  127300. };
  127301. /**
  127302. * Returns the latest update of the World matrix
  127303. * @returns a Matrix
  127304. */
  127305. Node.prototype.getWorldMatrix = function () {
  127306. if (this._currentRenderId !== this._scene.getRenderId()) {
  127307. this.computeWorldMatrix();
  127308. }
  127309. return this._worldMatrix;
  127310. };
  127311. /** @hidden */
  127312. Node.prototype._getWorldMatrixDeterminant = function () {
  127313. return this._worldMatrixDeterminant;
  127314. };
  127315. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  127316. /**
  127317. * Returns directly the latest state of the mesh World matrix.
  127318. * A Matrix is returned.
  127319. */
  127320. get: function () {
  127321. return this._worldMatrix;
  127322. },
  127323. enumerable: true,
  127324. configurable: true
  127325. });
  127326. // override it in derived class if you add new variables to the cache
  127327. // and call the parent class method
  127328. /** @hidden */
  127329. Node.prototype._initCache = function () {
  127330. this._cache = {};
  127331. this._cache.parent = undefined;
  127332. };
  127333. /** @hidden */
  127334. Node.prototype.updateCache = function (force) {
  127335. if (!force && this.isSynchronized()) {
  127336. return;
  127337. }
  127338. this._cache.parent = this.parent;
  127339. this._updateCache();
  127340. };
  127341. // override it in derived class if you add new variables to the cache
  127342. // and call the parent class method if !ignoreParentClass
  127343. /** @hidden */
  127344. Node.prototype._updateCache = function (ignoreParentClass) {
  127345. };
  127346. // override it in derived class if you add new variables to the cache
  127347. /** @hidden */
  127348. Node.prototype._isSynchronized = function () {
  127349. return true;
  127350. };
  127351. /** @hidden */
  127352. Node.prototype._markSyncedWithParent = function () {
  127353. if (this._parentNode) {
  127354. this._parentRenderId = this._parentNode._childRenderId;
  127355. }
  127356. };
  127357. /** @hidden */
  127358. Node.prototype.isSynchronizedWithParent = function () {
  127359. if (!this._parentNode) {
  127360. return true;
  127361. }
  127362. if (this._parentRenderId !== this._parentNode._childRenderId) {
  127363. return false;
  127364. }
  127365. return this._parentNode.isSynchronized();
  127366. };
  127367. /** @hidden */
  127368. Node.prototype.isSynchronized = function () {
  127369. if (this._cache.parent != this._parentNode) {
  127370. this._cache.parent = this._parentNode;
  127371. return false;
  127372. }
  127373. if (this._parentNode && !this.isSynchronizedWithParent()) {
  127374. return false;
  127375. }
  127376. return this._isSynchronized();
  127377. };
  127378. /**
  127379. * Is this node ready to be used/rendered
  127380. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  127381. * @return true if the node is ready
  127382. */
  127383. Node.prototype.isReady = function (completeCheck) {
  127384. if (completeCheck === void 0) { completeCheck = false; }
  127385. return this._isReady;
  127386. };
  127387. /**
  127388. * Is this node enabled?
  127389. * 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
  127390. * @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
  127391. * @return whether this node (and its parent) is enabled
  127392. */
  127393. Node.prototype.isEnabled = function (checkAncestors) {
  127394. if (checkAncestors === void 0) { checkAncestors = true; }
  127395. if (checkAncestors === false) {
  127396. return this._isEnabled;
  127397. }
  127398. if (!this._isEnabled) {
  127399. return false;
  127400. }
  127401. return this._isParentEnabled;
  127402. };
  127403. /** @hidden */
  127404. Node.prototype._syncParentEnabledState = function () {
  127405. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  127406. if (this._children) {
  127407. this._children.forEach(function (c) {
  127408. c._syncParentEnabledState(); // Force children to update accordingly
  127409. });
  127410. }
  127411. };
  127412. /**
  127413. * Set the enabled state of this node
  127414. * @param value defines the new enabled state
  127415. */
  127416. Node.prototype.setEnabled = function (value) {
  127417. this._isEnabled = value;
  127418. this._syncParentEnabledState();
  127419. };
  127420. /**
  127421. * Is this node a descendant of the given node?
  127422. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  127423. * @param ancestor defines the parent node to inspect
  127424. * @returns a boolean indicating if this node is a descendant of the given node
  127425. */
  127426. Node.prototype.isDescendantOf = function (ancestor) {
  127427. if (this.parent) {
  127428. if (this.parent === ancestor) {
  127429. return true;
  127430. }
  127431. return this.parent.isDescendantOf(ancestor);
  127432. }
  127433. return false;
  127434. };
  127435. /** @hidden */
  127436. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  127437. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  127438. if (!this._children) {
  127439. return;
  127440. }
  127441. for (var index = 0; index < this._children.length; index++) {
  127442. var item = this._children[index];
  127443. if (!predicate || predicate(item)) {
  127444. results.push(item);
  127445. }
  127446. if (!directDescendantsOnly) {
  127447. item._getDescendants(results, false, predicate);
  127448. }
  127449. }
  127450. };
  127451. /**
  127452. * Will return all nodes that have this node as ascendant
  127453. * @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
  127454. * @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
  127455. * @return all children nodes of all types
  127456. */
  127457. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  127458. var results = new Array();
  127459. this._getDescendants(results, directDescendantsOnly, predicate);
  127460. return results;
  127461. };
  127462. /**
  127463. * Get all child-meshes of this node
  127464. * @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
  127465. * @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
  127466. * @returns an array of AbstractMesh
  127467. */
  127468. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  127469. var results = [];
  127470. this._getDescendants(results, directDescendantsOnly, function (node) {
  127471. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  127472. });
  127473. return results;
  127474. };
  127475. /**
  127476. * Get all direct children of this node
  127477. * @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
  127478. * @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)
  127479. * @returns an array of Node
  127480. */
  127481. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  127482. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  127483. return this.getDescendants(directDescendantsOnly, predicate);
  127484. };
  127485. /** @hidden */
  127486. Node.prototype._setReady = function (state) {
  127487. if (state === this._isReady) {
  127488. return;
  127489. }
  127490. if (!state) {
  127491. this._isReady = false;
  127492. return;
  127493. }
  127494. if (this.onReady) {
  127495. this.onReady(this);
  127496. }
  127497. this._isReady = true;
  127498. };
  127499. /**
  127500. * Get an animation by name
  127501. * @param name defines the name of the animation to look for
  127502. * @returns null if not found else the requested animation
  127503. */
  127504. Node.prototype.getAnimationByName = function (name) {
  127505. for (var i = 0; i < this.animations.length; i++) {
  127506. var animation = this.animations[i];
  127507. if (animation.name === name) {
  127508. return animation;
  127509. }
  127510. }
  127511. return null;
  127512. };
  127513. /**
  127514. * Creates an animation range for this node
  127515. * @param name defines the name of the range
  127516. * @param from defines the starting key
  127517. * @param to defines the end key
  127518. */
  127519. Node.prototype.createAnimationRange = function (name, from, to) {
  127520. // check name not already in use
  127521. if (!this._ranges[name]) {
  127522. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  127523. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127524. if (this.animations[i]) {
  127525. this.animations[i].createRange(name, from, to);
  127526. }
  127527. }
  127528. }
  127529. };
  127530. /**
  127531. * Delete a specific animation range
  127532. * @param name defines the name of the range to delete
  127533. * @param deleteFrames defines if animation frames from the range must be deleted as well
  127534. */
  127535. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  127536. if (deleteFrames === void 0) { deleteFrames = true; }
  127537. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127538. if (this.animations[i]) {
  127539. this.animations[i].deleteRange(name, deleteFrames);
  127540. }
  127541. }
  127542. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  127543. };
  127544. /**
  127545. * Get an animation range by name
  127546. * @param name defines the name of the animation range to look for
  127547. * @returns null if not found else the requested animation range
  127548. */
  127549. Node.prototype.getAnimationRange = function (name) {
  127550. return this._ranges[name];
  127551. };
  127552. /**
  127553. * Will start the animation sequence
  127554. * @param name defines the range frames for animation sequence
  127555. * @param loop defines if the animation should loop (false by default)
  127556. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  127557. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  127558. * @returns the object created for this animation. If range does not exist, it will return null
  127559. */
  127560. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  127561. var range = this.getAnimationRange(name);
  127562. if (!range) {
  127563. return null;
  127564. }
  127565. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  127566. };
  127567. /**
  127568. * Serialize animation ranges into a JSON compatible object
  127569. * @returns serialization object
  127570. */
  127571. Node.prototype.serializeAnimationRanges = function () {
  127572. var serializationRanges = [];
  127573. for (var name in this._ranges) {
  127574. var localRange = this._ranges[name];
  127575. if (!localRange) {
  127576. continue;
  127577. }
  127578. var range = {};
  127579. range.name = name;
  127580. range.from = localRange.from;
  127581. range.to = localRange.to;
  127582. serializationRanges.push(range);
  127583. }
  127584. return serializationRanges;
  127585. };
  127586. /**
  127587. * Computes the world matrix of the node
  127588. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  127589. * @returns the world matrix
  127590. */
  127591. Node.prototype.computeWorldMatrix = function (force) {
  127592. if (!this._worldMatrix) {
  127593. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127594. }
  127595. return this._worldMatrix;
  127596. };
  127597. /**
  127598. * Releases resources associated with this node.
  127599. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127600. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127601. */
  127602. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  127603. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  127604. this._isDisposed = true;
  127605. if (!doNotRecurse) {
  127606. var nodes = this.getDescendants(true);
  127607. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  127608. var node = nodes_1[_i];
  127609. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  127610. }
  127611. }
  127612. if (!this.parent) {
  127613. this.removeFromSceneRootNodes();
  127614. }
  127615. else {
  127616. this.parent = null;
  127617. }
  127618. // Callback
  127619. this.onDisposeObservable.notifyObservers(this);
  127620. this.onDisposeObservable.clear();
  127621. // Behaviors
  127622. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  127623. var behavior = _b[_a];
  127624. behavior.detach();
  127625. }
  127626. this._behaviors = [];
  127627. };
  127628. /**
  127629. * Parse animation range data from a serialization object and store them into a given node
  127630. * @param node defines where to store the animation ranges
  127631. * @param parsedNode defines the serialization object to read data from
  127632. * @param scene defines the hosting scene
  127633. */
  127634. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  127635. if (parsedNode.ranges) {
  127636. for (var index = 0; index < parsedNode.ranges.length; index++) {
  127637. var data = parsedNode.ranges[index];
  127638. node.createAnimationRange(data.name, data.from, data.to);
  127639. }
  127640. }
  127641. };
  127642. /** @hidden */
  127643. Node._AnimationRangeFactory = function (name, from, to) {
  127644. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  127645. };
  127646. Node._NodeConstructors = {};
  127647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127649. ], Node.prototype, "name", void 0);
  127650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127652. ], Node.prototype, "id", void 0);
  127653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127655. ], Node.prototype, "uniqueId", void 0);
  127656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127658. ], Node.prototype, "state", void 0);
  127659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127661. ], Node.prototype, "metadata", void 0);
  127662. return Node;
  127663. }());
  127664. /***/ }),
  127665. /***/ "./scene.ts":
  127666. /*!******************!*\
  127667. !*** ./scene.ts ***!
  127668. \******************/
  127669. /*! exports provided: Scene */
  127670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127671. "use strict";
  127672. __webpack_require__.r(__webpack_exports__);
  127673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  127674. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127675. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  127676. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  127677. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127678. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  127679. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  127680. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  127681. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127682. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127683. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  127684. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  127685. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  127686. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  127687. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  127688. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  127689. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  127690. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  127691. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  127692. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  127693. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  127694. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  127695. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  127696. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  127697. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  127698. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127699. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  127700. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  127701. /** @hidden */
  127702. var ClickInfo = /** @class */ (function () {
  127703. function ClickInfo() {
  127704. this._singleClick = false;
  127705. this._doubleClick = false;
  127706. this._hasSwiped = false;
  127707. this._ignore = false;
  127708. }
  127709. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  127710. get: function () {
  127711. return this._singleClick;
  127712. },
  127713. set: function (b) {
  127714. this._singleClick = b;
  127715. },
  127716. enumerable: true,
  127717. configurable: true
  127718. });
  127719. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  127720. get: function () {
  127721. return this._doubleClick;
  127722. },
  127723. set: function (b) {
  127724. this._doubleClick = b;
  127725. },
  127726. enumerable: true,
  127727. configurable: true
  127728. });
  127729. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  127730. get: function () {
  127731. return this._hasSwiped;
  127732. },
  127733. set: function (b) {
  127734. this._hasSwiped = b;
  127735. },
  127736. enumerable: true,
  127737. configurable: true
  127738. });
  127739. Object.defineProperty(ClickInfo.prototype, "ignore", {
  127740. get: function () {
  127741. return this._ignore;
  127742. },
  127743. set: function (b) {
  127744. this._ignore = b;
  127745. },
  127746. enumerable: true,
  127747. configurable: true
  127748. });
  127749. return ClickInfo;
  127750. }());
  127751. /**
  127752. * Represents a scene to be rendered by the engine.
  127753. * @see http://doc.babylonjs.com/features/scene
  127754. */
  127755. var Scene = /** @class */ (function (_super) {
  127756. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  127757. /**
  127758. * Creates a new Scene
  127759. * @param engine defines the engine to use to render this scene
  127760. * @param options defines the scene options
  127761. */
  127762. function Scene(engine, options) {
  127763. var _this = _super.call(this) || this;
  127764. // Members
  127765. /** @hidden */
  127766. _this._isScene = true;
  127767. /**
  127768. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  127769. */
  127770. _this.autoClear = true;
  127771. /**
  127772. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  127773. */
  127774. _this.autoClearDepthAndStencil = true;
  127775. /**
  127776. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  127777. */
  127778. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  127779. /**
  127780. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  127781. */
  127782. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  127783. _this._forceWireframe = false;
  127784. _this._forcePointsCloud = false;
  127785. /**
  127786. * Gets or sets a boolean indicating if animations are enabled
  127787. */
  127788. _this.animationsEnabled = true;
  127789. _this._animationPropertiesOverride = null;
  127790. /**
  127791. * Gets or sets a boolean indicating if a constant deltatime has to be used
  127792. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  127793. */
  127794. _this.useConstantAnimationDeltaTime = false;
  127795. /**
  127796. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  127797. * Please note that it requires to run a ray cast through the scene on every frame
  127798. */
  127799. _this.constantlyUpdateMeshUnderPointer = false;
  127800. /**
  127801. * Defines the HTML cursor to use when hovering over interactive elements
  127802. */
  127803. _this.hoverCursor = "pointer";
  127804. /**
  127805. * Defines the HTML default cursor to use (empty by default)
  127806. */
  127807. _this.defaultCursor = "";
  127808. /**
  127809. * This is used to call preventDefault() on pointer down
  127810. * in order to block unwanted artifacts like system double clicks
  127811. */
  127812. _this.preventDefaultOnPointerDown = true;
  127813. /**
  127814. * This is used to call preventDefault() on pointer up
  127815. * in order to block unwanted artifacts like system double clicks
  127816. */
  127817. _this.preventDefaultOnPointerUp = true;
  127818. // Metadata
  127819. /**
  127820. * Gets or sets user defined metadata
  127821. */
  127822. _this.metadata = null;
  127823. /**
  127824. * For internal use only. Please do not use.
  127825. */
  127826. _this.reservedDataStore = null;
  127827. /**
  127828. * Use this array to add regular expressions used to disable offline support for specific urls
  127829. */
  127830. _this.disableOfflineSupportExceptionRules = new Array();
  127831. /**
  127832. * An event triggered when the scene is disposed.
  127833. */
  127834. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127835. _this._onDisposeObserver = null;
  127836. /**
  127837. * An event triggered before rendering the scene (right after animations and physics)
  127838. */
  127839. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127840. _this._onBeforeRenderObserver = null;
  127841. /**
  127842. * An event triggered after rendering the scene
  127843. */
  127844. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127845. _this._onAfterRenderObserver = null;
  127846. /**
  127847. * An event triggered before animating the scene
  127848. */
  127849. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127850. /**
  127851. * An event triggered after animations processing
  127852. */
  127853. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127854. /**
  127855. * An event triggered before draw calls are ready to be sent
  127856. */
  127857. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127858. /**
  127859. * An event triggered after draw calls have been sent
  127860. */
  127861. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127862. /**
  127863. * An event triggered when the scene is ready
  127864. */
  127865. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127866. /**
  127867. * An event triggered before rendering a camera
  127868. */
  127869. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127870. _this._onBeforeCameraRenderObserver = null;
  127871. /**
  127872. * An event triggered after rendering a camera
  127873. */
  127874. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127875. _this._onAfterCameraRenderObserver = null;
  127876. /**
  127877. * An event triggered when active meshes evaluation is about to start
  127878. */
  127879. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127880. /**
  127881. * An event triggered when active meshes evaluation is done
  127882. */
  127883. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127884. /**
  127885. * An event triggered when particles rendering is about to start
  127886. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127887. */
  127888. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127889. /**
  127890. * An event triggered when particles rendering is done
  127891. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127892. */
  127893. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127894. /**
  127895. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  127896. */
  127897. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127898. /**
  127899. * An event triggered when a camera is created
  127900. */
  127901. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127902. /**
  127903. * An event triggered when a camera is removed
  127904. */
  127905. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127906. /**
  127907. * An event triggered when a light is created
  127908. */
  127909. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127910. /**
  127911. * An event triggered when a light is removed
  127912. */
  127913. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127914. /**
  127915. * An event triggered when a geometry is created
  127916. */
  127917. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127918. /**
  127919. * An event triggered when a geometry is removed
  127920. */
  127921. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127922. /**
  127923. * An event triggered when a transform node is created
  127924. */
  127925. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127926. /**
  127927. * An event triggered when a transform node is removed
  127928. */
  127929. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127930. /**
  127931. * An event triggered when a mesh is created
  127932. */
  127933. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127934. /**
  127935. * An event triggered when a mesh is removed
  127936. */
  127937. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127938. /**
  127939. * An event triggered when a material is created
  127940. */
  127941. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127942. /**
  127943. * An event triggered when a material is removed
  127944. */
  127945. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127946. /**
  127947. * An event triggered when a texture is created
  127948. */
  127949. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127950. /**
  127951. * An event triggered when a texture is removed
  127952. */
  127953. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127954. /**
  127955. * An event triggered when render targets are about to be rendered
  127956. * Can happen multiple times per frame.
  127957. */
  127958. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127959. /**
  127960. * An event triggered when render targets were rendered.
  127961. * Can happen multiple times per frame.
  127962. */
  127963. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127964. /**
  127965. * An event triggered before calculating deterministic simulation step
  127966. */
  127967. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127968. /**
  127969. * An event triggered after calculating deterministic simulation step
  127970. */
  127971. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127972. /**
  127973. * An event triggered when the activeCamera property is updated
  127974. */
  127975. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127976. /**
  127977. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  127978. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  127979. * 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)
  127980. */
  127981. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127982. /**
  127983. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  127984. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  127985. * 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)
  127986. */
  127987. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127988. /**
  127989. * This Observable will when a mesh has been imported into the scene.
  127990. */
  127991. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127992. // Animations
  127993. /** @hidden */
  127994. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127995. /**
  127996. * 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).
  127997. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  127998. */
  127999. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128000. /**
  128001. * Observable event triggered each time an input event is received from the rendering canvas
  128002. */
  128003. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128004. _this._meshPickProceed = false;
  128005. _this._currentPickResult = null;
  128006. _this._previousPickResult = null;
  128007. _this._totalPointersPressed = 0;
  128008. _this._doubleClickOccured = false;
  128009. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  128010. _this.cameraToUseForPointers = null;
  128011. _this._pointerX = 0;
  128012. _this._pointerY = 0;
  128013. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  128014. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  128015. _this._startingPointerTime = 0;
  128016. _this._previousStartingPointerTime = 0;
  128017. _this._pointerCaptures = {};
  128018. // Deterministic lockstep
  128019. _this._timeAccumulator = 0;
  128020. _this._currentStepId = 0;
  128021. _this._currentInternalStep = 0;
  128022. // Keyboard
  128023. /**
  128024. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  128025. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  128026. */
  128027. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128028. /**
  128029. * Observable event triggered each time an keyboard event is received from the hosting window
  128030. */
  128031. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128032. // Coordinates system
  128033. _this._useRightHandedSystem = false;
  128034. // Fog
  128035. _this._fogEnabled = true;
  128036. _this._fogMode = Scene.FOGMODE_NONE;
  128037. /**
  128038. * Gets or sets the fog color to use
  128039. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128040. * (Default is Color3(0.2, 0.2, 0.3))
  128041. */
  128042. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  128043. /**
  128044. * Gets or sets the fog density to use
  128045. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128046. * (Default is 0.1)
  128047. */
  128048. _this.fogDensity = 0.1;
  128049. /**
  128050. * Gets or sets the fog start distance to use
  128051. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128052. * (Default is 0)
  128053. */
  128054. _this.fogStart = 0;
  128055. /**
  128056. * Gets or sets the fog end distance to use
  128057. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128058. * (Default is 1000)
  128059. */
  128060. _this.fogEnd = 1000.0;
  128061. // Lights
  128062. _this._shadowsEnabled = true;
  128063. _this._lightsEnabled = true;
  128064. /** All of the active cameras added to this scene. */
  128065. _this.activeCameras = new Array();
  128066. // Textures
  128067. _this._texturesEnabled = true;
  128068. // Particles
  128069. /**
  128070. * Gets or sets a boolean indicating if particles are enabled on this scene
  128071. */
  128072. _this.particlesEnabled = true;
  128073. // Sprites
  128074. /**
  128075. * Gets or sets a boolean indicating if sprites are enabled on this scene
  128076. */
  128077. _this.spritesEnabled = true;
  128078. // Skeletons
  128079. _this._skeletonsEnabled = true;
  128080. // Lens flares
  128081. /**
  128082. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  128083. */
  128084. _this.lensFlaresEnabled = true;
  128085. // Collisions
  128086. /**
  128087. * Gets or sets a boolean indicating if collisions are enabled on this scene
  128088. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  128089. */
  128090. _this.collisionsEnabled = true;
  128091. /**
  128092. * Defines the gravity applied to this scene (used only for collisions)
  128093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  128094. */
  128095. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  128096. // Postprocesses
  128097. /**
  128098. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  128099. */
  128100. _this.postProcessesEnabled = true;
  128101. /**
  128102. * The list of postprocesses added to the scene
  128103. */
  128104. _this.postProcesses = new Array();
  128105. // Customs render targets
  128106. /**
  128107. * Gets or sets a boolean indicating if render targets are enabled on this scene
  128108. */
  128109. _this.renderTargetsEnabled = true;
  128110. /**
  128111. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  128112. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  128113. */
  128114. _this.dumpNextRenderTargets = false;
  128115. /**
  128116. * The list of user defined render targets added to the scene
  128117. */
  128118. _this.customRenderTargets = new Array();
  128119. /**
  128120. * Gets the list of meshes imported to the scene through SceneLoader
  128121. */
  128122. _this.importedMeshesFiles = new Array();
  128123. // Probes
  128124. /**
  128125. * Gets or sets a boolean indicating if probes are enabled on this scene
  128126. */
  128127. _this.probesEnabled = true;
  128128. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128129. // Procedural textures
  128130. /**
  128131. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  128132. */
  128133. _this.proceduralTexturesEnabled = true;
  128134. // Performance counters
  128135. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128136. /** @hidden */
  128137. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128138. /** @hidden */
  128139. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128140. /** @hidden */
  128141. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128142. /** @hidden */
  128143. _this._animationTime = 0;
  128144. /**
  128145. * Gets or sets a general scale for animation speed
  128146. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  128147. */
  128148. _this.animationTimeScale = 1;
  128149. _this._renderId = 0;
  128150. _this._frameId = 0;
  128151. _this._executeWhenReadyTimeoutId = -1;
  128152. _this._intermediateRendering = false;
  128153. _this._viewUpdateFlag = -1;
  128154. _this._projectionUpdateFlag = -1;
  128155. _this._alternateViewUpdateFlag = -1;
  128156. _this._alternateProjectionUpdateFlag = -1;
  128157. /** @hidden */
  128158. _this._toBeDisposed = new Array(256);
  128159. _this._activeRequests = new Array();
  128160. /** @hidden */
  128161. _this._pendingData = new Array();
  128162. _this._isDisposed = false;
  128163. /**
  128164. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  128165. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  128166. */
  128167. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  128168. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128169. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128170. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128171. /** @hidden */
  128172. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128173. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128174. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128175. /** @hidden */
  128176. _this._activeAnimatables = new Array();
  128177. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  128178. _this._useAlternateCameraConfiguration = false;
  128179. _this._alternateRendering = false;
  128180. _this._wheelEventName = "";
  128181. /**
  128182. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  128183. * This is useful if there are more lights that the maximum simulteanous authorized
  128184. */
  128185. _this.requireLightSorting = false;
  128186. /**
  128187. * @hidden
  128188. * Backing store of defined scene components.
  128189. */
  128190. _this._components = [];
  128191. /**
  128192. * @hidden
  128193. * Backing store of defined scene components.
  128194. */
  128195. _this._serializableComponents = [];
  128196. /**
  128197. * List of components to register on the next registration step.
  128198. */
  128199. _this._transientComponents = [];
  128200. /**
  128201. * @hidden
  128202. * Defines the actions happening before camera updates.
  128203. */
  128204. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128205. /**
  128206. * @hidden
  128207. * Defines the actions happening before clear the canvas.
  128208. */
  128209. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128210. /**
  128211. * @hidden
  128212. * Defines the actions when collecting render targets for the frame.
  128213. */
  128214. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128215. /**
  128216. * @hidden
  128217. * Defines the actions happening for one camera in the frame.
  128218. */
  128219. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128220. /**
  128221. * @hidden
  128222. * Defines the actions happening during the per mesh ready checks.
  128223. */
  128224. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128225. /**
  128226. * @hidden
  128227. * Defines the actions happening before evaluate active mesh checks.
  128228. */
  128229. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128230. /**
  128231. * @hidden
  128232. * Defines the actions happening during the evaluate sub mesh checks.
  128233. */
  128234. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128235. /**
  128236. * @hidden
  128237. * Defines the actions happening during the active mesh stage.
  128238. */
  128239. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128240. /**
  128241. * @hidden
  128242. * Defines the actions happening during the per camera render target step.
  128243. */
  128244. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128245. /**
  128246. * @hidden
  128247. * Defines the actions happening just before the active camera is drawing.
  128248. */
  128249. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128250. /**
  128251. * @hidden
  128252. * Defines the actions happening just before a render target is drawing.
  128253. */
  128254. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128255. /**
  128256. * @hidden
  128257. * Defines the actions happening just before a rendering group is drawing.
  128258. */
  128259. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128260. /**
  128261. * @hidden
  128262. * Defines the actions happening just before a mesh is drawing.
  128263. */
  128264. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128265. /**
  128266. * @hidden
  128267. * Defines the actions happening just after a mesh has been drawn.
  128268. */
  128269. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128270. /**
  128271. * @hidden
  128272. * Defines the actions happening just after a rendering group has been drawn.
  128273. */
  128274. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128275. /**
  128276. * @hidden
  128277. * Defines the actions happening just after the active camera has been drawn.
  128278. */
  128279. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128280. /**
  128281. * @hidden
  128282. * Defines the actions happening just after a render target has been drawn.
  128283. */
  128284. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128285. /**
  128286. * @hidden
  128287. * Defines the actions happening just after rendering all cameras and computing intersections.
  128288. */
  128289. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128290. /**
  128291. * @hidden
  128292. * Defines the actions happening when a pointer move event happens.
  128293. */
  128294. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128295. /**
  128296. * @hidden
  128297. * Defines the actions happening when a pointer down event happens.
  128298. */
  128299. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128300. /**
  128301. * @hidden
  128302. * Defines the actions happening when a pointer up event happens.
  128303. */
  128304. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128305. /**
  128306. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  128307. */
  128308. _this.geometriesByUniqueId = null;
  128309. _this._defaultMeshCandidates = {
  128310. data: [],
  128311. length: 0
  128312. };
  128313. _this._defaultSubMeshCandidates = {
  128314. data: [],
  128315. length: 0
  128316. };
  128317. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  128318. _this._activeMeshesFrozen = false;
  128319. /** @hidden */
  128320. _this._allowPostProcessClearColor = true;
  128321. /**
  128322. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  128323. */
  128324. _this.getDeterministicFrameTime = function () {
  128325. return 1000.0 / 60.0; // frame time in ms
  128326. };
  128327. _this._blockMaterialDirtyMechanism = false;
  128328. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  128329. _this._engine.scenes.push(_this);
  128330. _this._uid = null;
  128331. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  128332. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  128333. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  128334. }
  128335. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  128336. _this.attachControl();
  128337. }
  128338. // Uniform Buffer
  128339. _this._createUbo();
  128340. // Default Image processing definition
  128341. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  128342. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  128343. }
  128344. _this.setDefaultCandidateProviders();
  128345. if (options && options.useGeometryUniqueIdsMap === true) {
  128346. _this.geometriesByUniqueId = {};
  128347. }
  128348. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  128349. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  128350. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  128351. return _this;
  128352. }
  128353. /**
  128354. * Factory used to create the default material.
  128355. * @param name The name of the material to create
  128356. * @param scene The scene to create the material for
  128357. * @returns The default material
  128358. */
  128359. Scene.DefaultMaterialFactory = function (scene) {
  128360. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  128361. };
  128362. /**
  128363. * Factory used to create the a collision coordinator.
  128364. * @returns The collision coordinator
  128365. */
  128366. Scene.CollisionCoordinatorFactory = function () {
  128367. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  128368. };
  128369. Object.defineProperty(Scene.prototype, "environmentTexture", {
  128370. /**
  128371. * Texture used in all pbr material as the reflection texture.
  128372. * As in the majority of the scene they are the same (exception for multi room and so on),
  128373. * this is easier to reference from here than from all the materials.
  128374. */
  128375. get: function () {
  128376. return this._environmentTexture;
  128377. },
  128378. /**
  128379. * Texture used in all pbr material as the reflection texture.
  128380. * As in the majority of the scene they are the same (exception for multi room and so on),
  128381. * this is easier to set here than in all the materials.
  128382. */
  128383. set: function (value) {
  128384. if (this._environmentTexture === value) {
  128385. return;
  128386. }
  128387. this._environmentTexture = value;
  128388. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  128389. },
  128390. enumerable: true,
  128391. configurable: true
  128392. });
  128393. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  128394. /**
  128395. * Default image processing configuration used either in the rendering
  128396. * Forward main pass or through the imageProcessingPostProcess if present.
  128397. * As in the majority of the scene they are the same (exception for multi camera),
  128398. * this is easier to reference from here than from all the materials and post process.
  128399. *
  128400. * No setter as we it is a shared configuration, you can set the values instead.
  128401. */
  128402. get: function () {
  128403. return this._imageProcessingConfiguration;
  128404. },
  128405. enumerable: true,
  128406. configurable: true
  128407. });
  128408. Object.defineProperty(Scene.prototype, "forceWireframe", {
  128409. get: function () {
  128410. return this._forceWireframe;
  128411. },
  128412. /**
  128413. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  128414. */
  128415. set: function (value) {
  128416. if (this._forceWireframe === value) {
  128417. return;
  128418. }
  128419. this._forceWireframe = value;
  128420. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128421. },
  128422. enumerable: true,
  128423. configurable: true
  128424. });
  128425. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  128426. get: function () {
  128427. return this._forcePointsCloud;
  128428. },
  128429. /**
  128430. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  128431. */
  128432. set: function (value) {
  128433. if (this._forcePointsCloud === value) {
  128434. return;
  128435. }
  128436. this._forcePointsCloud = value;
  128437. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128438. },
  128439. enumerable: true,
  128440. configurable: true
  128441. });
  128442. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  128443. /**
  128444. * Gets or sets the animation properties override
  128445. */
  128446. get: function () {
  128447. return this._animationPropertiesOverride;
  128448. },
  128449. set: function (value) {
  128450. this._animationPropertiesOverride = value;
  128451. },
  128452. enumerable: true,
  128453. configurable: true
  128454. });
  128455. Object.defineProperty(Scene.prototype, "onDispose", {
  128456. /** Sets a function to be executed when this scene is disposed. */
  128457. set: function (callback) {
  128458. if (this._onDisposeObserver) {
  128459. this.onDisposeObservable.remove(this._onDisposeObserver);
  128460. }
  128461. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  128462. },
  128463. enumerable: true,
  128464. configurable: true
  128465. });
  128466. Object.defineProperty(Scene.prototype, "beforeRender", {
  128467. /** Sets a function to be executed before rendering this scene */
  128468. set: function (callback) {
  128469. if (this._onBeforeRenderObserver) {
  128470. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  128471. }
  128472. if (callback) {
  128473. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  128474. }
  128475. },
  128476. enumerable: true,
  128477. configurable: true
  128478. });
  128479. Object.defineProperty(Scene.prototype, "afterRender", {
  128480. /** Sets a function to be executed after rendering this scene */
  128481. set: function (callback) {
  128482. if (this._onAfterRenderObserver) {
  128483. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  128484. }
  128485. if (callback) {
  128486. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  128487. }
  128488. },
  128489. enumerable: true,
  128490. configurable: true
  128491. });
  128492. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  128493. /** Sets a function to be executed before rendering a camera*/
  128494. set: function (callback) {
  128495. if (this._onBeforeCameraRenderObserver) {
  128496. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  128497. }
  128498. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  128499. },
  128500. enumerable: true,
  128501. configurable: true
  128502. });
  128503. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  128504. /** Sets a function to be executed after rendering a camera*/
  128505. set: function (callback) {
  128506. if (this._onAfterCameraRenderObserver) {
  128507. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  128508. }
  128509. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  128510. },
  128511. enumerable: true,
  128512. configurable: true
  128513. });
  128514. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  128515. /**
  128516. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  128517. */
  128518. get: function () {
  128519. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  128520. },
  128521. enumerable: true,
  128522. configurable: true
  128523. });
  128524. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  128525. get: function () {
  128526. return this._useRightHandedSystem;
  128527. },
  128528. /**
  128529. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  128530. */
  128531. set: function (value) {
  128532. if (this._useRightHandedSystem === value) {
  128533. return;
  128534. }
  128535. this._useRightHandedSystem = value;
  128536. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128537. },
  128538. enumerable: true,
  128539. configurable: true
  128540. });
  128541. /**
  128542. * Sets the step Id used by deterministic lock step
  128543. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128544. * @param newStepId defines the step Id
  128545. */
  128546. Scene.prototype.setStepId = function (newStepId) {
  128547. this._currentStepId = newStepId;
  128548. };
  128549. /**
  128550. * Gets the step Id used by deterministic lock step
  128551. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128552. * @returns the step Id
  128553. */
  128554. Scene.prototype.getStepId = function () {
  128555. return this._currentStepId;
  128556. };
  128557. /**
  128558. * Gets the internal step used by deterministic lock step
  128559. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128560. * @returns the internal step
  128561. */
  128562. Scene.prototype.getInternalStep = function () {
  128563. return this._currentInternalStep;
  128564. };
  128565. Object.defineProperty(Scene.prototype, "fogEnabled", {
  128566. get: function () {
  128567. return this._fogEnabled;
  128568. },
  128569. /**
  128570. * Gets or sets a boolean indicating if fog is enabled on this scene
  128571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128572. * (Default is true)
  128573. */
  128574. set: function (value) {
  128575. if (this._fogEnabled === value) {
  128576. return;
  128577. }
  128578. this._fogEnabled = value;
  128579. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128580. },
  128581. enumerable: true,
  128582. configurable: true
  128583. });
  128584. Object.defineProperty(Scene.prototype, "fogMode", {
  128585. get: function () {
  128586. return this._fogMode;
  128587. },
  128588. /**
  128589. * Gets or sets the fog mode to use
  128590. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128591. * | mode | value |
  128592. * | --- | --- |
  128593. * | FOGMODE_NONE | 0 |
  128594. * | FOGMODE_EXP | 1 |
  128595. * | FOGMODE_EXP2 | 2 |
  128596. * | FOGMODE_LINEAR | 3 |
  128597. */
  128598. set: function (value) {
  128599. if (this._fogMode === value) {
  128600. return;
  128601. }
  128602. this._fogMode = value;
  128603. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128604. },
  128605. enumerable: true,
  128606. configurable: true
  128607. });
  128608. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  128609. get: function () {
  128610. return this._shadowsEnabled;
  128611. },
  128612. /**
  128613. * Gets or sets a boolean indicating if shadows are enabled on this scene
  128614. */
  128615. set: function (value) {
  128616. if (this._shadowsEnabled === value) {
  128617. return;
  128618. }
  128619. this._shadowsEnabled = value;
  128620. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  128621. },
  128622. enumerable: true,
  128623. configurable: true
  128624. });
  128625. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  128626. get: function () {
  128627. return this._lightsEnabled;
  128628. },
  128629. /**
  128630. * Gets or sets a boolean indicating if lights are enabled on this scene
  128631. */
  128632. set: function (value) {
  128633. if (this._lightsEnabled === value) {
  128634. return;
  128635. }
  128636. this._lightsEnabled = value;
  128637. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  128638. },
  128639. enumerable: true,
  128640. configurable: true
  128641. });
  128642. Object.defineProperty(Scene.prototype, "activeCamera", {
  128643. /** Gets or sets the current active camera */
  128644. get: function () {
  128645. return this._activeCamera;
  128646. },
  128647. set: function (value) {
  128648. if (value === this._activeCamera) {
  128649. return;
  128650. }
  128651. this._activeCamera = value;
  128652. this.onActiveCameraChanged.notifyObservers(this);
  128653. },
  128654. enumerable: true,
  128655. configurable: true
  128656. });
  128657. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  128658. /** The default material used on meshes when no material is affected */
  128659. get: function () {
  128660. if (!this._defaultMaterial) {
  128661. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  128662. }
  128663. return this._defaultMaterial;
  128664. },
  128665. /** The default material used on meshes when no material is affected */
  128666. set: function (value) {
  128667. this._defaultMaterial = value;
  128668. },
  128669. enumerable: true,
  128670. configurable: true
  128671. });
  128672. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  128673. get: function () {
  128674. return this._texturesEnabled;
  128675. },
  128676. /**
  128677. * Gets or sets a boolean indicating if textures are enabled on this scene
  128678. */
  128679. set: function (value) {
  128680. if (this._texturesEnabled === value) {
  128681. return;
  128682. }
  128683. this._texturesEnabled = value;
  128684. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  128685. },
  128686. enumerable: true,
  128687. configurable: true
  128688. });
  128689. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  128690. get: function () {
  128691. return this._skeletonsEnabled;
  128692. },
  128693. /**
  128694. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  128695. */
  128696. set: function (value) {
  128697. if (this._skeletonsEnabled === value) {
  128698. return;
  128699. }
  128700. this._skeletonsEnabled = value;
  128701. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  128702. },
  128703. enumerable: true,
  128704. configurable: true
  128705. });
  128706. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  128707. /** @hidden */
  128708. get: function () {
  128709. if (!this._collisionCoordinator) {
  128710. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  128711. this._collisionCoordinator.init(this);
  128712. }
  128713. return this._collisionCoordinator;
  128714. },
  128715. enumerable: true,
  128716. configurable: true
  128717. });
  128718. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  128719. /** @hidden */
  128720. get: function () {
  128721. return this._alternateRendering;
  128722. },
  128723. enumerable: true,
  128724. configurable: true
  128725. });
  128726. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  128727. /**
  128728. * Gets the list of frustum planes (built from the active camera)
  128729. */
  128730. get: function () {
  128731. return this._frustumPlanes;
  128732. },
  128733. enumerable: true,
  128734. configurable: true
  128735. });
  128736. /**
  128737. * Registers the transient components if needed.
  128738. */
  128739. Scene.prototype._registerTransientComponents = function () {
  128740. // Register components that have been associated lately to the scene.
  128741. if (this._transientComponents.length > 0) {
  128742. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  128743. var component = _a[_i];
  128744. component.register();
  128745. }
  128746. this._transientComponents = [];
  128747. }
  128748. };
  128749. /**
  128750. * @hidden
  128751. * Add a component to the scene.
  128752. * Note that the ccomponent could be registered on th next frame if this is called after
  128753. * the register component stage.
  128754. * @param component Defines the component to add to the scene
  128755. */
  128756. Scene.prototype._addComponent = function (component) {
  128757. this._components.push(component);
  128758. this._transientComponents.push(component);
  128759. var serializableComponent = component;
  128760. if (serializableComponent.addFromContainer) {
  128761. this._serializableComponents.push(serializableComponent);
  128762. }
  128763. };
  128764. /**
  128765. * @hidden
  128766. * Gets a component from the scene.
  128767. * @param name defines the name of the component to retrieve
  128768. * @returns the component or null if not present
  128769. */
  128770. Scene.prototype._getComponent = function (name) {
  128771. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  128772. var component = _a[_i];
  128773. if (component.name === name) {
  128774. return component;
  128775. }
  128776. }
  128777. return null;
  128778. };
  128779. /**
  128780. * @hidden
  128781. */
  128782. Scene.prototype._getDefaultMeshCandidates = function () {
  128783. this._defaultMeshCandidates.data = this.meshes;
  128784. this._defaultMeshCandidates.length = this.meshes.length;
  128785. return this._defaultMeshCandidates;
  128786. };
  128787. /**
  128788. * @hidden
  128789. */
  128790. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  128791. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  128792. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  128793. return this._defaultSubMeshCandidates;
  128794. };
  128795. /**
  128796. * Sets the default candidate providers for the scene.
  128797. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  128798. * and getCollidingSubMeshCandidates to their default function
  128799. */
  128800. Scene.prototype.setDefaultCandidateProviders = function () {
  128801. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  128802. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128803. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128804. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128805. };
  128806. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  128807. /**
  128808. * Gets the mesh that is currently under the pointer
  128809. */
  128810. get: function () {
  128811. return this._pointerOverMesh;
  128812. },
  128813. enumerable: true,
  128814. configurable: true
  128815. });
  128816. Object.defineProperty(Scene.prototype, "pointerX", {
  128817. /**
  128818. * Gets or sets the current on-screen X position of the pointer
  128819. */
  128820. get: function () {
  128821. return this._pointerX;
  128822. },
  128823. set: function (value) {
  128824. this._pointerX = value;
  128825. },
  128826. enumerable: true,
  128827. configurable: true
  128828. });
  128829. Object.defineProperty(Scene.prototype, "pointerY", {
  128830. /**
  128831. * Gets or sets the current on-screen Y position of the pointer
  128832. */
  128833. get: function () {
  128834. return this._pointerY;
  128835. },
  128836. set: function (value) {
  128837. this._pointerY = value;
  128838. },
  128839. enumerable: true,
  128840. configurable: true
  128841. });
  128842. /**
  128843. * Gets the cached material (ie. the latest rendered one)
  128844. * @returns the cached material
  128845. */
  128846. Scene.prototype.getCachedMaterial = function () {
  128847. return this._cachedMaterial;
  128848. };
  128849. /**
  128850. * Gets the cached effect (ie. the latest rendered one)
  128851. * @returns the cached effect
  128852. */
  128853. Scene.prototype.getCachedEffect = function () {
  128854. return this._cachedEffect;
  128855. };
  128856. /**
  128857. * Gets the cached visibility state (ie. the latest rendered one)
  128858. * @returns the cached visibility state
  128859. */
  128860. Scene.prototype.getCachedVisibility = function () {
  128861. return this._cachedVisibility;
  128862. };
  128863. /**
  128864. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  128865. * @param material defines the current material
  128866. * @param effect defines the current effect
  128867. * @param visibility defines the current visibility state
  128868. * @returns true if one parameter is not cached
  128869. */
  128870. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  128871. if (visibility === void 0) { visibility = 1; }
  128872. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  128873. };
  128874. /**
  128875. * Gets the engine associated with the scene
  128876. * @returns an Engine
  128877. */
  128878. Scene.prototype.getEngine = function () {
  128879. return this._engine;
  128880. };
  128881. /**
  128882. * Gets the total number of vertices rendered per frame
  128883. * @returns the total number of vertices rendered per frame
  128884. */
  128885. Scene.prototype.getTotalVertices = function () {
  128886. return this._totalVertices.current;
  128887. };
  128888. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  128889. /**
  128890. * Gets the performance counter for total vertices
  128891. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128892. */
  128893. get: function () {
  128894. return this._totalVertices;
  128895. },
  128896. enumerable: true,
  128897. configurable: true
  128898. });
  128899. /**
  128900. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  128901. * @returns the total number of active indices rendered per frame
  128902. */
  128903. Scene.prototype.getActiveIndices = function () {
  128904. return this._activeIndices.current;
  128905. };
  128906. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  128907. /**
  128908. * Gets the performance counter for active indices
  128909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128910. */
  128911. get: function () {
  128912. return this._activeIndices;
  128913. },
  128914. enumerable: true,
  128915. configurable: true
  128916. });
  128917. /**
  128918. * Gets the total number of active particles rendered per frame
  128919. * @returns the total number of active particles rendered per frame
  128920. */
  128921. Scene.prototype.getActiveParticles = function () {
  128922. return this._activeParticles.current;
  128923. };
  128924. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  128925. /**
  128926. * Gets the performance counter for active particles
  128927. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128928. */
  128929. get: function () {
  128930. return this._activeParticles;
  128931. },
  128932. enumerable: true,
  128933. configurable: true
  128934. });
  128935. /**
  128936. * Gets the total number of active bones rendered per frame
  128937. * @returns the total number of active bones rendered per frame
  128938. */
  128939. Scene.prototype.getActiveBones = function () {
  128940. return this._activeBones.current;
  128941. };
  128942. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  128943. /**
  128944. * Gets the performance counter for active bones
  128945. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128946. */
  128947. get: function () {
  128948. return this._activeBones;
  128949. },
  128950. enumerable: true,
  128951. configurable: true
  128952. });
  128953. /**
  128954. * Gets the array of active meshes
  128955. * @returns an array of AbstractMesh
  128956. */
  128957. Scene.prototype.getActiveMeshes = function () {
  128958. return this._activeMeshes;
  128959. };
  128960. /**
  128961. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  128962. * @returns a number
  128963. */
  128964. Scene.prototype.getAnimationRatio = function () {
  128965. return this._animationRatio !== undefined ? this._animationRatio : 1;
  128966. };
  128967. /**
  128968. * Gets an unique Id for the current render phase
  128969. * @returns a number
  128970. */
  128971. Scene.prototype.getRenderId = function () {
  128972. return this._renderId;
  128973. };
  128974. /**
  128975. * Gets an unique Id for the current frame
  128976. * @returns a number
  128977. */
  128978. Scene.prototype.getFrameId = function () {
  128979. return this._frameId;
  128980. };
  128981. /** Call this function if you want to manually increment the render Id*/
  128982. Scene.prototype.incrementRenderId = function () {
  128983. this._renderId++;
  128984. };
  128985. Scene.prototype._updatePointerPosition = function (evt) {
  128986. var canvasRect = this._engine.getRenderingCanvasClientRect();
  128987. if (!canvasRect) {
  128988. return;
  128989. }
  128990. this._pointerX = evt.clientX - canvasRect.left;
  128991. this._pointerY = evt.clientY - canvasRect.top;
  128992. this._unTranslatedPointerX = this._pointerX;
  128993. this._unTranslatedPointerY = this._pointerY;
  128994. };
  128995. Scene.prototype._createUbo = function () {
  128996. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  128997. this._sceneUbo.addUniform("viewProjection", 16);
  128998. this._sceneUbo.addUniform("view", 16);
  128999. };
  129000. Scene.prototype._createAlternateUbo = function () {
  129001. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  129002. this._alternateSceneUbo.addUniform("viewProjection", 16);
  129003. this._alternateSceneUbo.addUniform("view", 16);
  129004. };
  129005. // Pointers handling
  129006. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  129007. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  129008. if (!pointerInfo.pickInfo.ray) {
  129009. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  129010. }
  129011. }
  129012. };
  129013. /**
  129014. * Use this method to simulate a pointer move on a mesh
  129015. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129016. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129017. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129018. * @returns the current scene
  129019. */
  129020. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  129021. var evt = new PointerEvent("pointermove", pointerEventInit);
  129022. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  129023. return this;
  129024. }
  129025. return this._processPointerMove(pickResult, evt);
  129026. };
  129027. Scene.prototype._processPointerMove = function (pickResult, evt) {
  129028. var canvas = this._engine.getRenderingCanvas();
  129029. if (!canvas) {
  129030. return this;
  129031. }
  129032. // Restore pointer
  129033. canvas.style.cursor = this.defaultCursor;
  129034. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  129035. if (isMeshPicked) {
  129036. this.setPointerOverMesh(pickResult.pickedMesh);
  129037. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  129038. if (this._pointerOverMesh.actionManager.hoverCursor) {
  129039. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  129040. }
  129041. else {
  129042. canvas.style.cursor = this.hoverCursor;
  129043. }
  129044. }
  129045. }
  129046. else {
  129047. this.setPointerOverMesh(null);
  129048. }
  129049. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  129050. var step = _a[_i];
  129051. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  129052. }
  129053. if (pickResult) {
  129054. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  129055. if (this.onPointerMove) {
  129056. this.onPointerMove(evt, pickResult, type);
  129057. }
  129058. if (this.onPointerObservable.hasObservers()) {
  129059. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129060. this._setRayOnPointerInfo(pi);
  129061. this.onPointerObservable.notifyObservers(pi, type);
  129062. }
  129063. }
  129064. return this;
  129065. };
  129066. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  129067. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  129068. if (pickResult) {
  129069. pi.ray = pickResult.ray;
  129070. }
  129071. this.onPrePointerObservable.notifyObservers(pi, type);
  129072. if (pi.skipOnPointerObservable) {
  129073. return true;
  129074. }
  129075. else {
  129076. return false;
  129077. }
  129078. };
  129079. /**
  129080. * Use this method to simulate a pointer down on a mesh
  129081. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129082. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129083. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129084. * @returns the current scene
  129085. */
  129086. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  129087. var evt = new PointerEvent("pointerdown", pointerEventInit);
  129088. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129089. return this;
  129090. }
  129091. return this._processPointerDown(pickResult, evt);
  129092. };
  129093. Scene.prototype._processPointerDown = function (pickResult, evt) {
  129094. var _this = this;
  129095. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  129096. this._pickedDownMesh = pickResult.pickedMesh;
  129097. var actionManager = pickResult.pickedMesh.actionManager;
  129098. if (actionManager) {
  129099. if (actionManager.hasPickTriggers) {
  129100. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129101. switch (evt.button) {
  129102. case 0:
  129103. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129104. break;
  129105. case 1:
  129106. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129107. break;
  129108. case 2:
  129109. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129110. break;
  129111. }
  129112. }
  129113. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  129114. window.setTimeout(function () {
  129115. 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_21__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  129116. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  129117. if (_this._totalPointersPressed !== 0 &&
  129118. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  129119. !_this._isPointerSwiping()) {
  129120. _this._startingPointerTime = 0;
  129121. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129122. }
  129123. }
  129124. }, Scene.LongPressDelay);
  129125. }
  129126. }
  129127. }
  129128. else {
  129129. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  129130. var step = _a[_i];
  129131. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129132. }
  129133. }
  129134. if (pickResult) {
  129135. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  129136. if (this.onPointerDown) {
  129137. this.onPointerDown(evt, pickResult, type);
  129138. }
  129139. if (this.onPointerObservable.hasObservers()) {
  129140. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129141. this._setRayOnPointerInfo(pi);
  129142. this.onPointerObservable.notifyObservers(pi, type);
  129143. }
  129144. }
  129145. return this;
  129146. };
  129147. /**
  129148. * Use this method to simulate a pointer up on a mesh
  129149. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129150. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129151. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129152. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  129153. * @returns the current scene
  129154. */
  129155. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  129156. var evt = new PointerEvent("pointerup", pointerEventInit);
  129157. var clickInfo = new ClickInfo();
  129158. if (doubleTap) {
  129159. clickInfo.doubleClick = true;
  129160. }
  129161. else {
  129162. clickInfo.singleClick = true;
  129163. }
  129164. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129165. return this;
  129166. }
  129167. return this._processPointerUp(pickResult, evt, clickInfo);
  129168. };
  129169. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  129170. if (pickResult && pickResult && pickResult.pickedMesh) {
  129171. this._pickedUpMesh = pickResult.pickedMesh;
  129172. if (this._pickedDownMesh === this._pickedUpMesh) {
  129173. if (this.onPointerPick) {
  129174. this.onPointerPick(evt, pickResult);
  129175. }
  129176. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  129177. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  129178. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  129179. this._setRayOnPointerInfo(pi);
  129180. this.onPointerObservable.notifyObservers(pi, type_1);
  129181. }
  129182. }
  129183. if (pickResult.pickedMesh.actionManager && !clickInfo.ignore) {
  129184. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129185. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  129186. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129187. }
  129188. if (clickInfo.doubleClick && pickResult.pickedMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129189. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129190. }
  129191. }
  129192. }
  129193. else {
  129194. if (!clickInfo.ignore) {
  129195. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  129196. var step = _a[_i];
  129197. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129198. }
  129199. }
  129200. }
  129201. if (this._pickedDownMesh &&
  129202. this._pickedDownMesh.actionManager &&
  129203. this._pickedDownMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger) &&
  129204. this._pickedDownMesh !== this._pickedUpMesh) {
  129205. this._pickedDownMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  129206. }
  129207. var type = 0;
  129208. if (this.onPointerObservable.hasObservers()) {
  129209. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  129210. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129211. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  129212. }
  129213. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129214. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  129215. }
  129216. if (type) {
  129217. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129218. this._setRayOnPointerInfo(pi);
  129219. this.onPointerObservable.notifyObservers(pi, type);
  129220. }
  129221. }
  129222. if (!clickInfo.ignore) {
  129223. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  129224. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129225. this._setRayOnPointerInfo(pi);
  129226. this.onPointerObservable.notifyObservers(pi, type);
  129227. }
  129228. }
  129229. if (this.onPointerUp && !clickInfo.ignore) {
  129230. this.onPointerUp(evt, pickResult, type);
  129231. }
  129232. return this;
  129233. };
  129234. /**
  129235. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  129236. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  129237. * @returns true if the pointer was captured
  129238. */
  129239. Scene.prototype.isPointerCaptured = function (pointerId) {
  129240. if (pointerId === void 0) { pointerId = 0; }
  129241. return this._pointerCaptures[pointerId];
  129242. };
  129243. /** @hidden */
  129244. Scene.prototype._isPointerSwiping = function () {
  129245. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  129246. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  129247. };
  129248. /**
  129249. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  129250. * @param attachUp defines if you want to attach events to pointerup
  129251. * @param attachDown defines if you want to attach events to pointerdown
  129252. * @param attachMove defines if you want to attach events to pointermove
  129253. */
  129254. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  129255. var _this = this;
  129256. if (attachUp === void 0) { attachUp = true; }
  129257. if (attachDown === void 0) { attachDown = true; }
  129258. if (attachMove === void 0) { attachMove = true; }
  129259. this._initActionManager = function (act, clickInfo) {
  129260. if (!_this._meshPickProceed) {
  129261. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129262. _this._currentPickResult = pickResult;
  129263. if (pickResult) {
  129264. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  129265. }
  129266. _this._meshPickProceed = true;
  129267. }
  129268. return act;
  129269. };
  129270. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  129271. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  129272. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  129273. btn !== _this._previousButtonPressed) {
  129274. _this._doubleClickOccured = false;
  129275. clickInfo.singleClick = true;
  129276. clickInfo.ignore = false;
  129277. cb(clickInfo, _this._currentPickResult);
  129278. }
  129279. };
  129280. this._initClickEvent = function (obs1, obs2, evt, cb) {
  129281. var clickInfo = new ClickInfo();
  129282. _this._currentPickResult = null;
  129283. var act = null;
  129284. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  129285. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  129286. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129287. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  129288. act = _this._initActionManager(act, clickInfo);
  129289. if (act) {
  129290. checkPicking = act.hasPickTriggers;
  129291. }
  129292. }
  129293. var needToIgnoreNext = false;
  129294. if (checkPicking) {
  129295. var btn = evt.button;
  129296. clickInfo.hasSwiped = _this._isPointerSwiping();
  129297. if (!clickInfo.hasSwiped) {
  129298. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  129299. if (!checkSingleClickImmediately) {
  129300. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  129301. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129302. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129303. act = _this._initActionManager(act, clickInfo);
  129304. if (act) {
  129305. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129306. }
  129307. }
  129308. }
  129309. if (checkSingleClickImmediately) {
  129310. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  129311. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  129312. btn !== _this._previousButtonPressed) {
  129313. clickInfo.singleClick = true;
  129314. cb(clickInfo, _this._currentPickResult);
  129315. needToIgnoreNext = true;
  129316. }
  129317. }
  129318. // at least one double click is required to be check and exclusive double click is enabled
  129319. else {
  129320. // wait that no double click has been raised during the double click delay
  129321. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129322. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  129323. }
  129324. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  129325. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129326. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129327. act = _this._initActionManager(act, clickInfo);
  129328. if (act) {
  129329. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129330. }
  129331. }
  129332. if (checkDoubleClick) {
  129333. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  129334. if (btn === _this._previousButtonPressed &&
  129335. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  129336. !_this._doubleClickOccured) {
  129337. // pointer has not moved for 2 clicks, it's a double click
  129338. if (!clickInfo.hasSwiped &&
  129339. !_this._isPointerSwiping()) {
  129340. _this._previousStartingPointerTime = 0;
  129341. _this._doubleClickOccured = true;
  129342. clickInfo.doubleClick = true;
  129343. clickInfo.ignore = false;
  129344. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  129345. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  129346. }
  129347. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129348. cb(clickInfo, _this._currentPickResult);
  129349. }
  129350. // if the two successive clicks are too far, it's just two simple clicks
  129351. else {
  129352. _this._doubleClickOccured = false;
  129353. _this._previousStartingPointerTime = _this._startingPointerTime;
  129354. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  129355. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  129356. _this._previousButtonPressed = btn;
  129357. if (Scene.ExclusiveDoubleClickMode) {
  129358. if (_this._previousDelayedSimpleClickTimeout) {
  129359. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  129360. }
  129361. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129362. cb(clickInfo, _this._previousPickResult);
  129363. }
  129364. else {
  129365. cb(clickInfo, _this._currentPickResult);
  129366. }
  129367. }
  129368. needToIgnoreNext = true;
  129369. }
  129370. // just the first click of the double has been raised
  129371. else {
  129372. _this._doubleClickOccured = false;
  129373. _this._previousStartingPointerTime = _this._startingPointerTime;
  129374. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  129375. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  129376. _this._previousButtonPressed = btn;
  129377. }
  129378. }
  129379. }
  129380. }
  129381. if (!needToIgnoreNext) {
  129382. cb(clickInfo, _this._currentPickResult);
  129383. }
  129384. };
  129385. this._onPointerMove = function (evt) {
  129386. _this._updatePointerPosition(evt);
  129387. // PreObservable support
  129388. 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)) {
  129389. return;
  129390. }
  129391. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129392. return;
  129393. }
  129394. if (!_this.pointerMovePredicate) {
  129395. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  129396. }
  129397. // Meshes
  129398. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  129399. _this._processPointerMove(pickResult, evt);
  129400. };
  129401. this._onPointerDown = function (evt) {
  129402. _this._totalPointersPressed++;
  129403. _this._pickedDownMesh = null;
  129404. _this._meshPickProceed = false;
  129405. _this._updatePointerPosition(evt);
  129406. if (_this.preventDefaultOnPointerDown && canvas) {
  129407. evt.preventDefault();
  129408. canvas.focus();
  129409. }
  129410. _this._startingPointerPosition.x = _this._pointerX;
  129411. _this._startingPointerPosition.y = _this._pointerY;
  129412. _this._startingPointerTime = Date.now();
  129413. // PreObservable support
  129414. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129415. return;
  129416. }
  129417. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129418. return;
  129419. }
  129420. _this._pointerCaptures[evt.pointerId] = true;
  129421. if (!_this.pointerDownPredicate) {
  129422. _this.pointerDownPredicate = function (mesh) {
  129423. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129424. };
  129425. }
  129426. // Meshes
  129427. _this._pickedDownMesh = null;
  129428. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129429. _this._processPointerDown(pickResult, evt);
  129430. };
  129431. this._onPointerUp = function (evt) {
  129432. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  129433. return; // So we need to test it the pointer down was pressed before.
  129434. }
  129435. _this._totalPointersPressed--;
  129436. _this._pickedUpMesh = null;
  129437. _this._meshPickProceed = false;
  129438. _this._updatePointerPosition(evt);
  129439. if (_this.preventDefaultOnPointerUp && canvas) {
  129440. evt.preventDefault();
  129441. canvas.focus();
  129442. }
  129443. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  129444. _this._pointerCaptures[evt.pointerId] = false;
  129445. // PreObservable support
  129446. if (_this.onPrePointerObservable.hasObservers()) {
  129447. if (!clickInfo.ignore) {
  129448. if (!clickInfo.hasSwiped) {
  129449. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129450. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129451. return;
  129452. }
  129453. }
  129454. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129455. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129456. return;
  129457. }
  129458. }
  129459. }
  129460. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129461. return;
  129462. }
  129463. }
  129464. }
  129465. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129466. return;
  129467. }
  129468. if (!_this.pointerUpPredicate) {
  129469. _this.pointerUpPredicate = function (mesh) {
  129470. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129471. };
  129472. }
  129473. // Meshes
  129474. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  129475. _this._initActionManager(null, clickInfo);
  129476. }
  129477. if (!pickResult) {
  129478. pickResult = _this._currentPickResult;
  129479. }
  129480. _this._processPointerUp(pickResult, evt, clickInfo);
  129481. _this._previousPickResult = _this._currentPickResult;
  129482. });
  129483. };
  129484. this._onKeyDown = function (evt) {
  129485. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  129486. if (_this.onPreKeyboardObservable.hasObservers()) {
  129487. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129488. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129489. if (pi.skipOnPointerObservable) {
  129490. return;
  129491. }
  129492. }
  129493. if (_this.onKeyboardObservable.hasObservers()) {
  129494. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129495. _this.onKeyboardObservable.notifyObservers(pi, type);
  129496. }
  129497. if (_this.actionManager) {
  129498. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129499. }
  129500. };
  129501. this._onKeyUp = function (evt) {
  129502. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  129503. if (_this.onPreKeyboardObservable.hasObservers()) {
  129504. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129505. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129506. if (pi.skipOnPointerObservable) {
  129507. return;
  129508. }
  129509. }
  129510. if (_this.onKeyboardObservable.hasObservers()) {
  129511. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129512. _this.onKeyboardObservable.notifyObservers(pi, type);
  129513. }
  129514. if (_this.actionManager) {
  129515. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129516. }
  129517. };
  129518. var engine = this.getEngine();
  129519. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  129520. if (!canvas) {
  129521. return;
  129522. }
  129523. canvas.addEventListener("keydown", _this._onKeyDown, false);
  129524. canvas.addEventListener("keyup", _this._onKeyUp, false);
  129525. });
  129526. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  129527. if (!canvas) {
  129528. return;
  129529. }
  129530. canvas.removeEventListener("keydown", _this._onKeyDown);
  129531. canvas.removeEventListener("keyup", _this._onKeyUp);
  129532. });
  129533. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129534. var canvas = this._engine.getRenderingCanvas();
  129535. if (!canvas) {
  129536. return;
  129537. }
  129538. if (attachMove) {
  129539. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  129540. // Wheel
  129541. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  129542. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  129543. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  129544. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  129545. }
  129546. if (attachDown) {
  129547. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  129548. }
  129549. if (attachUp) {
  129550. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  129551. }
  129552. canvas.tabIndex = 1;
  129553. };
  129554. /** Detaches all event handlers*/
  129555. Scene.prototype.detachControl = function () {
  129556. var engine = this.getEngine();
  129557. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129558. var canvas = engine.getRenderingCanvas();
  129559. if (!canvas) {
  129560. return;
  129561. }
  129562. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  129563. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  129564. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  129565. if (this._onCanvasBlurObserver) {
  129566. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  129567. }
  129568. if (this._onCanvasFocusObserver) {
  129569. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  129570. }
  129571. // Wheel
  129572. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  129573. // Keyboard
  129574. canvas.removeEventListener("keydown", this._onKeyDown);
  129575. canvas.removeEventListener("keyup", this._onKeyUp);
  129576. // Observables
  129577. this.onKeyboardObservable.clear();
  129578. this.onPreKeyboardObservable.clear();
  129579. this.onPointerObservable.clear();
  129580. this.onPrePointerObservable.clear();
  129581. };
  129582. /**
  129583. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  129584. * Delay loaded resources are not taking in account
  129585. * @return true if all required resources are ready
  129586. */
  129587. Scene.prototype.isReady = function () {
  129588. if (this._isDisposed) {
  129589. return false;
  129590. }
  129591. var index;
  129592. var engine = this.getEngine();
  129593. // Effects
  129594. if (!engine.areAllEffectsReady()) {
  129595. return false;
  129596. }
  129597. // Pending data
  129598. if (this._pendingData.length > 0) {
  129599. return false;
  129600. }
  129601. // Meshes
  129602. for (index = 0; index < this.meshes.length; index++) {
  129603. var mesh = this.meshes[index];
  129604. if (!mesh.isEnabled()) {
  129605. continue;
  129606. }
  129607. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  129608. continue;
  129609. }
  129610. if (!mesh.isReady(true)) {
  129611. return false;
  129612. }
  129613. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  129614. // Is Ready For Mesh
  129615. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  129616. var step = _a[_i];
  129617. if (!step.action(mesh, hardwareInstancedRendering)) {
  129618. return false;
  129619. }
  129620. }
  129621. }
  129622. // Geometries
  129623. for (index = 0; index < this.geometries.length; index++) {
  129624. var geometry = this.geometries[index];
  129625. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  129626. return false;
  129627. }
  129628. }
  129629. // Post-processes
  129630. if (this.activeCameras && this.activeCameras.length > 0) {
  129631. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  129632. var camera = _c[_b];
  129633. if (!camera.isReady(true)) {
  129634. return false;
  129635. }
  129636. }
  129637. }
  129638. else if (this.activeCamera) {
  129639. if (!this.activeCamera.isReady(true)) {
  129640. return false;
  129641. }
  129642. }
  129643. // Particles
  129644. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  129645. var particleSystem = _e[_d];
  129646. if (!particleSystem.isReady()) {
  129647. return false;
  129648. }
  129649. }
  129650. return true;
  129651. };
  129652. /** Resets all cached information relative to material (including effect and visibility) */
  129653. Scene.prototype.resetCachedMaterial = function () {
  129654. this._cachedMaterial = null;
  129655. this._cachedEffect = null;
  129656. this._cachedVisibility = null;
  129657. };
  129658. /**
  129659. * Registers a function to be called before every frame render
  129660. * @param func defines the function to register
  129661. */
  129662. Scene.prototype.registerBeforeRender = function (func) {
  129663. this.onBeforeRenderObservable.add(func);
  129664. };
  129665. /**
  129666. * Unregisters a function called before every frame render
  129667. * @param func defines the function to unregister
  129668. */
  129669. Scene.prototype.unregisterBeforeRender = function (func) {
  129670. this.onBeforeRenderObservable.removeCallback(func);
  129671. };
  129672. /**
  129673. * Registers a function to be called after every frame render
  129674. * @param func defines the function to register
  129675. */
  129676. Scene.prototype.registerAfterRender = function (func) {
  129677. this.onAfterRenderObservable.add(func);
  129678. };
  129679. /**
  129680. * Unregisters a function called after every frame render
  129681. * @param func defines the function to unregister
  129682. */
  129683. Scene.prototype.unregisterAfterRender = function (func) {
  129684. this.onAfterRenderObservable.removeCallback(func);
  129685. };
  129686. Scene.prototype._executeOnceBeforeRender = function (func) {
  129687. var _this = this;
  129688. var execFunc = function () {
  129689. func();
  129690. setTimeout(function () {
  129691. _this.unregisterBeforeRender(execFunc);
  129692. });
  129693. };
  129694. this.registerBeforeRender(execFunc);
  129695. };
  129696. /**
  129697. * The provided function will run before render once and will be disposed afterwards.
  129698. * A timeout delay can be provided so that the function will be executed in N ms.
  129699. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  129700. * @param func The function to be executed.
  129701. * @param timeout optional delay in ms
  129702. */
  129703. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  129704. var _this = this;
  129705. if (timeout !== undefined) {
  129706. setTimeout(function () {
  129707. _this._executeOnceBeforeRender(func);
  129708. }, timeout);
  129709. }
  129710. else {
  129711. this._executeOnceBeforeRender(func);
  129712. }
  129713. };
  129714. /** @hidden */
  129715. Scene.prototype._addPendingData = function (data) {
  129716. this._pendingData.push(data);
  129717. };
  129718. /** @hidden */
  129719. Scene.prototype._removePendingData = function (data) {
  129720. var wasLoading = this.isLoading;
  129721. var index = this._pendingData.indexOf(data);
  129722. if (index !== -1) {
  129723. this._pendingData.splice(index, 1);
  129724. }
  129725. if (wasLoading && !this.isLoading) {
  129726. this.onDataLoadedObservable.notifyObservers(this);
  129727. }
  129728. };
  129729. /**
  129730. * Returns the number of items waiting to be loaded
  129731. * @returns the number of items waiting to be loaded
  129732. */
  129733. Scene.prototype.getWaitingItemsCount = function () {
  129734. return this._pendingData.length;
  129735. };
  129736. Object.defineProperty(Scene.prototype, "isLoading", {
  129737. /**
  129738. * Returns a boolean indicating if the scene is still loading data
  129739. */
  129740. get: function () {
  129741. return this._pendingData.length > 0;
  129742. },
  129743. enumerable: true,
  129744. configurable: true
  129745. });
  129746. /**
  129747. * Registers a function to be executed when the scene is ready
  129748. * @param {Function} func - the function to be executed
  129749. */
  129750. Scene.prototype.executeWhenReady = function (func) {
  129751. var _this = this;
  129752. this.onReadyObservable.add(func);
  129753. if (this._executeWhenReadyTimeoutId !== -1) {
  129754. return;
  129755. }
  129756. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129757. _this._checkIsReady();
  129758. }, 150);
  129759. };
  129760. /**
  129761. * Returns a promise that resolves when the scene is ready
  129762. * @returns A promise that resolves when the scene is ready
  129763. */
  129764. Scene.prototype.whenReadyAsync = function () {
  129765. var _this = this;
  129766. return new Promise(function (resolve) {
  129767. _this.executeWhenReady(function () {
  129768. resolve();
  129769. });
  129770. });
  129771. };
  129772. /** @hidden */
  129773. Scene.prototype._checkIsReady = function () {
  129774. var _this = this;
  129775. this._registerTransientComponents();
  129776. if (this.isReady()) {
  129777. this.onReadyObservable.notifyObservers(this);
  129778. this.onReadyObservable.clear();
  129779. this._executeWhenReadyTimeoutId = -1;
  129780. return;
  129781. }
  129782. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129783. _this._checkIsReady();
  129784. }, 150);
  129785. };
  129786. Object.defineProperty(Scene.prototype, "animatables", {
  129787. /**
  129788. * Gets all animatable attached to the scene
  129789. */
  129790. get: function () {
  129791. return this._activeAnimatables;
  129792. },
  129793. enumerable: true,
  129794. configurable: true
  129795. });
  129796. /**
  129797. * Resets the last animation time frame.
  129798. * Useful to override when animations start running when loading a scene for the first time.
  129799. */
  129800. Scene.prototype.resetLastAnimationTimeFrame = function () {
  129801. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  129802. };
  129803. // Matrix
  129804. /** @hidden */
  129805. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  129806. this._useAlternateCameraConfiguration = active;
  129807. };
  129808. /**
  129809. * Gets the current view matrix
  129810. * @returns a Matrix
  129811. */
  129812. Scene.prototype.getViewMatrix = function () {
  129813. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  129814. };
  129815. /**
  129816. * Gets the current projection matrix
  129817. * @returns a Matrix
  129818. */
  129819. Scene.prototype.getProjectionMatrix = function () {
  129820. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  129821. };
  129822. /**
  129823. * Gets the current transform matrix
  129824. * @returns a Matrix made of View * Projection
  129825. */
  129826. Scene.prototype.getTransformMatrix = function () {
  129827. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  129828. };
  129829. /**
  129830. * Sets the current transform matrix
  129831. * @param view defines the View matrix to use
  129832. * @param projection defines the Projection matrix to use
  129833. */
  129834. Scene.prototype.setTransformMatrix = function (view, projection) {
  129835. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  129836. return;
  129837. }
  129838. this._viewUpdateFlag = view.updateFlag;
  129839. this._projectionUpdateFlag = projection.updateFlag;
  129840. this._viewMatrix = view;
  129841. this._projectionMatrix = projection;
  129842. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  129843. // Update frustum
  129844. if (!this._frustumPlanes) {
  129845. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  129846. }
  129847. else {
  129848. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  129849. }
  129850. if (this.activeCamera && this.activeCamera._alternateCamera) {
  129851. var otherCamera = this.activeCamera._alternateCamera;
  129852. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  129853. _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
  129854. }
  129855. if (this._sceneUbo.useUbo) {
  129856. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  129857. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  129858. this._sceneUbo.update();
  129859. }
  129860. };
  129861. /** @hidden */
  129862. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  129863. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  129864. return;
  129865. }
  129866. this._alternateViewUpdateFlag = view.updateFlag;
  129867. this._alternateProjectionUpdateFlag = projection.updateFlag;
  129868. this._alternateViewMatrix = view;
  129869. this._alternateProjectionMatrix = projection;
  129870. if (!this._alternateTransformMatrix) {
  129871. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  129872. }
  129873. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  129874. if (!this._alternateSceneUbo) {
  129875. this._createAlternateUbo();
  129876. }
  129877. if (this._alternateSceneUbo.useUbo) {
  129878. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  129879. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  129880. this._alternateSceneUbo.update();
  129881. }
  129882. };
  129883. /**
  129884. * Gets the uniform buffer used to store scene data
  129885. * @returns a UniformBuffer
  129886. */
  129887. Scene.prototype.getSceneUniformBuffer = function () {
  129888. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  129889. };
  129890. /**
  129891. * Gets an unique (relatively to the current scene) Id
  129892. * @returns an unique number for the scene
  129893. */
  129894. Scene.prototype.getUniqueId = function () {
  129895. var result = Scene._uniqueIdCounter;
  129896. Scene._uniqueIdCounter++;
  129897. return result;
  129898. };
  129899. /**
  129900. * Add a mesh to the list of scene's meshes
  129901. * @param newMesh defines the mesh to add
  129902. * @param recursive if all child meshes should also be added to the scene
  129903. */
  129904. Scene.prototype.addMesh = function (newMesh, recursive) {
  129905. var _this = this;
  129906. if (recursive === void 0) { recursive = false; }
  129907. this.meshes.push(newMesh);
  129908. newMesh._resyncLightSources();
  129909. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  129910. if (recursive) {
  129911. newMesh.getChildMeshes().forEach(function (m) {
  129912. _this.addMesh(m);
  129913. });
  129914. }
  129915. };
  129916. /**
  129917. * Remove a mesh for the list of scene's meshes
  129918. * @param toRemove defines the mesh to remove
  129919. * @param recursive if all child meshes should also be removed from the scene
  129920. * @returns the index where the mesh was in the mesh list
  129921. */
  129922. Scene.prototype.removeMesh = function (toRemove, recursive) {
  129923. var _this = this;
  129924. if (recursive === void 0) { recursive = false; }
  129925. var index = this.meshes.indexOf(toRemove);
  129926. if (index !== -1) {
  129927. // Remove from the scene if mesh found
  129928. this.meshes[index] = this.meshes[this.meshes.length - 1];
  129929. this.meshes.pop();
  129930. }
  129931. this.onMeshRemovedObservable.notifyObservers(toRemove);
  129932. if (recursive) {
  129933. toRemove.getChildMeshes().forEach(function (m) {
  129934. _this.removeMesh(m);
  129935. });
  129936. }
  129937. return index;
  129938. };
  129939. /**
  129940. * Add a transform node to the list of scene's transform nodes
  129941. * @param newTransformNode defines the transform node to add
  129942. */
  129943. Scene.prototype.addTransformNode = function (newTransformNode) {
  129944. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  129945. this.transformNodes.push(newTransformNode);
  129946. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  129947. };
  129948. /**
  129949. * Remove a transform node for the list of scene's transform nodes
  129950. * @param toRemove defines the transform node to remove
  129951. * @returns the index where the transform node was in the transform node list
  129952. */
  129953. Scene.prototype.removeTransformNode = function (toRemove) {
  129954. var index = toRemove._indexInSceneTransformNodesArray;
  129955. if (index !== -1) {
  129956. if (index !== this.transformNodes.length - 1) {
  129957. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  129958. this.transformNodes[index] = lastNode;
  129959. lastNode._indexInSceneTransformNodesArray = index;
  129960. }
  129961. toRemove._indexInSceneTransformNodesArray = -1;
  129962. this.transformNodes.pop();
  129963. }
  129964. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  129965. return index;
  129966. };
  129967. /**
  129968. * Remove a skeleton for the list of scene's skeletons
  129969. * @param toRemove defines the skeleton to remove
  129970. * @returns the index where the skeleton was in the skeleton list
  129971. */
  129972. Scene.prototype.removeSkeleton = function (toRemove) {
  129973. var index = this.skeletons.indexOf(toRemove);
  129974. if (index !== -1) {
  129975. // Remove from the scene if found
  129976. this.skeletons.splice(index, 1);
  129977. }
  129978. return index;
  129979. };
  129980. /**
  129981. * Remove a morph target for the list of scene's morph targets
  129982. * @param toRemove defines the morph target to remove
  129983. * @returns the index where the morph target was in the morph target list
  129984. */
  129985. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  129986. var index = this.morphTargetManagers.indexOf(toRemove);
  129987. if (index !== -1) {
  129988. // Remove from the scene if found
  129989. this.morphTargetManagers.splice(index, 1);
  129990. }
  129991. return index;
  129992. };
  129993. /**
  129994. * Remove a light for the list of scene's lights
  129995. * @param toRemove defines the light to remove
  129996. * @returns the index where the light was in the light list
  129997. */
  129998. Scene.prototype.removeLight = function (toRemove) {
  129999. var index = this.lights.indexOf(toRemove);
  130000. if (index !== -1) {
  130001. // Remove from meshes
  130002. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  130003. var mesh = _a[_i];
  130004. mesh._removeLightSource(toRemove);
  130005. }
  130006. // Remove from the scene if mesh found
  130007. this.lights.splice(index, 1);
  130008. this.sortLightsByPriority();
  130009. }
  130010. this.onLightRemovedObservable.notifyObservers(toRemove);
  130011. return index;
  130012. };
  130013. /**
  130014. * Remove a camera for the list of scene's cameras
  130015. * @param toRemove defines the camera to remove
  130016. * @returns the index where the camera was in the camera list
  130017. */
  130018. Scene.prototype.removeCamera = function (toRemove) {
  130019. var index = this.cameras.indexOf(toRemove);
  130020. if (index !== -1) {
  130021. // Remove from the scene if mesh found
  130022. this.cameras.splice(index, 1);
  130023. }
  130024. // Remove from activeCameras
  130025. var index2 = this.activeCameras.indexOf(toRemove);
  130026. if (index2 !== -1) {
  130027. // Remove from the scene if mesh found
  130028. this.activeCameras.splice(index2, 1);
  130029. }
  130030. // Reset the activeCamera
  130031. if (this.activeCamera === toRemove) {
  130032. if (this.cameras.length > 0) {
  130033. this.activeCamera = this.cameras[0];
  130034. }
  130035. else {
  130036. this.activeCamera = null;
  130037. }
  130038. }
  130039. this.onCameraRemovedObservable.notifyObservers(toRemove);
  130040. return index;
  130041. };
  130042. /**
  130043. * Remove a particle system for the list of scene's particle systems
  130044. * @param toRemove defines the particle system to remove
  130045. * @returns the index where the particle system was in the particle system list
  130046. */
  130047. Scene.prototype.removeParticleSystem = function (toRemove) {
  130048. var index = this.particleSystems.indexOf(toRemove);
  130049. if (index !== -1) {
  130050. this.particleSystems.splice(index, 1);
  130051. }
  130052. return index;
  130053. };
  130054. /**
  130055. * Remove a animation for the list of scene's animations
  130056. * @param toRemove defines the animation to remove
  130057. * @returns the index where the animation was in the animation list
  130058. */
  130059. Scene.prototype.removeAnimation = function (toRemove) {
  130060. var index = this.animations.indexOf(toRemove);
  130061. if (index !== -1) {
  130062. this.animations.splice(index, 1);
  130063. }
  130064. return index;
  130065. };
  130066. /**
  130067. * Removes the given animation group from this scene.
  130068. * @param toRemove The animation group to remove
  130069. * @returns The index of the removed animation group
  130070. */
  130071. Scene.prototype.removeAnimationGroup = function (toRemove) {
  130072. var index = this.animationGroups.indexOf(toRemove);
  130073. if (index !== -1) {
  130074. this.animationGroups.splice(index, 1);
  130075. }
  130076. return index;
  130077. };
  130078. /**
  130079. * Removes the given multi-material from this scene.
  130080. * @param toRemove The multi-material to remove
  130081. * @returns The index of the removed multi-material
  130082. */
  130083. Scene.prototype.removeMultiMaterial = function (toRemove) {
  130084. var index = this.multiMaterials.indexOf(toRemove);
  130085. if (index !== -1) {
  130086. this.multiMaterials.splice(index, 1);
  130087. }
  130088. return index;
  130089. };
  130090. /**
  130091. * Removes the given material from this scene.
  130092. * @param toRemove The material to remove
  130093. * @returns The index of the removed material
  130094. */
  130095. Scene.prototype.removeMaterial = function (toRemove) {
  130096. var index = toRemove._indexInSceneMaterialArray;
  130097. if (index !== -1 && index < this.materials.length) {
  130098. if (index !== this.materials.length - 1) {
  130099. var lastMaterial = this.materials[this.materials.length - 1];
  130100. this.materials[index] = lastMaterial;
  130101. lastMaterial._indexInSceneMaterialArray = index;
  130102. }
  130103. toRemove._indexInSceneMaterialArray = -1;
  130104. this.materials.pop();
  130105. }
  130106. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  130107. return index;
  130108. };
  130109. /**
  130110. * Removes the given action manager from this scene.
  130111. * @param toRemove The action manager to remove
  130112. * @returns The index of the removed action manager
  130113. */
  130114. Scene.prototype.removeActionManager = function (toRemove) {
  130115. var index = this.actionManagers.indexOf(toRemove);
  130116. if (index !== -1) {
  130117. this.actionManagers.splice(index, 1);
  130118. }
  130119. return index;
  130120. };
  130121. /**
  130122. * Removes the given texture from this scene.
  130123. * @param toRemove The texture to remove
  130124. * @returns The index of the removed texture
  130125. */
  130126. Scene.prototype.removeTexture = function (toRemove) {
  130127. var index = this.textures.indexOf(toRemove);
  130128. if (index !== -1) {
  130129. this.textures.splice(index, 1);
  130130. }
  130131. this.onTextureRemovedObservable.notifyObservers(toRemove);
  130132. return index;
  130133. };
  130134. /**
  130135. * Adds the given light to this scene
  130136. * @param newLight The light to add
  130137. */
  130138. Scene.prototype.addLight = function (newLight) {
  130139. this.lights.push(newLight);
  130140. this.sortLightsByPriority();
  130141. // Add light to all meshes (To support if the light is removed and then readded)
  130142. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  130143. var mesh = _a[_i];
  130144. if (mesh._lightSources.indexOf(newLight) === -1) {
  130145. mesh._lightSources.push(newLight);
  130146. mesh._resyncLightSources();
  130147. }
  130148. }
  130149. this.onNewLightAddedObservable.notifyObservers(newLight);
  130150. };
  130151. /**
  130152. * Sorts the list list based on light priorities
  130153. */
  130154. Scene.prototype.sortLightsByPriority = function () {
  130155. if (this.requireLightSorting) {
  130156. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  130157. }
  130158. };
  130159. /**
  130160. * Adds the given camera to this scene
  130161. * @param newCamera The camera to add
  130162. */
  130163. Scene.prototype.addCamera = function (newCamera) {
  130164. this.cameras.push(newCamera);
  130165. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  130166. };
  130167. /**
  130168. * Adds the given skeleton to this scene
  130169. * @param newSkeleton The skeleton to add
  130170. */
  130171. Scene.prototype.addSkeleton = function (newSkeleton) {
  130172. this.skeletons.push(newSkeleton);
  130173. };
  130174. /**
  130175. * Adds the given particle system to this scene
  130176. * @param newParticleSystem The particle system to add
  130177. */
  130178. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  130179. this.particleSystems.push(newParticleSystem);
  130180. };
  130181. /**
  130182. * Adds the given animation to this scene
  130183. * @param newAnimation The animation to add
  130184. */
  130185. Scene.prototype.addAnimation = function (newAnimation) {
  130186. this.animations.push(newAnimation);
  130187. };
  130188. /**
  130189. * Adds the given animation group to this scene.
  130190. * @param newAnimationGroup The animation group to add
  130191. */
  130192. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  130193. this.animationGroups.push(newAnimationGroup);
  130194. };
  130195. /**
  130196. * Adds the given multi-material to this scene
  130197. * @param newMultiMaterial The multi-material to add
  130198. */
  130199. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  130200. this.multiMaterials.push(newMultiMaterial);
  130201. };
  130202. /**
  130203. * Adds the given material to this scene
  130204. * @param newMaterial The material to add
  130205. */
  130206. Scene.prototype.addMaterial = function (newMaterial) {
  130207. newMaterial._indexInSceneMaterialArray = this.materials.length;
  130208. this.materials.push(newMaterial);
  130209. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  130210. };
  130211. /**
  130212. * Adds the given morph target to this scene
  130213. * @param newMorphTargetManager The morph target to add
  130214. */
  130215. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  130216. this.morphTargetManagers.push(newMorphTargetManager);
  130217. };
  130218. /**
  130219. * Adds the given geometry to this scene
  130220. * @param newGeometry The geometry to add
  130221. */
  130222. Scene.prototype.addGeometry = function (newGeometry) {
  130223. if (this.geometriesByUniqueId) {
  130224. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  130225. }
  130226. this.geometries.push(newGeometry);
  130227. };
  130228. /**
  130229. * Adds the given action manager to this scene
  130230. * @param newActionManager The action manager to add
  130231. */
  130232. Scene.prototype.addActionManager = function (newActionManager) {
  130233. this.actionManagers.push(newActionManager);
  130234. };
  130235. /**
  130236. * Adds the given texture to this scene.
  130237. * @param newTexture The texture to add
  130238. */
  130239. Scene.prototype.addTexture = function (newTexture) {
  130240. this.textures.push(newTexture);
  130241. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  130242. };
  130243. /**
  130244. * Switch active camera
  130245. * @param newCamera defines the new active camera
  130246. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  130247. */
  130248. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  130249. if (attachControl === void 0) { attachControl = true; }
  130250. var canvas = this._engine.getRenderingCanvas();
  130251. if (!canvas) {
  130252. return;
  130253. }
  130254. if (this.activeCamera) {
  130255. this.activeCamera.detachControl(canvas);
  130256. }
  130257. this.activeCamera = newCamera;
  130258. if (attachControl) {
  130259. newCamera.attachControl(canvas);
  130260. }
  130261. };
  130262. /**
  130263. * sets the active camera of the scene using its ID
  130264. * @param id defines the camera's ID
  130265. * @return the new active camera or null if none found.
  130266. */
  130267. Scene.prototype.setActiveCameraByID = function (id) {
  130268. var camera = this.getCameraByID(id);
  130269. if (camera) {
  130270. this.activeCamera = camera;
  130271. return camera;
  130272. }
  130273. return null;
  130274. };
  130275. /**
  130276. * sets the active camera of the scene using its name
  130277. * @param name defines the camera's name
  130278. * @returns the new active camera or null if none found.
  130279. */
  130280. Scene.prototype.setActiveCameraByName = function (name) {
  130281. var camera = this.getCameraByName(name);
  130282. if (camera) {
  130283. this.activeCamera = camera;
  130284. return camera;
  130285. }
  130286. return null;
  130287. };
  130288. /**
  130289. * get an animation group using its name
  130290. * @param name defines the material's name
  130291. * @return the animation group or null if none found.
  130292. */
  130293. Scene.prototype.getAnimationGroupByName = function (name) {
  130294. for (var index = 0; index < this.animationGroups.length; index++) {
  130295. if (this.animationGroups[index].name === name) {
  130296. return this.animationGroups[index];
  130297. }
  130298. }
  130299. return null;
  130300. };
  130301. /**
  130302. * get a material using its id
  130303. * @param id defines the material's ID
  130304. * @return the material or null if none found.
  130305. */
  130306. Scene.prototype.getMaterialByID = function (id) {
  130307. for (var index = 0; index < this.materials.length; index++) {
  130308. if (this.materials[index].id === id) {
  130309. return this.materials[index];
  130310. }
  130311. }
  130312. return null;
  130313. };
  130314. /**
  130315. * Gets a material using its name
  130316. * @param name defines the material's name
  130317. * @return the material or null if none found.
  130318. */
  130319. Scene.prototype.getMaterialByName = function (name) {
  130320. for (var index = 0; index < this.materials.length; index++) {
  130321. if (this.materials[index].name === name) {
  130322. return this.materials[index];
  130323. }
  130324. }
  130325. return null;
  130326. };
  130327. /**
  130328. * Gets a camera using its id
  130329. * @param id defines the id to look for
  130330. * @returns the camera or null if not found
  130331. */
  130332. Scene.prototype.getCameraByID = function (id) {
  130333. for (var index = 0; index < this.cameras.length; index++) {
  130334. if (this.cameras[index].id === id) {
  130335. return this.cameras[index];
  130336. }
  130337. }
  130338. return null;
  130339. };
  130340. /**
  130341. * Gets a camera using its unique id
  130342. * @param uniqueId defines the unique id to look for
  130343. * @returns the camera or null if not found
  130344. */
  130345. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  130346. for (var index = 0; index < this.cameras.length; index++) {
  130347. if (this.cameras[index].uniqueId === uniqueId) {
  130348. return this.cameras[index];
  130349. }
  130350. }
  130351. return null;
  130352. };
  130353. /**
  130354. * Gets a camera using its name
  130355. * @param name defines the camera's name
  130356. * @return the camera or null if none found.
  130357. */
  130358. Scene.prototype.getCameraByName = function (name) {
  130359. for (var index = 0; index < this.cameras.length; index++) {
  130360. if (this.cameras[index].name === name) {
  130361. return this.cameras[index];
  130362. }
  130363. }
  130364. return null;
  130365. };
  130366. /**
  130367. * Gets a bone using its id
  130368. * @param id defines the bone's id
  130369. * @return the bone or null if not found
  130370. */
  130371. Scene.prototype.getBoneByID = function (id) {
  130372. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130373. var skeleton = this.skeletons[skeletonIndex];
  130374. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130375. if (skeleton.bones[boneIndex].id === id) {
  130376. return skeleton.bones[boneIndex];
  130377. }
  130378. }
  130379. }
  130380. return null;
  130381. };
  130382. /**
  130383. * Gets a bone using its id
  130384. * @param name defines the bone's name
  130385. * @return the bone or null if not found
  130386. */
  130387. Scene.prototype.getBoneByName = function (name) {
  130388. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130389. var skeleton = this.skeletons[skeletonIndex];
  130390. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130391. if (skeleton.bones[boneIndex].name === name) {
  130392. return skeleton.bones[boneIndex];
  130393. }
  130394. }
  130395. }
  130396. return null;
  130397. };
  130398. /**
  130399. * Gets a light node using its name
  130400. * @param name defines the the light's name
  130401. * @return the light or null if none found.
  130402. */
  130403. Scene.prototype.getLightByName = function (name) {
  130404. for (var index = 0; index < this.lights.length; index++) {
  130405. if (this.lights[index].name === name) {
  130406. return this.lights[index];
  130407. }
  130408. }
  130409. return null;
  130410. };
  130411. /**
  130412. * Gets a light node using its id
  130413. * @param id defines the light's id
  130414. * @return the light or null if none found.
  130415. */
  130416. Scene.prototype.getLightByID = function (id) {
  130417. for (var index = 0; index < this.lights.length; index++) {
  130418. if (this.lights[index].id === id) {
  130419. return this.lights[index];
  130420. }
  130421. }
  130422. return null;
  130423. };
  130424. /**
  130425. * Gets a light node using its scene-generated unique ID
  130426. * @param uniqueId defines the light's unique id
  130427. * @return the light or null if none found.
  130428. */
  130429. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  130430. for (var index = 0; index < this.lights.length; index++) {
  130431. if (this.lights[index].uniqueId === uniqueId) {
  130432. return this.lights[index];
  130433. }
  130434. }
  130435. return null;
  130436. };
  130437. /**
  130438. * Gets a particle system by id
  130439. * @param id defines the particle system id
  130440. * @return the corresponding system or null if none found
  130441. */
  130442. Scene.prototype.getParticleSystemByID = function (id) {
  130443. for (var index = 0; index < this.particleSystems.length; index++) {
  130444. if (this.particleSystems[index].id === id) {
  130445. return this.particleSystems[index];
  130446. }
  130447. }
  130448. return null;
  130449. };
  130450. /**
  130451. * Gets a geometry using its ID
  130452. * @param id defines the geometry's id
  130453. * @return the geometry or null if none found.
  130454. */
  130455. Scene.prototype.getGeometryByID = function (id) {
  130456. for (var index = 0; index < this.geometries.length; index++) {
  130457. if (this.geometries[index].id === id) {
  130458. return this.geometries[index];
  130459. }
  130460. }
  130461. return null;
  130462. };
  130463. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  130464. if (this.geometriesByUniqueId) {
  130465. var index_1 = this.geometriesByUniqueId[uniqueId];
  130466. if (index_1 !== undefined) {
  130467. return this.geometries[index_1];
  130468. }
  130469. }
  130470. else {
  130471. for (var index = 0; index < this.geometries.length; index++) {
  130472. if (this.geometries[index].uniqueId === uniqueId) {
  130473. return this.geometries[index];
  130474. }
  130475. }
  130476. }
  130477. return null;
  130478. };
  130479. /**
  130480. * Add a new geometry to this scene
  130481. * @param geometry defines the geometry to be added to the scene.
  130482. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  130483. * @return a boolean defining if the geometry was added or not
  130484. */
  130485. Scene.prototype.pushGeometry = function (geometry, force) {
  130486. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  130487. return false;
  130488. }
  130489. this.addGeometry(geometry);
  130490. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  130491. return true;
  130492. };
  130493. /**
  130494. * Removes an existing geometry
  130495. * @param geometry defines the geometry to be removed from the scene
  130496. * @return a boolean defining if the geometry was removed or not
  130497. */
  130498. Scene.prototype.removeGeometry = function (geometry) {
  130499. var index;
  130500. if (this.geometriesByUniqueId) {
  130501. index = this.geometriesByUniqueId[geometry.uniqueId];
  130502. if (index === undefined) {
  130503. return false;
  130504. }
  130505. }
  130506. else {
  130507. index = this.geometries.indexOf(geometry);
  130508. if (index < 0) {
  130509. return false;
  130510. }
  130511. }
  130512. if (index !== this.geometries.length - 1) {
  130513. var lastGeometry = this.geometries[this.geometries.length - 1];
  130514. this.geometries[index] = lastGeometry;
  130515. if (this.geometriesByUniqueId) {
  130516. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  130517. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  130518. }
  130519. }
  130520. this.geometries.pop();
  130521. this.onGeometryRemovedObservable.notifyObservers(geometry);
  130522. return true;
  130523. };
  130524. /**
  130525. * Gets the list of geometries attached to the scene
  130526. * @returns an array of Geometry
  130527. */
  130528. Scene.prototype.getGeometries = function () {
  130529. return this.geometries;
  130530. };
  130531. /**
  130532. * Gets the first added mesh found of a given ID
  130533. * @param id defines the id to search for
  130534. * @return the mesh found or null if not found at all
  130535. */
  130536. Scene.prototype.getMeshByID = function (id) {
  130537. for (var index = 0; index < this.meshes.length; index++) {
  130538. if (this.meshes[index].id === id) {
  130539. return this.meshes[index];
  130540. }
  130541. }
  130542. return null;
  130543. };
  130544. /**
  130545. * Gets a list of meshes using their id
  130546. * @param id defines the id to search for
  130547. * @returns a list of meshes
  130548. */
  130549. Scene.prototype.getMeshesByID = function (id) {
  130550. return this.meshes.filter(function (m) {
  130551. return m.id === id;
  130552. });
  130553. };
  130554. /**
  130555. * Gets the first added transform node found of a given ID
  130556. * @param id defines the id to search for
  130557. * @return the found transform node or null if not found at all.
  130558. */
  130559. Scene.prototype.getTransformNodeByID = function (id) {
  130560. for (var index = 0; index < this.transformNodes.length; index++) {
  130561. if (this.transformNodes[index].id === id) {
  130562. return this.transformNodes[index];
  130563. }
  130564. }
  130565. return null;
  130566. };
  130567. /**
  130568. * Gets a list of transform nodes using their id
  130569. * @param id defines the id to search for
  130570. * @returns a list of transform nodes
  130571. */
  130572. Scene.prototype.getTransformNodesByID = function (id) {
  130573. return this.transformNodes.filter(function (m) {
  130574. return m.id === id;
  130575. });
  130576. };
  130577. /**
  130578. * Gets a mesh with its auto-generated unique id
  130579. * @param uniqueId defines the unique id to search for
  130580. * @return the found mesh or null if not found at all.
  130581. */
  130582. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  130583. for (var index = 0; index < this.meshes.length; index++) {
  130584. if (this.meshes[index].uniqueId === uniqueId) {
  130585. return this.meshes[index];
  130586. }
  130587. }
  130588. return null;
  130589. };
  130590. /**
  130591. * Gets a the last added mesh using a given id
  130592. * @param id defines the id to search for
  130593. * @return the found mesh or null if not found at all.
  130594. */
  130595. Scene.prototype.getLastMeshByID = function (id) {
  130596. for (var index = this.meshes.length - 1; index >= 0; index--) {
  130597. if (this.meshes[index].id === id) {
  130598. return this.meshes[index];
  130599. }
  130600. }
  130601. return null;
  130602. };
  130603. /**
  130604. * Gets a the last added node (Mesh, Camera, Light) using a given id
  130605. * @param id defines the id to search for
  130606. * @return the found node or null if not found at all
  130607. */
  130608. Scene.prototype.getLastEntryByID = function (id) {
  130609. var index;
  130610. for (index = this.meshes.length - 1; index >= 0; index--) {
  130611. if (this.meshes[index].id === id) {
  130612. return this.meshes[index];
  130613. }
  130614. }
  130615. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  130616. if (this.transformNodes[index].id === id) {
  130617. return this.transformNodes[index];
  130618. }
  130619. }
  130620. for (index = this.cameras.length - 1; index >= 0; index--) {
  130621. if (this.cameras[index].id === id) {
  130622. return this.cameras[index];
  130623. }
  130624. }
  130625. for (index = this.lights.length - 1; index >= 0; index--) {
  130626. if (this.lights[index].id === id) {
  130627. return this.lights[index];
  130628. }
  130629. }
  130630. return null;
  130631. };
  130632. /**
  130633. * Gets a node (Mesh, Camera, Light) using a given id
  130634. * @param id defines the id to search for
  130635. * @return the found node or null if not found at all
  130636. */
  130637. Scene.prototype.getNodeByID = function (id) {
  130638. var mesh = this.getMeshByID(id);
  130639. if (mesh) {
  130640. return mesh;
  130641. }
  130642. var transformNode = this.getTransformNodeByID(id);
  130643. if (transformNode) {
  130644. return transformNode;
  130645. }
  130646. var light = this.getLightByID(id);
  130647. if (light) {
  130648. return light;
  130649. }
  130650. var camera = this.getCameraByID(id);
  130651. if (camera) {
  130652. return camera;
  130653. }
  130654. var bone = this.getBoneByID(id);
  130655. if (bone) {
  130656. return bone;
  130657. }
  130658. return null;
  130659. };
  130660. /**
  130661. * Gets a node (Mesh, Camera, Light) using a given name
  130662. * @param name defines the name to search for
  130663. * @return the found node or null if not found at all.
  130664. */
  130665. Scene.prototype.getNodeByName = function (name) {
  130666. var mesh = this.getMeshByName(name);
  130667. if (mesh) {
  130668. return mesh;
  130669. }
  130670. var transformNode = this.getTransformNodeByName(name);
  130671. if (transformNode) {
  130672. return transformNode;
  130673. }
  130674. var light = this.getLightByName(name);
  130675. if (light) {
  130676. return light;
  130677. }
  130678. var camera = this.getCameraByName(name);
  130679. if (camera) {
  130680. return camera;
  130681. }
  130682. var bone = this.getBoneByName(name);
  130683. if (bone) {
  130684. return bone;
  130685. }
  130686. return null;
  130687. };
  130688. /**
  130689. * Gets a mesh using a given name
  130690. * @param name defines the name to search for
  130691. * @return the found mesh or null if not found at all.
  130692. */
  130693. Scene.prototype.getMeshByName = function (name) {
  130694. for (var index = 0; index < this.meshes.length; index++) {
  130695. if (this.meshes[index].name === name) {
  130696. return this.meshes[index];
  130697. }
  130698. }
  130699. return null;
  130700. };
  130701. /**
  130702. * Gets a transform node using a given name
  130703. * @param name defines the name to search for
  130704. * @return the found transform node or null if not found at all.
  130705. */
  130706. Scene.prototype.getTransformNodeByName = function (name) {
  130707. for (var index = 0; index < this.transformNodes.length; index++) {
  130708. if (this.transformNodes[index].name === name) {
  130709. return this.transformNodes[index];
  130710. }
  130711. }
  130712. return null;
  130713. };
  130714. /**
  130715. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  130716. * @param id defines the id to search for
  130717. * @return the found skeleton or null if not found at all.
  130718. */
  130719. Scene.prototype.getLastSkeletonByID = function (id) {
  130720. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  130721. if (this.skeletons[index].id === id) {
  130722. return this.skeletons[index];
  130723. }
  130724. }
  130725. return null;
  130726. };
  130727. /**
  130728. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  130729. * @param id defines the id to search for
  130730. * @return the found skeleton or null if not found at all.
  130731. */
  130732. Scene.prototype.getSkeletonById = function (id) {
  130733. for (var index = 0; index < this.skeletons.length; index++) {
  130734. if (this.skeletons[index].id === id) {
  130735. return this.skeletons[index];
  130736. }
  130737. }
  130738. return null;
  130739. };
  130740. /**
  130741. * Gets a skeleton using a given name
  130742. * @param name defines the name to search for
  130743. * @return the found skeleton or null if not found at all.
  130744. */
  130745. Scene.prototype.getSkeletonByName = function (name) {
  130746. for (var index = 0; index < this.skeletons.length; index++) {
  130747. if (this.skeletons[index].name === name) {
  130748. return this.skeletons[index];
  130749. }
  130750. }
  130751. return null;
  130752. };
  130753. /**
  130754. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  130755. * @param id defines the id to search for
  130756. * @return the found morph target manager or null if not found at all.
  130757. */
  130758. Scene.prototype.getMorphTargetManagerById = function (id) {
  130759. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  130760. if (this.morphTargetManagers[index].uniqueId === id) {
  130761. return this.morphTargetManagers[index];
  130762. }
  130763. }
  130764. return null;
  130765. };
  130766. /**
  130767. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  130768. * @param id defines the id to search for
  130769. * @return the found morph target or null if not found at all.
  130770. */
  130771. Scene.prototype.getMorphTargetById = function (id) {
  130772. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  130773. var morphTargetManager = this.morphTargetManagers[managerIndex];
  130774. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  130775. var target = morphTargetManager.getTarget(index);
  130776. if (target.id === id) {
  130777. return target;
  130778. }
  130779. }
  130780. }
  130781. return null;
  130782. };
  130783. /**
  130784. * Gets a boolean indicating if the given mesh is active
  130785. * @param mesh defines the mesh to look for
  130786. * @returns true if the mesh is in the active list
  130787. */
  130788. Scene.prototype.isActiveMesh = function (mesh) {
  130789. return (this._activeMeshes.indexOf(mesh) !== -1);
  130790. };
  130791. Object.defineProperty(Scene.prototype, "uid", {
  130792. /**
  130793. * Return a unique id as a string which can serve as an identifier for the scene
  130794. */
  130795. get: function () {
  130796. if (!this._uid) {
  130797. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  130798. }
  130799. return this._uid;
  130800. },
  130801. enumerable: true,
  130802. configurable: true
  130803. });
  130804. /**
  130805. * Add an externaly attached data from its key.
  130806. * This method call will fail and return false, if such key already exists.
  130807. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  130808. * @param key the unique key that identifies the data
  130809. * @param data the data object to associate to the key for this Engine instance
  130810. * @return true if no such key were already present and the data was added successfully, false otherwise
  130811. */
  130812. Scene.prototype.addExternalData = function (key, data) {
  130813. if (!this._externalData) {
  130814. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130815. }
  130816. return this._externalData.add(key, data);
  130817. };
  130818. /**
  130819. * Get an externaly attached data from its key
  130820. * @param key the unique key that identifies the data
  130821. * @return the associated data, if present (can be null), or undefined if not present
  130822. */
  130823. Scene.prototype.getExternalData = function (key) {
  130824. if (!this._externalData) {
  130825. return null;
  130826. }
  130827. return this._externalData.get(key);
  130828. };
  130829. /**
  130830. * Get an externaly attached data from its key, create it using a factory if it's not already present
  130831. * @param key the unique key that identifies the data
  130832. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  130833. * @return the associated data, can be null if the factory returned null.
  130834. */
  130835. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  130836. if (!this._externalData) {
  130837. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130838. }
  130839. return this._externalData.getOrAddWithFactory(key, factory);
  130840. };
  130841. /**
  130842. * Remove an externaly attached data from the Engine instance
  130843. * @param key the unique key that identifies the data
  130844. * @return true if the data was successfully removed, false if it doesn't exist
  130845. */
  130846. Scene.prototype.removeExternalData = function (key) {
  130847. return this._externalData.remove(key);
  130848. };
  130849. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  130850. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  130851. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  130852. var step = _a[_i];
  130853. step.action(mesh, subMesh);
  130854. }
  130855. var material = subMesh.getMaterial();
  130856. if (material !== null && material !== undefined) {
  130857. // Render targets
  130858. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  130859. if (this._processedMaterials.indexOf(material) === -1) {
  130860. this._processedMaterials.push(material);
  130861. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  130862. }
  130863. }
  130864. // Dispatch
  130865. this._activeIndices.addCount(subMesh.indexCount, false);
  130866. this._renderingManager.dispatch(subMesh, mesh, material);
  130867. }
  130868. }
  130869. };
  130870. /**
  130871. * Clear the processed materials smart array preventing retention point in material dispose.
  130872. */
  130873. Scene.prototype.freeProcessedMaterials = function () {
  130874. this._processedMaterials.dispose();
  130875. };
  130876. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  130877. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  130878. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  130879. * when disposing several meshes in a row or a hierarchy of meshes.
  130880. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  130881. */
  130882. get: function () {
  130883. return this._preventFreeActiveMeshesAndRenderingGroups;
  130884. },
  130885. set: function (value) {
  130886. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  130887. return;
  130888. }
  130889. if (value) {
  130890. this.freeActiveMeshes();
  130891. this.freeRenderingGroups();
  130892. }
  130893. this._preventFreeActiveMeshesAndRenderingGroups = value;
  130894. },
  130895. enumerable: true,
  130896. configurable: true
  130897. });
  130898. /**
  130899. * Clear the active meshes smart array preventing retention point in mesh dispose.
  130900. */
  130901. Scene.prototype.freeActiveMeshes = function () {
  130902. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130903. return;
  130904. }
  130905. this._activeMeshes.dispose();
  130906. if (this.activeCamera && this.activeCamera._activeMeshes) {
  130907. this.activeCamera._activeMeshes.dispose();
  130908. }
  130909. if (this.activeCameras) {
  130910. for (var i = 0; i < this.activeCameras.length; i++) {
  130911. var activeCamera = this.activeCameras[i];
  130912. if (activeCamera && activeCamera._activeMeshes) {
  130913. activeCamera._activeMeshes.dispose();
  130914. }
  130915. }
  130916. }
  130917. };
  130918. /**
  130919. * Clear the info related to rendering groups preventing retention points during dispose.
  130920. */
  130921. Scene.prototype.freeRenderingGroups = function () {
  130922. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130923. return;
  130924. }
  130925. if (this._renderingManager) {
  130926. this._renderingManager.freeRenderingGroups();
  130927. }
  130928. if (this.textures) {
  130929. for (var i = 0; i < this.textures.length; i++) {
  130930. var texture = this.textures[i];
  130931. if (texture && texture.renderList) {
  130932. texture.freeRenderingGroups();
  130933. }
  130934. }
  130935. }
  130936. };
  130937. /** @hidden */
  130938. Scene.prototype._isInIntermediateRendering = function () {
  130939. return this._intermediateRendering;
  130940. };
  130941. /**
  130942. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  130943. * @returns the current scene
  130944. */
  130945. Scene.prototype.freezeActiveMeshes = function () {
  130946. if (!this.activeCamera) {
  130947. return this;
  130948. }
  130949. if (!this._frustumPlanes) {
  130950. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130951. }
  130952. this._evaluateActiveMeshes();
  130953. this._activeMeshesFrozen = true;
  130954. return this;
  130955. };
  130956. /**
  130957. * Use this function to restart evaluating active meshes on every frame
  130958. * @returns the current scene
  130959. */
  130960. Scene.prototype.unfreezeActiveMeshes = function () {
  130961. this._activeMeshesFrozen = false;
  130962. return this;
  130963. };
  130964. Scene.prototype._evaluateActiveMeshes = function () {
  130965. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  130966. return;
  130967. }
  130968. if (!this.activeCamera) {
  130969. return;
  130970. }
  130971. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  130972. this.activeCamera._activeMeshes.reset();
  130973. this._activeMeshes.reset();
  130974. this._renderingManager.reset();
  130975. this._processedMaterials.reset();
  130976. this._activeParticleSystems.reset();
  130977. this._activeSkeletons.reset();
  130978. this._softwareSkinnedMeshes.reset();
  130979. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  130980. var step = _a[_i];
  130981. step.action();
  130982. }
  130983. // Determine mesh candidates
  130984. var meshes = this.getActiveMeshCandidates();
  130985. // Check each mesh
  130986. var len = meshes.length;
  130987. for (var i = 0; i < len; i++) {
  130988. var mesh = meshes.data[i];
  130989. if (mesh.isBlocked) {
  130990. continue;
  130991. }
  130992. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  130993. if (!mesh.isReady() || !mesh.isEnabled()) {
  130994. continue;
  130995. }
  130996. mesh.computeWorldMatrix();
  130997. // Intersections
  130998. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  130999. this._meshesForIntersections.pushNoDuplicate(mesh);
  131000. }
  131001. // Switch to current LOD
  131002. var meshLOD = mesh.getLOD(this.activeCamera);
  131003. if (meshLOD === undefined || meshLOD === null) {
  131004. continue;
  131005. }
  131006. mesh._preActivate();
  131007. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  131008. this._activeMeshes.push(mesh);
  131009. this.activeCamera._activeMeshes.push(mesh);
  131010. mesh._activate(this._renderId);
  131011. if (meshLOD !== mesh) {
  131012. meshLOD._activate(this._renderId);
  131013. }
  131014. this._activeMesh(mesh, meshLOD);
  131015. }
  131016. }
  131017. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  131018. // Particle systems
  131019. if (this.particlesEnabled) {
  131020. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  131021. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  131022. var particleSystem = this.particleSystems[particleIndex];
  131023. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  131024. continue;
  131025. }
  131026. var emitter = particleSystem.emitter;
  131027. if (!emitter.position || emitter.isEnabled()) {
  131028. this._activeParticleSystems.push(particleSystem);
  131029. particleSystem.animate();
  131030. this._renderingManager.dispatchParticles(particleSystem);
  131031. }
  131032. }
  131033. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  131034. }
  131035. };
  131036. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  131037. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  131038. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  131039. mesh.skeleton.prepare();
  131040. }
  131041. if (!mesh.computeBonesUsingShaders) {
  131042. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  131043. }
  131044. }
  131045. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  131046. var step = _a[_i];
  131047. step.action(sourceMesh, mesh);
  131048. }
  131049. if (mesh !== undefined && mesh !== null
  131050. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  131051. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  131052. var len = subMeshes.length;
  131053. for (var i = 0; i < len; i++) {
  131054. var subMesh = subMeshes.data[i];
  131055. this._evaluateSubMesh(subMesh, mesh);
  131056. }
  131057. }
  131058. };
  131059. /**
  131060. * Update the transform matrix to update from the current active camera
  131061. * @param force defines a boolean used to force the update even if cache is up to date
  131062. */
  131063. Scene.prototype.updateTransformMatrix = function (force) {
  131064. if (!this.activeCamera) {
  131065. return;
  131066. }
  131067. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  131068. };
  131069. /**
  131070. * 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)
  131071. * @param alternateCamera defines the camera to use
  131072. */
  131073. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  131074. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  131075. };
  131076. Scene.prototype._renderForCamera = function (camera, rigParent) {
  131077. if (camera && camera._skipRendering) {
  131078. return;
  131079. }
  131080. var engine = this._engine;
  131081. this.activeCamera = camera;
  131082. if (!this.activeCamera) {
  131083. throw new Error("Active camera not set");
  131084. }
  131085. // Viewport
  131086. engine.setViewport(this.activeCamera.viewport);
  131087. // Camera
  131088. this.resetCachedMaterial();
  131089. this._renderId++;
  131090. this.updateTransformMatrix();
  131091. if (camera._alternateCamera) {
  131092. this.updateAlternateTransformMatrix(camera._alternateCamera);
  131093. this._alternateRendering = true;
  131094. }
  131095. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  131096. // Meshes
  131097. this._evaluateActiveMeshes();
  131098. // Software skinning
  131099. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  131100. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  131101. mesh.applySkeleton(mesh.skeleton);
  131102. }
  131103. // Render targets
  131104. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  131105. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  131106. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  131107. }
  131108. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  131109. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  131110. }
  131111. // Collects render targets from external components.
  131112. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  131113. var step = _a[_i];
  131114. step.action(this._renderTargets);
  131115. }
  131116. if (this.renderTargetsEnabled) {
  131117. this._intermediateRendering = true;
  131118. if (this._renderTargets.length > 0) {
  131119. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  131120. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  131121. var renderTarget = this._renderTargets.data[renderIndex];
  131122. if (renderTarget._shouldRender()) {
  131123. this._renderId++;
  131124. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  131125. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  131126. }
  131127. }
  131128. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  131129. this._renderId++;
  131130. }
  131131. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  131132. var step = _c[_b];
  131133. step.action(this.activeCamera);
  131134. }
  131135. this._intermediateRendering = false;
  131136. if (this.activeCamera.outputRenderTarget) {
  131137. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  131138. if (internalTexture) {
  131139. engine.bindFramebuffer(internalTexture);
  131140. }
  131141. else {
  131142. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  131143. }
  131144. }
  131145. else {
  131146. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  131147. }
  131148. }
  131149. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  131150. // Prepare Frame
  131151. if (this.postProcessManager) {
  131152. this.postProcessManager._prepareFrame();
  131153. }
  131154. // Before Camera Draw
  131155. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  131156. var step = _e[_d];
  131157. step.action(this.activeCamera);
  131158. }
  131159. // Render
  131160. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  131161. this._renderingManager.render(null, null, true, true);
  131162. this.onAfterDrawPhaseObservable.notifyObservers(this);
  131163. // After Camera Draw
  131164. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  131165. var step = _g[_f];
  131166. step.action(this.activeCamera);
  131167. }
  131168. // Finalize frame
  131169. if (this.postProcessManager) {
  131170. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  131171. }
  131172. // Reset some special arrays
  131173. this._renderTargets.reset();
  131174. this._alternateRendering = false;
  131175. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  131176. };
  131177. Scene.prototype._processSubCameras = function (camera) {
  131178. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131179. this._renderForCamera(camera);
  131180. return;
  131181. }
  131182. // rig cameras
  131183. for (var index = 0; index < camera._rigCameras.length; index++) {
  131184. this._renderForCamera(camera._rigCameras[index], camera);
  131185. }
  131186. this.activeCamera = camera;
  131187. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  131188. };
  131189. Scene.prototype._checkIntersections = function () {
  131190. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  131191. var sourceMesh = this._meshesForIntersections.data[index];
  131192. if (!sourceMesh.actionManager) {
  131193. continue;
  131194. }
  131195. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  131196. var action = sourceMesh.actionManager.actions[actionIndex];
  131197. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131198. var parameters = action.getTriggerParameter();
  131199. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  131200. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  131201. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  131202. if (areIntersecting && currentIntersectionInProgress === -1) {
  131203. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  131204. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131205. sourceMesh._intersectionsInProgress.push(otherMesh);
  131206. }
  131207. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131208. sourceMesh._intersectionsInProgress.push(otherMesh);
  131209. }
  131210. }
  131211. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  131212. //They intersected, and now they don't.
  131213. //is this trigger an exit trigger? execute an event.
  131214. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131215. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131216. }
  131217. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  131218. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  131219. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  131220. return otherMesh === parameterMesh;
  131221. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131222. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  131223. }
  131224. }
  131225. }
  131226. }
  131227. }
  131228. };
  131229. /** @hidden */
  131230. Scene.prototype._advancePhysicsEngineStep = function (step) {
  131231. // Do nothing. Code will be replaced if physics engine component is referenced
  131232. };
  131233. /** @hidden */
  131234. Scene.prototype._animate = function () {
  131235. // Nothing to do as long as Animatable have not been imported.
  131236. };
  131237. /**
  131238. * Render the scene
  131239. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  131240. */
  131241. Scene.prototype.render = function (updateCameras) {
  131242. if (updateCameras === void 0) { updateCameras = true; }
  131243. if (this.isDisposed) {
  131244. return;
  131245. }
  131246. this._frameId++;
  131247. // Register components that have been associated lately to the scene.
  131248. this._registerTransientComponents();
  131249. this._activeParticles.fetchNewFrame();
  131250. this._totalVertices.fetchNewFrame();
  131251. this._activeIndices.fetchNewFrame();
  131252. this._activeBones.fetchNewFrame();
  131253. this._meshesForIntersections.reset();
  131254. this.resetCachedMaterial();
  131255. this.onBeforeAnimationsObservable.notifyObservers(this);
  131256. // Actions
  131257. if (this.actionManager) {
  131258. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  131259. }
  131260. if (this._engine.isDeterministicLockStep()) {
  131261. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  131262. var defaultFPS = (60.0 / 1000.0);
  131263. var defaultFrameTime = this.getDeterministicFrameTime();
  131264. var stepsTaken = 0;
  131265. var maxSubSteps = this._engine.getLockstepMaxSteps();
  131266. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  131267. internalSteps = Math.min(internalSteps, maxSubSteps);
  131268. do {
  131269. this.onBeforeStepObservable.notifyObservers(this);
  131270. // Animations
  131271. this._animationRatio = defaultFrameTime * defaultFPS;
  131272. this._animate();
  131273. this.onAfterAnimationsObservable.notifyObservers(this);
  131274. // Physics
  131275. this._advancePhysicsEngineStep(defaultFrameTime);
  131276. this.onAfterStepObservable.notifyObservers(this);
  131277. this._currentStepId++;
  131278. stepsTaken++;
  131279. deltaTime -= defaultFrameTime;
  131280. } while (deltaTime > 0 && stepsTaken < internalSteps);
  131281. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  131282. }
  131283. else {
  131284. // Animations
  131285. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  131286. this._animationRatio = deltaTime * (60.0 / 1000.0);
  131287. this._animate();
  131288. this.onAfterAnimationsObservable.notifyObservers(this);
  131289. // Physics
  131290. this._advancePhysicsEngineStep(deltaTime);
  131291. }
  131292. // Before camera update steps
  131293. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  131294. var step = _a[_i];
  131295. step.action();
  131296. }
  131297. // Update Cameras
  131298. if (updateCameras) {
  131299. if (this.activeCameras.length > 0) {
  131300. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  131301. var camera = this.activeCameras[cameraIndex];
  131302. camera.update();
  131303. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131304. // rig cameras
  131305. for (var index = 0; index < camera._rigCameras.length; index++) {
  131306. camera._rigCameras[index].update();
  131307. }
  131308. }
  131309. }
  131310. }
  131311. else if (this.activeCamera) {
  131312. this.activeCamera.update();
  131313. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131314. // rig cameras
  131315. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  131316. this.activeCamera._rigCameras[index].update();
  131317. }
  131318. }
  131319. }
  131320. }
  131321. // Before render
  131322. this.onBeforeRenderObservable.notifyObservers(this);
  131323. // Customs render targets
  131324. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  131325. var engine = this.getEngine();
  131326. var currentActiveCamera = this.activeCamera;
  131327. if (this.renderTargetsEnabled) {
  131328. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  131329. this._intermediateRendering = true;
  131330. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  131331. var renderTarget = this.customRenderTargets[customIndex];
  131332. if (renderTarget._shouldRender()) {
  131333. this._renderId++;
  131334. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  131335. if (!this.activeCamera) {
  131336. throw new Error("Active camera not set");
  131337. }
  131338. // Viewport
  131339. engine.setViewport(this.activeCamera.viewport);
  131340. // Camera
  131341. this.updateTransformMatrix();
  131342. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  131343. }
  131344. }
  131345. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  131346. this._intermediateRendering = false;
  131347. this._renderId++;
  131348. }
  131349. // Restore back buffer
  131350. if (this.customRenderTargets.length > 0) {
  131351. engine.restoreDefaultFramebuffer();
  131352. }
  131353. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  131354. this.activeCamera = currentActiveCamera;
  131355. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  131356. var step = _c[_b];
  131357. step.action();
  131358. }
  131359. // Clear
  131360. if (this.autoClearDepthAndStencil || this.autoClear) {
  131361. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  131362. }
  131363. // Collects render targets from external components.
  131364. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  131365. var step = _e[_d];
  131366. step.action(this._renderTargets);
  131367. }
  131368. // Multi-cameras?
  131369. if (this.activeCameras.length > 0) {
  131370. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  131371. if (cameraIndex > 0) {
  131372. this._engine.clear(null, false, true, true);
  131373. }
  131374. this._processSubCameras(this.activeCameras[cameraIndex]);
  131375. }
  131376. }
  131377. else {
  131378. if (!this.activeCamera) {
  131379. throw new Error("No camera defined");
  131380. }
  131381. this._processSubCameras(this.activeCamera);
  131382. }
  131383. // Intersection checks
  131384. this._checkIntersections();
  131385. // Executes the after render stage actions.
  131386. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  131387. var step = _g[_f];
  131388. step.action();
  131389. }
  131390. // After render
  131391. if (this.afterRender) {
  131392. this.afterRender();
  131393. }
  131394. this.onAfterRenderObservable.notifyObservers(this);
  131395. // Cleaning
  131396. if (this._toBeDisposed.length) {
  131397. for (var index = 0; index < this._toBeDisposed.length; index++) {
  131398. var data = this._toBeDisposed[index];
  131399. if (data) {
  131400. data.dispose();
  131401. }
  131402. }
  131403. this._toBeDisposed = [];
  131404. }
  131405. if (this.dumpNextRenderTargets) {
  131406. this.dumpNextRenderTargets = false;
  131407. }
  131408. this._activeBones.addCount(0, true);
  131409. this._activeIndices.addCount(0, true);
  131410. this._activeParticles.addCount(0, true);
  131411. };
  131412. /**
  131413. * Freeze all materials
  131414. * A frozen material will not be updatable but should be faster to render
  131415. */
  131416. Scene.prototype.freezeMaterials = function () {
  131417. for (var i = 0; i < this.materials.length; i++) {
  131418. this.materials[i].freeze();
  131419. }
  131420. };
  131421. /**
  131422. * Unfreeze all materials
  131423. * A frozen material will not be updatable but should be faster to render
  131424. */
  131425. Scene.prototype.unfreezeMaterials = function () {
  131426. for (var i = 0; i < this.materials.length; i++) {
  131427. this.materials[i].unfreeze();
  131428. }
  131429. };
  131430. /**
  131431. * Releases all held ressources
  131432. */
  131433. Scene.prototype.dispose = function () {
  131434. this.beforeRender = null;
  131435. this.afterRender = null;
  131436. this.skeletons = [];
  131437. this.morphTargetManagers = [];
  131438. this._transientComponents = [];
  131439. this._isReadyForMeshStage.clear();
  131440. this._beforeEvaluateActiveMeshStage.clear();
  131441. this._evaluateSubMeshStage.clear();
  131442. this._activeMeshStage.clear();
  131443. this._cameraDrawRenderTargetStage.clear();
  131444. this._beforeCameraDrawStage.clear();
  131445. this._beforeRenderTargetDrawStage.clear();
  131446. this._beforeRenderingGroupDrawStage.clear();
  131447. this._beforeRenderingMeshStage.clear();
  131448. this._afterRenderingMeshStage.clear();
  131449. this._afterRenderingGroupDrawStage.clear();
  131450. this._afterCameraDrawStage.clear();
  131451. this._afterRenderTargetDrawStage.clear();
  131452. this._afterRenderStage.clear();
  131453. this._beforeCameraUpdateStage.clear();
  131454. this._beforeClearStage.clear();
  131455. this._gatherRenderTargetsStage.clear();
  131456. this._gatherActiveCameraRenderTargetsStage.clear();
  131457. this._pointerMoveStage.clear();
  131458. this._pointerDownStage.clear();
  131459. this._pointerUpStage.clear();
  131460. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  131461. var component = _a[_i];
  131462. component.dispose();
  131463. }
  131464. this.importedMeshesFiles = new Array();
  131465. this.stopAllAnimations();
  131466. this.resetCachedMaterial();
  131467. // Smart arrays
  131468. if (this.activeCamera) {
  131469. this.activeCamera._activeMeshes.dispose();
  131470. this.activeCamera = null;
  131471. }
  131472. this._activeMeshes.dispose();
  131473. this._renderingManager.dispose();
  131474. this._processedMaterials.dispose();
  131475. this._activeParticleSystems.dispose();
  131476. this._activeSkeletons.dispose();
  131477. this._softwareSkinnedMeshes.dispose();
  131478. this._renderTargets.dispose();
  131479. this._registeredForLateAnimationBindings.dispose();
  131480. this._meshesForIntersections.dispose();
  131481. this._toBeDisposed = [];
  131482. // Abort active requests
  131483. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  131484. var request = _c[_b];
  131485. request.abort();
  131486. }
  131487. // Events
  131488. this.onDisposeObservable.notifyObservers(this);
  131489. this.onDisposeObservable.clear();
  131490. this.onBeforeRenderObservable.clear();
  131491. this.onAfterRenderObservable.clear();
  131492. this.onBeforeRenderTargetsRenderObservable.clear();
  131493. this.onAfterRenderTargetsRenderObservable.clear();
  131494. this.onAfterStepObservable.clear();
  131495. this.onBeforeStepObservable.clear();
  131496. this.onBeforeActiveMeshesEvaluationObservable.clear();
  131497. this.onAfterActiveMeshesEvaluationObservable.clear();
  131498. this.onBeforeParticlesRenderingObservable.clear();
  131499. this.onAfterParticlesRenderingObservable.clear();
  131500. this.onBeforeDrawPhaseObservable.clear();
  131501. this.onAfterDrawPhaseObservable.clear();
  131502. this.onBeforeAnimationsObservable.clear();
  131503. this.onAfterAnimationsObservable.clear();
  131504. this.onDataLoadedObservable.clear();
  131505. this.onBeforeRenderingGroupObservable.clear();
  131506. this.onAfterRenderingGroupObservable.clear();
  131507. this.onMeshImportedObservable.clear();
  131508. this.onBeforeCameraRenderObservable.clear();
  131509. this.onAfterCameraRenderObservable.clear();
  131510. this.onReadyObservable.clear();
  131511. this.onNewCameraAddedObservable.clear();
  131512. this.onCameraRemovedObservable.clear();
  131513. this.onNewLightAddedObservable.clear();
  131514. this.onLightRemovedObservable.clear();
  131515. this.onNewGeometryAddedObservable.clear();
  131516. this.onGeometryRemovedObservable.clear();
  131517. this.onNewTransformNodeAddedObservable.clear();
  131518. this.onTransformNodeRemovedObservable.clear();
  131519. this.onNewMeshAddedObservable.clear();
  131520. this.onMeshRemovedObservable.clear();
  131521. this.onNewMaterialAddedObservable.clear();
  131522. this.onMaterialRemovedObservable.clear();
  131523. this.onNewTextureAddedObservable.clear();
  131524. this.onTextureRemovedObservable.clear();
  131525. this.onPrePointerObservable.clear();
  131526. this.onPointerObservable.clear();
  131527. this.onPreKeyboardObservable.clear();
  131528. this.onKeyboardObservable.clear();
  131529. this.onActiveCameraChanged.clear();
  131530. this.detachControl();
  131531. // Detach cameras
  131532. var canvas = this._engine.getRenderingCanvas();
  131533. if (canvas) {
  131534. var index;
  131535. for (index = 0; index < this.cameras.length; index++) {
  131536. this.cameras[index].detachControl(canvas);
  131537. }
  131538. }
  131539. // Release animation groups
  131540. while (this.animationGroups.length) {
  131541. this.animationGroups[0].dispose();
  131542. }
  131543. // Release lights
  131544. while (this.lights.length) {
  131545. this.lights[0].dispose();
  131546. }
  131547. // Release meshes
  131548. while (this.meshes.length) {
  131549. this.meshes[0].dispose(true);
  131550. }
  131551. while (this.transformNodes.length) {
  131552. this.removeTransformNode(this.transformNodes[0]);
  131553. }
  131554. // Release cameras
  131555. while (this.cameras.length) {
  131556. this.cameras[0].dispose();
  131557. }
  131558. // Release materials
  131559. if (this.defaultMaterial) {
  131560. this.defaultMaterial.dispose();
  131561. }
  131562. while (this.multiMaterials.length) {
  131563. this.multiMaterials[0].dispose();
  131564. }
  131565. while (this.materials.length) {
  131566. this.materials[0].dispose();
  131567. }
  131568. // Release particles
  131569. while (this.particleSystems.length) {
  131570. this.particleSystems[0].dispose();
  131571. }
  131572. // Release postProcesses
  131573. while (this.postProcesses.length) {
  131574. this.postProcesses[0].dispose();
  131575. }
  131576. // Release textures
  131577. while (this.textures.length) {
  131578. this.textures[0].dispose();
  131579. }
  131580. // Release UBO
  131581. this._sceneUbo.dispose();
  131582. if (this._alternateSceneUbo) {
  131583. this._alternateSceneUbo.dispose();
  131584. }
  131585. // Post-processes
  131586. this.postProcessManager.dispose();
  131587. // Remove from engine
  131588. index = this._engine.scenes.indexOf(this);
  131589. if (index > -1) {
  131590. this._engine.scenes.splice(index, 1);
  131591. }
  131592. this._engine.wipeCaches(true);
  131593. this._isDisposed = true;
  131594. };
  131595. Object.defineProperty(Scene.prototype, "isDisposed", {
  131596. /**
  131597. * Gets if the scene is already disposed
  131598. */
  131599. get: function () {
  131600. return this._isDisposed;
  131601. },
  131602. enumerable: true,
  131603. configurable: true
  131604. });
  131605. /**
  131606. * Call this function to reduce memory footprint of the scene.
  131607. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  131608. */
  131609. Scene.prototype.clearCachedVertexData = function () {
  131610. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131611. var mesh = this.meshes[meshIndex];
  131612. var geometry = mesh.geometry;
  131613. if (geometry) {
  131614. geometry._indices = [];
  131615. for (var vbName in geometry._vertexBuffers) {
  131616. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  131617. continue;
  131618. }
  131619. geometry._vertexBuffers[vbName]._buffer._data = null;
  131620. }
  131621. }
  131622. }
  131623. };
  131624. /**
  131625. * This function will remove the local cached buffer data from texture.
  131626. * It will save memory but will prevent the texture from being rebuilt
  131627. */
  131628. Scene.prototype.cleanCachedTextureBuffer = function () {
  131629. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131630. var baseTexture = _a[_i];
  131631. var buffer = baseTexture._buffer;
  131632. if (buffer) {
  131633. baseTexture._buffer = null;
  131634. }
  131635. }
  131636. };
  131637. /**
  131638. * Get the world extend vectors with an optional filter
  131639. *
  131640. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  131641. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  131642. */
  131643. Scene.prototype.getWorldExtends = function (filterPredicate) {
  131644. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  131645. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  131646. filterPredicate = filterPredicate || (function () { return true; });
  131647. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  131648. mesh.computeWorldMatrix(true);
  131649. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  131650. return;
  131651. }
  131652. var boundingInfo = mesh.getBoundingInfo();
  131653. var minBox = boundingInfo.boundingBox.minimumWorld;
  131654. var maxBox = boundingInfo.boundingBox.maximumWorld;
  131655. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  131656. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  131657. });
  131658. return {
  131659. min: min,
  131660. max: max
  131661. };
  131662. };
  131663. // Picking
  131664. /**
  131665. * Creates a ray that can be used to pick in the scene
  131666. * @param x defines the x coordinate of the origin (on-screen)
  131667. * @param y defines the y coordinate of the origin (on-screen)
  131668. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131669. * @param camera defines the camera to use for the picking
  131670. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131671. * @returns a Ray
  131672. */
  131673. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  131674. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131675. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131676. };
  131677. /**
  131678. * Creates a ray that can be used to pick in the scene
  131679. * @param x defines the x coordinate of the origin (on-screen)
  131680. * @param y defines the y coordinate of the origin (on-screen)
  131681. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131682. * @param result defines the ray where to store the picking ray
  131683. * @param camera defines the camera to use for the picking
  131684. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131685. * @returns the current scene
  131686. */
  131687. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  131688. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131689. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131690. };
  131691. /**
  131692. * Creates a ray that can be used to pick in the scene
  131693. * @param x defines the x coordinate of the origin (on-screen)
  131694. * @param y defines the y coordinate of the origin (on-screen)
  131695. * @param camera defines the camera to use for the picking
  131696. * @returns a Ray
  131697. */
  131698. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  131699. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131700. };
  131701. /**
  131702. * Creates a ray that can be used to pick in the scene
  131703. * @param x defines the x coordinate of the origin (on-screen)
  131704. * @param y defines the y coordinate of the origin (on-screen)
  131705. * @param result defines the ray where to store the picking ray
  131706. * @param camera defines the camera to use for the picking
  131707. * @returns the current scene
  131708. */
  131709. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  131710. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131711. };
  131712. /** Launch a ray to try to pick a mesh in the scene
  131713. * @param x position on screen
  131714. * @param y position on screen
  131715. * @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
  131716. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  131717. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131718. * @returns a PickingInfo
  131719. */
  131720. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  131721. // Dummy info if picking as not been imported
  131722. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  131723. pi._pickingUnavailable = true;
  131724. return pi;
  131725. };
  131726. /** Use the given ray to pick a mesh in the scene
  131727. * @param ray The ray to use to pick meshes
  131728. * @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
  131729. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  131730. * @returns a PickingInfo
  131731. */
  131732. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  131733. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131734. };
  131735. /**
  131736. * Launch a ray to try to pick a mesh in the scene
  131737. * @param x X position on screen
  131738. * @param y Y position on screen
  131739. * @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
  131740. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131741. * @returns an array of PickingInfo
  131742. */
  131743. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  131744. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131745. };
  131746. /**
  131747. * Launch a ray to try to pick a mesh in the scene
  131748. * @param ray Ray to use
  131749. * @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
  131750. * @returns an array of PickingInfo
  131751. */
  131752. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  131753. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131754. };
  131755. /**
  131756. * Force the value of meshUnderPointer
  131757. * @param mesh defines the mesh to use
  131758. */
  131759. Scene.prototype.setPointerOverMesh = function (mesh) {
  131760. if (this._pointerOverMesh === mesh) {
  131761. return;
  131762. }
  131763. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131764. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131765. }
  131766. this._pointerOverMesh = mesh;
  131767. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131768. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131769. }
  131770. };
  131771. /**
  131772. * Gets the mesh under the pointer
  131773. * @returns a Mesh or null if no mesh is under the pointer
  131774. */
  131775. Scene.prototype.getPointerOverMesh = function () {
  131776. return this._pointerOverMesh;
  131777. };
  131778. // Misc.
  131779. /** @hidden */
  131780. Scene.prototype._rebuildGeometries = function () {
  131781. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  131782. var geometry = _a[_i];
  131783. geometry._rebuild();
  131784. }
  131785. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  131786. var mesh = _c[_b];
  131787. mesh._rebuild();
  131788. }
  131789. if (this.postProcessManager) {
  131790. this.postProcessManager._rebuild();
  131791. }
  131792. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  131793. var component = _e[_d];
  131794. component.rebuild();
  131795. }
  131796. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  131797. var system = _g[_f];
  131798. system.rebuild();
  131799. }
  131800. };
  131801. /** @hidden */
  131802. Scene.prototype._rebuildTextures = function () {
  131803. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131804. var texture = _a[_i];
  131805. texture._rebuild();
  131806. }
  131807. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  131808. };
  131809. // Tags
  131810. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  131811. if (tagsQuery === undefined) {
  131812. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  131813. return list;
  131814. }
  131815. var listByTags = [];
  131816. forEach = forEach || (function (item) { return; });
  131817. for (var i in list) {
  131818. var item = list[i];
  131819. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  131820. listByTags.push(item);
  131821. forEach(item);
  131822. }
  131823. }
  131824. return listByTags;
  131825. };
  131826. /**
  131827. * Get a list of meshes by tags
  131828. * @param tagsQuery defines the tags query to use
  131829. * @param forEach defines a predicate used to filter results
  131830. * @returns an array of Mesh
  131831. */
  131832. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  131833. return this._getByTags(this.meshes, tagsQuery, forEach);
  131834. };
  131835. /**
  131836. * Get a list of cameras by tags
  131837. * @param tagsQuery defines the tags query to use
  131838. * @param forEach defines a predicate used to filter results
  131839. * @returns an array of Camera
  131840. */
  131841. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  131842. return this._getByTags(this.cameras, tagsQuery, forEach);
  131843. };
  131844. /**
  131845. * Get a list of lights by tags
  131846. * @param tagsQuery defines the tags query to use
  131847. * @param forEach defines a predicate used to filter results
  131848. * @returns an array of Light
  131849. */
  131850. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  131851. return this._getByTags(this.lights, tagsQuery, forEach);
  131852. };
  131853. /**
  131854. * Get a list of materials by tags
  131855. * @param tagsQuery defines the tags query to use
  131856. * @param forEach defines a predicate used to filter results
  131857. * @returns an array of Material
  131858. */
  131859. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  131860. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  131861. };
  131862. /**
  131863. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131864. * This allowed control for front to back rendering or reversly depending of the special needs.
  131865. *
  131866. * @param renderingGroupId The rendering group id corresponding to its index
  131867. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131868. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131869. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131870. */
  131871. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  131872. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  131873. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  131874. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  131875. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  131876. };
  131877. /**
  131878. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131879. *
  131880. * @param renderingGroupId The rendering group id corresponding to its index
  131881. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131882. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131883. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131884. */
  131885. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  131886. if (depth === void 0) { depth = true; }
  131887. if (stencil === void 0) { stencil = true; }
  131888. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  131889. };
  131890. /**
  131891. * Gets the current auto clear configuration for one rendering group of the rendering
  131892. * manager.
  131893. * @param index the rendering group index to get the information for
  131894. * @returns The auto clear setup for the requested rendering group
  131895. */
  131896. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  131897. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  131898. };
  131899. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  131900. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131901. get: function () {
  131902. return this._blockMaterialDirtyMechanism;
  131903. },
  131904. set: function (value) {
  131905. if (this._blockMaterialDirtyMechanism === value) {
  131906. return;
  131907. }
  131908. this._blockMaterialDirtyMechanism = value;
  131909. if (!value) { // Do a complete update
  131910. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  131911. }
  131912. },
  131913. enumerable: true,
  131914. configurable: true
  131915. });
  131916. /**
  131917. * Will flag all materials as dirty to trigger new shader compilation
  131918. * @param flag defines the flag used to specify which material part must be marked as dirty
  131919. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  131920. */
  131921. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  131922. if (this._blockMaterialDirtyMechanism) {
  131923. return;
  131924. }
  131925. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  131926. var material = _a[_i];
  131927. if (predicate && !predicate(material)) {
  131928. continue;
  131929. }
  131930. material.markAsDirty(flag);
  131931. }
  131932. };
  131933. /** @hidden */
  131934. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  131935. var _this = this;
  131936. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  131937. this._activeRequests.push(request);
  131938. request.onCompleteObservable.add(function (request) {
  131939. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  131940. });
  131941. return request;
  131942. };
  131943. /** @hidden */
  131944. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  131945. var _this = this;
  131946. return new Promise(function (resolve, reject) {
  131947. _this._loadFile(url, function (data) {
  131948. resolve(data);
  131949. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  131950. reject(exception);
  131951. });
  131952. });
  131953. };
  131954. // Statics
  131955. Scene._uniqueIdCounter = 0;
  131956. /** The fog is deactivated */
  131957. Scene.FOGMODE_NONE = 0;
  131958. /** The fog density is following an exponential function */
  131959. Scene.FOGMODE_EXP = 1;
  131960. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  131961. Scene.FOGMODE_EXP2 = 2;
  131962. /** The fog density is following a linear function. */
  131963. Scene.FOGMODE_LINEAR = 3;
  131964. /**
  131965. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  131966. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131967. */
  131968. Scene.MinDeltaTime = 1.0;
  131969. /**
  131970. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  131971. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131972. */
  131973. Scene.MaxDeltaTime = 1000.0;
  131974. /** The distance in pixel that you have to move to prevent some events */
  131975. Scene.DragMovementThreshold = 10; // in pixels
  131976. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  131977. Scene.LongPressDelay = 500; // in milliseconds
  131978. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  131979. Scene.DoubleClickDelay = 300; // in milliseconds
  131980. /** If you need to check double click without raising a single click at first click, enable this flag */
  131981. Scene.ExclusiveDoubleClickMode = false;
  131982. return Scene;
  131983. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  131984. /***/ }),
  131985. /***/ "./sceneComponent.ts":
  131986. /*!***************************!*\
  131987. !*** ./sceneComponent.ts ***!
  131988. \***************************/
  131989. /*! exports provided: SceneComponentConstants, Stage */
  131990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131991. "use strict";
  131992. __webpack_require__.r(__webpack_exports__);
  131993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  131994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  131995. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131996. /**
  131997. * Groups all the scene component constants in one place to ease maintenance.
  131998. * @hidden
  131999. */
  132000. var SceneComponentConstants = /** @class */ (function () {
  132001. function SceneComponentConstants() {
  132002. }
  132003. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  132004. SceneComponentConstants.NAME_LAYER = "Layer";
  132005. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  132006. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  132007. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  132008. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  132009. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  132010. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  132011. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  132012. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  132013. SceneComponentConstants.NAME_SPRITE = "Sprite";
  132014. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  132015. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  132016. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  132017. SceneComponentConstants.NAME_OCTREE = "Octree";
  132018. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  132019. SceneComponentConstants.NAME_AUDIO = "Audio";
  132020. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  132021. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  132022. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  132023. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  132024. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  132025. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  132026. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  132027. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  132028. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  132029. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  132030. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  132031. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  132032. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  132033. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  132034. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  132035. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  132036. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  132037. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  132038. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  132039. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  132040. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  132041. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  132042. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  132043. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  132044. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  132045. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  132046. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  132047. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  132048. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  132049. return SceneComponentConstants;
  132050. }());
  132051. /**
  132052. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  132053. * @hidden
  132054. */
  132055. var Stage = /** @class */ (function (_super) {
  132056. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  132057. /**
  132058. * Hide ctor from the rest of the world.
  132059. * @param items The items to add.
  132060. */
  132061. function Stage(items) {
  132062. return _super.apply(this, items) || this;
  132063. }
  132064. /**
  132065. * Creates a new Stage.
  132066. * @returns A new instance of a Stage
  132067. */
  132068. Stage.Create = function () {
  132069. return Object.create(Stage.prototype);
  132070. };
  132071. /**
  132072. * Registers a step in an ordered way in the targeted stage.
  132073. * @param index Defines the position to register the step in
  132074. * @param component Defines the component attached to the step
  132075. * @param action Defines the action to launch during the step
  132076. */
  132077. Stage.prototype.registerStep = function (index, component, action) {
  132078. var i = 0;
  132079. var maxIndex = Number.MAX_VALUE;
  132080. for (; i < this.length; i++) {
  132081. var step = this[i];
  132082. maxIndex = step.index;
  132083. if (index < maxIndex) {
  132084. break;
  132085. }
  132086. }
  132087. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  132088. };
  132089. /**
  132090. * Clears all the steps from the stage.
  132091. */
  132092. Stage.prototype.clear = function () {
  132093. this.length = 0;
  132094. };
  132095. return Stage;
  132096. }(Array));
  132097. /***/ })
  132098. /******/ });
  132099. });
  132100. //# sourceMappingURL=babylon.max.js.map